IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Selective extract of multi-record-type data


IBM Mainframe Forums -> SYNCSORT
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
cybertaurean

New User


Joined: 22 Dec 2008
Posts: 87
Location: US

PostPosted: Thu Aug 26, 2021 10:29 pm
Reply with quote

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
View user's profile Send private message
Joerg.Findeisen

Active Member


Joined: 15 Aug 2015
Posts: 606
Location: Bamberg, Germany

PostPosted: Fri Aug 27, 2021 3:04 am
Reply with quote

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
View user's profile Send private message
sergeyken
Warnings : 2

Senior Member


Joined: 29 Apr 2008
Posts: 1189

PostPosted: Fri Aug 27, 2021 6:33 pm
Reply with quote

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
View user's profile Send private message
Joerg.Findeisen

Active Member


Joined: 15 Aug 2015
Posts: 606
Location: Bamberg, Germany

PostPosted: Fri Aug 27, 2021 6:39 pm
Reply with quote

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
View user's profile Send private message
cybertaurean

New User


Joined: 22 Dec 2008
Posts: 87
Location: US

PostPosted: Sat Aug 28, 2021 2:49 am
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> SYNCSORT

 


Similar Topics
Topic Forum Replies
No new posts Adding a header when change data DFSORT/ICETOOL 6
No new posts SORT for dynamic trailer record + CSV... DFSORT/ICETOOL 14
No new posts Expected data is not coming up on Fir... CICS 2
No new posts Data for newly added fields not displ... IMS DB/DC 5
No new posts COBOL Table data to a flat file with ... COBOL Programming 8
Search our Forums:

Back to Top