View previous topic :: View next topic
|
Author |
Message |
cybertaurean
New User

Joined: 22 Dec 2008 Posts: 87 Location: US
|
|
|
|
Hi,
I have a data that has the following structure -
H123
A1
B2
C3
T
H123
A2
B2
C3
T
with record types H, A, B, C and T.
In a file with multiple occurrences of the above, is there a way to output only the blocks (H, A, B, C and T) that correspond to a record type A having a value of "1". In the example above, the following should be output -
H123
A1
B2
C3
T
since it has a "1" next to record type A. The second block has "2" next to type "A".
Thanks |
|
Back to top |
|
 |
Joerg.Findeisen
Senior Member

Joined: 15 Aug 2015 Posts: 1390 Location: Bamberg, Germany
|
|
|
|
Code: |
//WHATEVER EXEC PGM=SORT
//F1 DD *
H123
E5
A1
B2
C3
T
H123
A2
B2
C3
T
/*
//F2 DD .. <* Exactly the same as DD:F1
//SYSOUT DD SYSOUT=*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
JOINKEYS F1=F1,FIELDS=(20,8,A)
JOINKEYS F2=F2,FIELDS=(20,8,A)
REFORMAT FIELDS=(F1:1,9,F2:29,8)
OUTFIL FNAMES=(SORTOUT),
INCLUDE=(10,8,BI,NE,+0),
BUILD=(1,9)
END
/*
//JNF1CNTL DD *
INREC IFTHEN=(WHEN=GROUP,
BEGIN=(1,1,CH,EQ,C'H'),END=(1,1,CH,EQ,C'T'),PUSH=(20:ID=8))
END
/*
//JNF2CNTL DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(29:8Z)),
IFTHEN=(WHEN=GROUP,
BEGIN=(1,1,CH,EQ,C'H'),END=(1,1,CH,EQ,C'T'),PUSH=(20:ID=8)),
IFTHEN=(WHEN=(1,2,CH,EQ,C'A1'),OVERLAY=(29:+1,TO=BI,LENGTH=8))
SUM FIELDS=(29,8,BI)
END
/* |
Output:
Code: |
****** ********************
000001 H123
000002 E5
000003 A1
000004 B2
000005 C3
000006 T
****** ******************** |
|
|
Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2218 Location: USA
|
|
|
|
Giving the answer as a working code with not a single comment or explanation of the approach, - it is the best way to get tomorrow a new question from the same TS regarding his new daily task.
You're looking at a free lunch, boys.
Free meal is tempting... |
|
Back to top |
|
 |
Joerg.Findeisen
Senior Member

Joined: 15 Aug 2015 Posts: 1390 Location: Bamberg, Germany
|
|
|
|
I could have written that the same questions have been asked a couple of times in the past. Besides that, the question was asked without code tags and proper formatting. Basically it should have been ignored at all. |
|
Back to top |
|
 |
cybertaurean
New User

Joined: 22 Dec 2008 Posts: 87 Location: US
|
|
|
|
Thanks Joerg.Findeisen. That worked for me.
On a different note, isn't there a way to reply to the person on this forum, similar to slack? Saves the need to copy paste the name of the individual. |
|
Back to top |
|
 |
|
|