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

to Insert Rows from File1 to File 2 for every 10 records


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Arun_Tupili

New User


Joined: 18 Nov 2008
Posts: 3
Location: Norwich, UK

PostPosted: Thu Aug 13, 2020 6:22 pm
Reply with quote

I have below Requirement to Copy All Records From File 1 to File 2 for every 5 records in File 2.

File 1 (4 Records - 1 to 80 bytes each):-

ABCDEFGH
IJKLMNOP
QRSTUVEX
YZ12345

File 2 (19 Records - 1 to 80 bytes each):-

12345
67890
12313
45543
32454
12123
98762
32684
74456
69683
35412
31365
64532
36457
75347
12347
44543
65554
75454

Expected Output:-

ABCDEFGH
IJKLMNOP
QRSTUVEX
YZ12345
12345
67890
12313
45543
32454
ABCDEFGH
IJKLMNOP
QRSTUVEX
YZ12345
12123
98762
32684
74456
69683
ABCDEFGH
IJKLMNOP
QRSTUVEX
YZ12345
35412
31365
64532
36457
75347
ABCDEFGH
IJKLMNOP
QRSTUVEX
YZ12345
12347
44543
65554
75454

Can someone please suggest if this can be achieved using DFSORT/ICETOOL or any other utilities . I don't want to write COBOL code for this.
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


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

PostPosted: Thu Aug 13, 2020 8:10 pm
Reply with quote

Input:
Code:
//JUSTDOIT EXEC PGM=ICEMAN       
//F1       DD *                 
ABCDEFGH                         
IJKLMNOP                         
QRSTUVEX                         
YZ12345                         
/*                               
//F2       DD *                 
12345                           
67890                           
12313                           
45543                           
32454                           
12123                           
98762                           
32684                           
74456                           
69683                           
35412                           
31365                           
64532                           
36457                           
75347                           
12347                           
44543                           
65554                           
75454                           
/*                               
//SYSOUT   DD SYSOUT=*           
//SORTOUT  DD SYSOUT=*           
//SYSIN    DD *                 
  OPTION EQUALS                                               
  JOINKEYS F1=F1,FIELDS=(81,1,A),TYPE=F,SORTED                 
  JOINKEYS F2=F2,FIELDS=(81,1,A),TYPE=F                       
  JOIN UNPAIRED,F2                                             
  REFORMAT FIELDS=(F2:1,83,?,F1:1,83)                         
  SORT FIELDS=(82,2,ZD,A)                                     
  OUTFIL FNAMES=(SORTOUT),                                     
    IFTHEN=(WHEN=(84,1,CH,EQ,C'B',AND,165,3,ZD,NE,+4),         
    BUILD=(85,80)),                                           
    IFTHEN=(WHEN=(84,1,CH,EQ,C'B',AND,165,3,ZD,EQ,+4),         
      BUILD=(85,80,/,1,80)),                                   
    IFTHEN=(WHEN=NONE,BUILD=(1,80))                           
  END                                                         
/*                                                             
//JNF1CNTL DD *                                               
  INREC IFTHEN=(WHEN=INIT,                                     
    OVERLAY=(81:+0,TO=ZD,LENGTH=2,SEQNUM,1,ZD,START=1))       
  END                                                         
/*                                                             
//JNF2CNTL DD *                                               
  INREC IFTHEN=(WHEN=GROUP,PUSH=(82:ID=1,SEQ=1),RECORDS=5),   
    IFTHEN=(WHEN=(83,1,ZD,EQ,+1),OVERLAY=(81:+0,ZD,LENGTH=1)) 
  END                                                         
/*

Output:
Code:
****** **************************** Datenanfang ******
000001 ABCDEFGH                                       
000002 IJKLMNOP                                       
000003 QRSTUVEX                                       
000004 YZ12345                                       
000005 12345                                         
000006 67890                                         
000007 12313                                         
000008 45543                                         
000009 32454                                         
000010 ABCDEFGH                                       
000011 IJKLMNOP                                       
000012 QRSTUVEX                                       
000013 YZ12345                                       
000014 12123                                         
000015 98762                                         
000016 32684                                         
000017 74456                                         
000018 69683                                         
000019 ABCDEFGH                                       
000020 IJKLMNOP                                       
000021 QRSTUVEX                                       
000022 YZ12345                                       
000023 35412                                         
000024 31365                                         
000025 64532                                         
000026 36457                                         
000027 75347                                         
000028 ABCDEFGH                                       
000029 IJKLMNOP                                       
000030 QRSTUVEX                                       
000031 YZ12345                                       
000032 12347                                         
000033 44543                                         
000034 65554                                         
000035 75454                                         
****** **************************** Datenende ********
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 -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts To get the count of rows for every 1 ... DB2 3
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Access to non cataloged VSAM file JCL & VSAM 18
No new posts Compare only first records of the fil... SYNCSORT 7
Search our Forums:

Back to Top