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

Synctool-dynamic split job for varying files and record coun


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Kalyani karuppiah

New User


Joined: 24 Mar 2023
Posts: 2
Location: Chennai

PostPosted: Fri Mar 24, 2023 4:07 pm
Reply with quote

My requirement is to split one input file to multiple files (I don't know how many as it can vary for each run) and also the endrec is not constant first file I might need to send 100 records second file I can send 230 records based on a header.

Sample input:

Header1
Aaa
Baa
Can
Header2
Daa
Eaa
Faaa
F
Gaa
Header3
Haha
Iaaa
Jaaa
Kaaa

I used the below code and it dynamically allotted number of output files based on my input record count but it equally splits the file. How to split the file using header and modify the endrec number based on my header keyword position in my file.

//STEP1 EXEC PGM=SYNCTOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN= Your.input.file
//T1 DD DSN=&&T1,DISP=(,PASS)
//OUT DD SYSOUT=*
//TOOLIN DD *
COPY FROM(IN) TO(T1) USING(CTL1)
SORT FROM(T1) TO(OUT) USING(CTL2)
//CTL1CNTL DD *
INREC OVERLAY=(81:SEQNUM,8,ZD,89:81,8,ZD,MOD,+5,M11,LENGTH=8)
OUTFIL INCLUDE=(89,8,ZD,EQ,1),
BUILD=(C' OUTFIL FILES=',SEQNUM,2,ZD,C',STARTREC=',81,8,C',',
C'ENDREC=',81,8,ZD,ADD,+4,M11,LENGTH=8,/,
C'//SORTOF',SEQNUM,2,ZD,C' DD DSN=xxxx.SPLTFILE.F',
SEQNUM,2,ZD,C',UNIT=SYSDA,',/,
C'//',12X,C'SPACE=(CYL,(100,100),RLSE),DISP=(,CATLG)',80:X)
//CTL2CNTL DD *
INREC IFTHEN=(WHEN=(1,1,CH,EQ,C' '),OVERLAY=(81:C'0')),
IFTHEN=(WHEN=NONE,OVERLAY=(81:C'9'))
SORT FIELDS=(81,1,CH,A)
OUTFIL REMOVECC,BUILD=(1,80),
HEADER1=(C'//xxxxxxxx JOB (YYYY),''SPLIT'',CLASS=A,MSGCLASS=X,',/,
C'// REGION=2048K,NOTIFY=&SYSUID',/,
C'//STEP1 EXEC PGM=SORT',/,
C'//SYSOUT DD SYSOUT=*',/,
C'//SORTIN DD DSN=Your.input.file,DISP=SHR',/,
C'//SYSIN DD *',/,
C' OPTION COPY',80:X)

The above job is for writing 5 records each into each of the split files.

I have given the final output filenames as
Code:
xxxx.SPLTFILE.F01
xxxx.SPLTFILE.F02
..............
..............


.[/quote]
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2133
Location: USA

PostPosted: Fri Mar 24, 2023 5:10 pm
Reply with quote

Unless you learned how to use the Code button to present your samples of code and data, nobody would dig into your pile of garbage.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2133
Location: USA

PostPosted: Fri Mar 24, 2023 5:42 pm
Reply with quote

P.S.

0) SYNCTOOL is using //SSMSG DD for log messages, not //DFSMSG DD

1) Before "creating a JCL to generate another JCL" you need to learn by yourself: how to create that final JCL manually?

2) The way to detect variable number of records between your "headers", or whatever else, may be: try using IFTHEN=(WHEN=GROUP,...) parameters

3) This question is related mainly to SYNCSORT, rather than to JCL section
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2133
Location: USA

PostPosted: Fri Mar 24, 2023 6:13 pm
Reply with quote

The simple solution, without using the "bend over backwards" methods, might be like this one below.
The only question to be resolved is: how to deal with those output datasets which left empty?
Code:
//SPLIT    EXEC PGM=SYNCSORT     
//SYSOUT   DD  SYSOUT=*         
//*                             
//SORTIN   DD  *                 
Header1                         
Aaa                             
Baa                             
Can                             
Header2                         
Daa                             
Eaa                             
Faaa                             
F                               
Gaa                             
Header3                         
Haha                             
Iaaa                             
Jaaa                             
Kaaa                             
//*                             
//SORTOF01 DD  SYSOUT=*         
//SORTOF02 DD  SYSOUT=*         
//SORTOF03 DD  SYSOUT=*         
//SORTOF04 DD  SYSOUT=*         
//SORTOF05 DD  SYSOUT=*         
//SORTOF06 DD  SYSOUT=*                                                 
//SORTOF07 DD  SYSOUT=*                                                 
//SORTOF08 DD  SYSOUT=*                                                 
//SORTOF09 DD  SYSOUT=*                                                 
//SORTOF10 DD  SYSOUT=*                                                 
//*                                                                     
//SYSIN    DD  *                                                       
 INREC IFTHEN=(WHEN=GROUP,                                             
               BEGIN=(1,6,CH,EQ,C'Header'),                             
               PUSH=(81:ID=2))                                         
 SORT FIELDS=COPY                                                       
 OUTFIL FNAMES=SORTOF01,INCLUDE=(81,2,CH,EQ,C'01'),BUILD=(1,80)         
 OUTFIL FNAMES=SORTOF02,INCLUDE=(81,2,CH,EQ,C'02'),BUILD=(1,80)         
 OUTFIL FNAMES=SORTOF03,INCLUDE=(81,2,CH,EQ,C'03'),BUILD=(1,80)         
 OUTFIL FNAMES=SORTOF04,INCLUDE=(81,2,CH,EQ,C'04'),BUILD=(1,80)         
 OUTFIL FNAMES=SORTOF05,INCLUDE=(81,2,CH,EQ,C'05'),BUILD=(1,80)         
 OUTFIL FNAMES=SORTOF06,INCLUDE=(81,2,CH,EQ,C'06'),BUILD=(1,80)         
 OUTFIL FNAMES=SORTOF07,INCLUDE=(81,2,CH,EQ,C'07'),BUILD=(1,80)         
 OUTFIL FNAMES=SORTOF08,INCLUDE=(81,2,CH,EQ,C'08'),BUILD=(1,80)         
 OUTFIL FNAMES=SORTOF09,INCLUDE=(81,2,CH,EQ,C'09'),BUILD=(1,80)         
 OUTFIL FNAMES=SORTOF10,INCLUDE=(81,2,CH,EQ,C'10'),BUILD=(1,80)         
//*                                                                     
//*=====================================================================


Code:
********************************* TOP OF DATA *********
Header1                                               
Aaa                                                   
Baa                                                   
Can                                                   
******************************** BOTTOM OF DATA *******

Code:
********************************* TOP OF DATA ***********
Header2                                                 
Daa                                                     
Eaa                                                     
Faaa                                                     
F                                                       
Gaa                                                     
******************************** BOTTOM OF DATA *********

Code:
********************************* TOP OF DATA ********
Header3                                               
Haha                                                 
Iaaa                                                 
Jaaa                                                 
Kaaa                                                 
******************************** BOTTOM OF DATA ******
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2133
Location: USA

PostPosted: Fri Mar 24, 2023 6:13 pm
Reply with quote

dup ...
Back to top
View user's profile Send private message
Kalyani karuppiah

New User


Joined: 24 Mar 2023
Posts: 2
Location: Chennai

PostPosted: Fri Mar 24, 2023 6:28 pm
Reply with quote

sergeyken wrote:
The simple solution, without using the "bend over backwards" methods, might be like this one below.
The only question to be resolved is: how to deal with those output datasets which left empty?
Code:
//SPLIT    EXEC PGM=SYNCSORT     
//SYSOUT   DD  SYSOUT=*         
//*                             
//SORTIN   DD  *                 
Header1                         
Aaa                             
Baa                             
Can                             
Header2                         
Daa                             
Eaa                             
Faaa                             
F                               
Gaa                             
Header3                         
Haha                             
Iaaa                             
Jaaa                             
Kaaa                             
//*                             
//SORTOF01 DD  SYSOUT=*         
//SORTOF02 DD  SYSOUT=*         
//SORTOF03 DD  SYSOUT=*         
//SORTOF04 DD  SYSOUT=*         
//SORTOF05 DD  SYSOUT=*         
//SORTOF06 DD  SYSOUT=*                                                 
//SORTOF07 DD  SYSOUT=*                                                 
//SORTOF08 DD  SYSOUT=*                                                 
//SORTOF09 DD  SYSOUT=*                                                 
//SORTOF10 DD  SYSOUT=*                                                 
//*                                                                     
//SYSIN    DD  *                                                       
 INREC IFTHEN=(WHEN=GROUP,                                             
               BEGIN=(1,6,CH,EQ,C'Header'),                             
               PUSH=(81:ID=2))                                         
 SORT FIELDS=COPY                                                       
 OUTFIL FNAMES=SORTOF01,INCLUDE=(81,2,CH,EQ,C'01'),BUILD=(1,80)         
 OUTFIL FNAMES=SORTOF02,INCLUDE=(81,2,CH,EQ,C'02'),BUILD=(1,80)         
 OUTFIL FNAMES=SORTOF03,INCLUDE=(81,2,CH,EQ,C'03'),BUILD=(1,80)         
 OUTFIL FNAMES=SORTOF04,INCLUDE=(81,2,CH,EQ,C'04'),BUILD=(1,80)         
 OUTFIL FNAMES=SORTOF05,INCLUDE=(81,2,CH,EQ,C'05'),BUILD=(1,80)         
 OUTFIL FNAMES=SORTOF06,INCLUDE=(81,2,CH,EQ,C'06'),BUILD=(1,80)         
 OUTFIL FNAMES=SORTOF07,INCLUDE=(81,2,CH,EQ,C'07'),BUILD=(1,80)         
 OUTFIL FNAMES=SORTOF08,INCLUDE=(81,2,CH,EQ,C'08'),BUILD=(1,80)         
 OUTFIL FNAMES=SORTOF09,INCLUDE=(81,2,CH,EQ,C'09'),BUILD=(1,80)         
 OUTFIL FNAMES=SORTOF10,INCLUDE=(81,2,CH,EQ,C'10'),BUILD=(1,80)         
//*                                                                     
//*=====================================================================


Code:
********************************* TOP OF DATA *********
Header1                                               
Aaa                                                   
Baa                                                   
Can                                                   
******************************** BOTTOM OF DATA *******

Code:
********************************* TOP OF DATA ***********
Header2                                                 
Daa                                                     
Eaa                                                     
Faaa                                                     
F                                                       
Gaa                                                     
******************************** BOTTOM OF DATA *********

Code:
********************************* TOP OF DATA ********
Header3                                               
Haha                                                 
Iaaa                                                 
Jaaa                                                 
Kaaa                                                 
******************************** BOTTOM OF DATA ******


Yes and also I might need more than 10 files too due to the input file size, so cannot define it in a straightforward way
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


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

PostPosted: Fri Mar 24, 2023 6:44 pm
Reply with quote

If you have HDR/TRL, IFTHEN=(GROUP,.. PUSH is the best option. When splitting by numbers only, see SPLITBY* keywords.

It is left to the TS to solve the problem of too few or too many DSNs being allocated.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2133
Location: USA

PostPosted: Fri Mar 24, 2023 11:23 pm
Reply with quote

Kalyani karuppiah wrote:

Yes and also I might need more than 10 files too due to the input file size, so cannot define it in a straightforward way

1. What prevents you from defining, let's say, 100 datasets in a straightforward way (not files, @#$%&$#!!!)?

2. As I already mentioned: this is the first step you need to do, and to understand deeply: HOW TO CREATE THE REQUIRED JCL MANUALLY. Next step might be: how to create another JCL, to dynamically generate the first one?

3. There are other tools available, to really dynamically allocate exactly the required number of datasets. But you don't need a musket to shoot a butterfly, I believe so.
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 -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts 3 files concatenated to 1 DFSORT/ICETOOL 2
No new posts Copy only TEXT or String from a record SYNCSORT 4
No new posts JCL sort to compare dates in two file... DFSORT/ICETOOL 2
No new posts combine multiple unique records into ... DFSORT/ICETOOL 2
No new posts SORT on detail record, then repeat he... DFSORT/ICETOOL 3
Search our Forums:

Back to Top