Posted: Wed Jun 22, 2022 2:44 pm Post subject: Split record with Include and Omit.
Good day everyone, trying to split multiple occurrences of the same record into multiple separate records under few conditions.
Have a seq. dataset, RECFM=FB,LRECL=685 holding account records with multiple transaction dates + their types. There could be up to 7 occurrences of date+type per record.
I put together a Sort step that does it without problems, the issue is with an OMIT st-t I'm trying to use to avoid picking up empty occurrences. The OMIT is being ignored and I'm getting records without dates in the output.
Condition.
Select all records where REL-CODE = RDL4 and ACCOUNT-DATE/TYPE is not blank. Split each ACCOUNT-DATE/TYPE occurrence into separate record keeping ACCOUNT-NUM.
Input data.
Layout.
Code:
Ref Field Name Picture Type Start End Length
**** Top of data ****
1 1 INPUT-REC AN 1 685 685
2 2 ACCOUNT-NUM X(15) AN 1 15 15
3 2 REL-CODE X(04) AN 16 19 4
4 2 ACCOUNT-TABLE OCCURS 7 TIMES
4 2 ACCOUNT-TABLE(1) AN 20 29 10
5 3 ACCOUNT-DATE(1) X(08) AN 20 27 8
6 3 ACCOUNT-TYPE(1) X(02) AN 28 29 2
4 2 ACCOUNT-TABLE(2) AN 30 39 10
5 3 ACCOUNT-DATE(2) X(08) AN 30 37 8
6 3 ACCOUNT-TYPE(2) X(02) AN 38 39 2
4 2 ACCOUNT-TABLE(3) AN 40 49 10
5 3 ACCOUNT-DATE(3) X(08) AN 40 47 8
6 3 ACCOUNT-TYPE(3) X(02) AN 48 49 2
4 2 ACCOUNT-TABLE(4) AN 50 59 10
5 3 ACCOUNT-DATE(4) X(08) AN 50 57 8
6 3 ACCOUNT-TYPE(4) X(02) AN 58 59 2
4 2 ACCOUNT-TABLE(5) AN 60 69 10
5 3 ACCOUNT-DATE(5) X(08) AN 60 67 8
6 3 ACCOUNT-TYPE(5) X(02) AN 68 69 2
4 2 ACCOUNT-TABLE(6) AN 70 79 10
5 3 ACCOUNT-DATE(6) X(08) AN 70 77 8
6 3 ACCOUNT-TYPE(6) X(02) AN 78 79 2
4 2 ACCOUNT-TABLE(7) AN 80 89 10
5 3 ACCOUNT-DATE(7) X(08) AN 80 87 8
6 3 ACCOUNT-TYPE(7) X(02) AN 88 89 2
7 2 REST X(596) AN 90 685 596
Code:
ACCOUNT-NUM REL-CODE DATE(1) TYPE(1) DATE(2) TYPE(2) DATE(3) TYPE(3) DATE(4) TYPE(4) DATE(5) TYPE(5) DATE(6) TYPE(6) DATE(7) TYPE(7)
111111111111111 RDL4 20220217 TR 20220520 SM 20220610 SY
222222222222222 RDL0 20220216 TB 20220531 SO 20220601 SY 20220610 FZ
333333333333333 ARSM 20220111 NN 20220223 MM 20220603 SS 20220610 FZ
444444444444444 RDL4 20220115 CA 20220313 EB 20220517 AY 20220608 OW 20220615 LE
Expected Output.
Code:
111111111111111 20220217 TR
111111111111111 20220520 SM
111111111111111 20220610 SY
444444444444444 20220115 CA
444444444444444 20220313 EB
444444444444444 20220517 AY
444444444444444 20220608 OW
444444444444444 20220615 LE
I did it through the DFSort step below, but the output included all empty DATE/TYPE occurrences preceded with ACCOUNT-NUM. Tried adding an OMIT st-t after OUTFIL BUILD but that had no impact.
Code:
//SYSIN DD *
INCLUDE COND=(16,4,CH,EQ,C'RDL4')
OPTION COPY
OUTFIL BUILD=(1,15,20,10,/,1,15,30,10,/,1,15,40,10,/,1,15,50,10,/,
1,15,60,10,/,1,15,70,10,/,1,15,80,10)
If you remembered or searched for resize you could have adapted the above solution to your latest requirement.
Taking that base line solution, you could have simply built the Account-num + Date as array of 7 entries making a 175 byte record and use resize with a TOLEN 25 bytes. Using OMIT on OUTFIL you could have skipped writing the records with spaces in date
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
Posted: Sat Jun 25, 2022 2:56 pm Post subject:
ramy2016 wrote:
Thank you kolusu, I remembered of RESIZE but was wondering if I could use OMIT along with OUTFIL BUILD.
Is it possible at all?
OMIT works on RECORD level and not on FIELD level. So if you want to use OUTFIL OMIT then you can code IFTHEN statements to cover all the permutations and combinations. Since you have 7 entries, you will need to 7! (5040 ) to cover all the possible scenarios.
RESIZE is breaking up the 175 bytes record into 7 records and using OMIT will be on the RECORD level.
The goal should be about solving the problem but NOT get fixated on a solution which may work or may not. _________________ Kolusu
www.linkedin.com/in/kolusu
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum