Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Split a file into n different files

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
Vamshi Veludandi

New User


Joined: 17 Mar 2009
Posts: 23
Location: Bangalore

PostPosted: Tue Feb 14, 2012 1:27 pm    Post subject: Split a file into n different files
Reply with quote

Hi,

I need to split the input file (VB 100) into 'n' different output files (VB 100).
But the catch here is that I only know that the keyfield is @ column (1,7). I have no idea what the key values are.
Based on keyvalue present in column (1,7) I need to split the files.

One this is for sure that the not more than 10 different keyvalues in Column 1,7 will be there in the input file. There can be thousands of records for each key value.


Input File:
Code:

----+----1----+----2----+----3----+----4----
***************************** Top of Data *******
AAA1111 sdfasdfsdfsdf                       
AAA1111 fdfsdfsdfsd                         
AAA1111  dfasf    sdsd                     
AAA2222    fsdasd                           
AAA2222    fadffaf                         
AAA2222  zxcvafsdfds                       
BBB1111  423rsfsdafsdaf                     
BBB1111 sdfasdfsdfsdf                       
BBB1111 fdfsdfsdfsd                         
BBB3333  dfsfsda  sdsd                     
BBB3333    fsdasd                           
BBB3333    fadfsdfsdafsd                   
BBB3333  zxcvafsdfds    fd                 
**************************** Bottom of Data *****


Output Files:
Code:

----+----1----+----2----+----3----+----4----+----5
***************************** Top of Data ********
AAA1111 sdfasdfsdfsdf                             
AAA1111 fdfsdfsdfsd                               
AAA1111  dfasf    sdsd                           
**************************** Bottom of Data ******

Code:

----+----1----+----2----+----3----+----4----+----5
***************************** Top of Data ********
AAA2222    fsdasd                           
AAA2222    fadffaf                         
AAA2222  zxcvafsdfds                       
**************************** Bottom of Data ******

Code:

----+----1----+----2----+----3----+----4----+----5
***************************** Top of Data ********
BBB1111  423rsfsdafsdaf                     
BBB1111 sdfasdfsdfsdf                       
BBB1111 fdfsdfsdfsd                             
**************************** Bottom of Data ******

Code:

----+----1----+----2----+----3----+----4----+----5
***************************** Top of Data ********
BBB3333  dfsfsda  sdsd                     
BBB3333    fsdasd                           
BBB3333    fadfsdfsdafsd                   
BBB3333  zxcvafsdfds    fd                           
**************************** Bottom of Data ******



Is it possible to split a file without knowing the keyvalue or the number records to be split ?

Regards,
Vamshi.
Back to top
View user's profile Send private message

enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10256
Location: italy

PostPosted: Tue Feb 14, 2012 1:43 pm    Post subject: Reply to: Split a file into n different files
Reply with quote

all depends on the FULL requirement...

if the output dsname is irrelevant and You bear some empty datasets
You can do it in one pass
( since You say that there will be no more than 10 keys )
see here for a snippet ( just change the key accordingly )
http://www.ibmmainframes.com/viewtopic.php?t=55695&highlight=split

but if on the other side the output dsname MUST relate to the <key>
and You NEED to create the exact number of datasets
You will have to use a two pass approach
pass1 <scan> the input to determine the keys and GENERATE/SUBMIT the
pass2 job that will do the splitting

note...
if the key can be used as a dataset qualifier the key can be up to 8 chars
otherwise it must be at max 7 to prefix it with a <letter> to make it a valid qualifier
Back to top
View user's profile Send private message
Vamshi Veludandi

New User


Joined: 17 Mar 2009
Posts: 23
Location: Bangalore

PostPosted: Tue Feb 14, 2012 5:52 pm    Post subject:
Reply with quote

Thanks Enrico,

Thats exactly what I needed.
Though my current requirement doesn't need "exact number of datasets" or "datasets with the key as part of the dsname", I will try to implement it using intrdr.

Regards,
Vamshi.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10256
Location: italy

PostPosted: Tue Feb 14, 2012 7:48 pm    Post subject: Reply to: Split a file into n different files
Reply with quote

here is a snippet to use as a trace ( modify to suit Your environment )
Code:

 ****** ***************************** Top of Data ******************************
 000001 //ENRICO1  JOB (ACCT#),'SPLIT1',NOTIFY=ENRICO,                         
 000002 //             CLASS=A,MSGCLASS=X,MSGLEVEL=(1,1)                       
 000003 //* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 000004 //*                                                                     
 000005 //ICE1    EXEC PGM=SORT                                                 
 000006 //SYSPRINT  DD SYSOUT=*                                                 
 000007 //SYSOUT    DD SYSOUT=*                                                 
 000008 //SORTIN    DD * <THE MOTHER OF INPUT>                                 
 000009 AAA0001 REC1                                                           
 000010 AAA0001 REC2                                                           
 000011 BBB0001 REC1                                                           
 000012 BBB0001 REC2                                                           
 000013 BBB0001 REC3                                                           
 ==CHG> //ICEJCL    DD DISP=(,PASS),DSN=&JCL,                                   
 000015 //             DCB=(RECFM=FB,LRECL=80),                                 
 000016 //             UNIT=VIO,SPACE=(TRK,(1,1))                               
 ==CHG> //ICECTL    DD DISP=(,PASS),DSN=&CTL,                                   
 000018 //             DCB=(RECFM=FB,LRECL=80),                                 
 000019 //             UNIT=VIO,SPACE=(TRK,(1,1))                               
 000020 //SYSIN     DD *                                                       
 000021   OPTION COPY                                                           
 000022   INREC  BUILD=(1,7,8:SEQNUM,8,ZD,RESTART=(1,7),80:X)                   
 000023   OUTFIL FNAMES=ICEJCL,                                                 
 000024     INCLUDE=(8,8,ZD,EQ,1),                                             
 000025     REMOVECC,                                                           
 000026     HEADER1=('//SPLIT2   JOB NOTIFY=&SYSUID,'/,                         
 000027              '//             CLASS=A,MSGCLASS=X,',/,                   
 000028              '//             MSGLEVEL=(1,1)',/,                         
 000029              '//*',/,                                                   
 000030              '//ICE     EXEC PGM=SORT',/,                               
 000031              '//SYSPRINT  DD SYSOUT=*',/,                               
 000032              '//SYSOUT    DD SYSOUT=*',/,                               
 000033              '//SORTIN    DD DISP=(HR)',/,                       
 000034              '//             DSN=<THE MOTHER OF INPUT>'),               
 000035     TRAILER1=('//SYSIN    DD *'),                                       
 000036     BUILD=(1:C'//',1,7,13:C'DD DISP=(,CATLG),',80:X,/,                 
 000037            1:C'//',16:C'DSN=HLQ1.HLQ2.',1,7,C',',80:X,/,               
 000038            1:C'//',16:C'UNIT=.....,',80:X,/,                           
 000039            1:C'//',16:C'SPACE=....,',80:X,/,                           
 000040            1:C'//',16:C'DCB=...,',80:X)                                 
 000041   OUTFIL FNAMES=ICECTL,                                                 
 000042     INCLUDE=(8,8,ZD,EQ,1),                                             
 000043     REMOVECC,                                                           
 000044     HEADER1=('  OPTION COPY'),                                         
 000045     TRAILER1=('/*',/,'//'),                                             
 000046     BUILD=(3:C'OUTFIL FNAMES=',1,7,                                     
 000047                       C',INCLUDE=(1,7,CH,EQ,C''',1,7,C''')',80:X)       
 000048 //ICE2    EXEC PGM=SORT                                                 
 000049 //SYSPRINT  DD SYSOUT=*                                                 
 000050 //SYSOUT    DD SYSOUT=*                                                 
 ==CHG> //SORTIN    DD DISP=(OLD,PASS),DSN=&JCL                                 
 ==CHG> //          DD DISP=(OLD,PASS),DSN=&CTL                                 
 000053 //SORTOUT   DD SYSOUT=*                                                 
 000054 //SYSIN     DD *                                                       
 000055   OPTION COPY                                                           
 ****** **************************** Bottom of Data ****************************



Frank or Kolusu might come up with a better solution
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Tue Feb 14, 2012 11:06 pm    Post subject:
Reply with quote

Vamshi Veludandi,

Since your input can only have a max of 10 datasets I suggest that you hard code the DSN names and later on delete them if they are empty. Use the following DFSORT JCL which will give you the desired results
Code:

//STEP0100 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTIN   DD DSN=Your input VB 100 byte file,DISP=SHR
//OUT01    DD DSN=Your output file-01,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,
//            SPACE=(CYL,(X,Y),RLSE)
//*
//OUT02    DD DSN=Your output file-02,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,
//            SPACE=(CYL,(X,Y),RLSE)
//*
//OUT03    DD DSN=Your output file-03,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,
//            SPACE=(CYL,(X,Y),RLSE)
//*
//OUT04    DD DSN=Your output file-04,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,
//            SPACE=(CYL,(X,Y),RLSE)
//*
//OUT05    DD DSN=Your output file-05,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,
//            SPACE=(CYL,(X,Y),RLSE)
//*
//OUT06    DD DSN=Your output file-06,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,
//            SPACE=(CYL,(X,Y),RLSE)
//*
//OUT07    DD DSN=Your output file-07,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,
//            SPACE=(CYL,(X,Y),RLSE)
//*
//OUT08    DD DSN=Your output file-08,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,
//            SPACE=(CYL,(X,Y),RLSE)
//*
//OUT09    DD DSN=Your output file-09,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,
//            SPACE=(CYL,(X,Y),RLSE)
//*
//OUT10    DD DSN=Your output file-10,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,
//            SPACE=(CYL,(X,Y),RLSE)
//*
//SYSIN    DD *                                                   
  SORT FIELDS=COPY                                                 
  INREC IFTHEN=(WHEN=INIT,BUILD=(1,4,2X,5)),                       
        IFTHEN=(WHEN=GROUP,KEYBEGIN=(7,7),PUSH=(5:ID=2))           

  OUTFIL FNAMES=OUT01,INCLUDE=(5,2,ZD,EQ,01),BUILD=(1,4,7)         
  OUTFIL FNAMES=OUT02,INCLUDE=(5,2,ZD,EQ,02),BUILD=(1,4,7)         
  OUTFIL FNAMES=OUT03,INCLUDE=(5,2,ZD,EQ,03),BUILD=(1,4,7)         
  OUTFIL FNAMES=OUT04,INCLUDE=(5,2,ZD,EQ,04),BUILD=(1,4,7)         
  OUTFIL FNAMES=OUT05,INCLUDE=(5,2,ZD,EQ,05),BUILD=(1,4,7)         
  OUTFIL FNAMES=OUT06,INCLUDE=(5,2,ZD,EQ,06),BUILD=(1,4,7)         
  OUTFIL FNAMES=OUT07,INCLUDE=(5,2,ZD,EQ,07),BUILD=(1,4,7)         
  OUTFIL FNAMES=OUT08,INCLUDE=(5,2,ZD,EQ,08),BUILD=(1,4,7)         
  OUTFIL FNAMES=OUT09,INCLUDE=(5,2,ZD,EQ,09),BUILD=(1,4,7)         
  OUTFIL FNAMES=OUT10,INCLUDE=(5,2,ZD,EQ,10),BUILD=(1,4,7)         
//*
//STEP0200 EXEC PGM=IDCAMS                   
//SYSPRINT DD SYSOUT=*                       
//IN01     DD DISP=SHR,DSN=Your output file-01
//IN02     DD DISP=SHR,DSN=Your output file-02
//IN03     DD DISP=SHR,DSN=Your output file-03
//IN04     DD DISP=SHR,DSN=Your output file-04
//IN05     DD DISP=SHR,DSN=Your output file-05
//IN06     DD DISP=SHR,DSN=Your output file-06
//IN07     DD DISP=SHR,DSN=Your output file-07
//IN08     DD DISP=SHR,DSN=Your output file-08
//IN09     DD DISP=SHR,DSN=Your output file-09
//IN10     DD DISP=SHR,DSN=Your output file-10
//SYSIN    DD *                               
  PRINT INFILE(IN01) CHARACTER COUNT(1)       
  IF LASTCC = 4 THEN DELETE 'Your output file-01'
  PRINT INFILE(IN02) CHARACTER COUNT(1)       
  IF LASTCC = 4 THEN DELETE 'Your output file-02'
  PRINT INFILE(IN03) CHARACTER COUNT(1)       
  IF LASTCC = 4 THEN DELETE 'Your output file-03'
  PRINT INFILE(IN04) CHARACTER COUNT(1)       
  IF LASTCC = 4 THEN DELETE 'Your output file-04'
  PRINT INFILE(IN05) CHARACTER COUNT(1)       
  IF LASTCC = 4 THEN DELETE 'Your output file-05'
  PRINT INFILE(IN06) CHARACTER COUNT(1)       
  IF LASTCC = 4 THEN DELETE 'Your output file-06'
  PRINT INFILE(IN07) CHARACTER COUNT(1)       
  IF LASTCC = 4 THEN DELETE 'Your output file-07'
  PRINT INFILE(IN08) CHARACTER COUNT(1)       
  IF LASTCC = 4 THEN DELETE 'Your output file-08'
  PRINT INFILE(IN09) CHARACTER COUNT(1)       
  IF LASTCC = 4 THEN DELETE 'Your output file-09'
  PRINT INFILE(IN10) CHARACTER COUNT(1)       
  IF LASTCC = 4 THEN DELETE 'Your output file-10'
//*
Back to top
View user's profile Send private message
Vamshi Veludandi

New User


Joined: 17 Mar 2009
Posts: 23
Location: Bangalore

PostPosted: Wed Feb 15, 2012 5:09 pm    Post subject: Reply to: Split a file into n different files
Reply with quote

Thanks a lot Kolusu,

The code snippet you mentioned did the job perfectly.
Deleting the empty datasets was much easier and simple.

Thank you one and all.

Regards,
Vamshi.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm
No new posts Unable to create multiple files using... mbattu COBOL Programming 3 Fri May 05, 2017 5:35 pm
No new posts Getting error while opening a variabl... apandey1 COBOL Programming 5 Fri May 05, 2017 12:22 pm
This topic is locked: you cannot edit posts or make replies. Merge two files and update Trailer re... Yashashri JCL & VSAM 1 Thu May 04, 2017 12:54 pm
No new posts Issue with NDM process to transmit ES... chetanambi All Other Mainframe Topics 6 Wed May 03, 2017 10:52 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us