MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Split a file into different files
Goto page 1, 2  Next
 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
programmer1
Beginner


Joined: 18 Feb 2004
Posts: 138
Topics: 14

PostPosted: Tue Jul 20, 2004 11:34 am    Post subject: Split a file into different files Reply with quote

Hi,

I have a input file with this layout:

File Header (Can be Distinguished with a field having a value FH)
Batch Header (Can be Distinguished with a field having a value BH)
Detail Record1
Detail Record2
..
..
Detail Recordn
Batch Trailer(Can be Distinguished with a field having a value BT)
Batch Header (Can be Distinguished with a field having a value BH)
Detail Record1
Detail Record2
..
..
Detail Recordn
Batch Trailer(Can be Distinguished with a field having a value BT)
..
..
.
.
Batch Trailer(Can be Distinguished with a field having a value BT)
File Trailer(Can be Distinguished with a field having a value FT)


I need to split this file into different files (Just 8, this number is fixed: so there are only 8 batches).

I need 1 file for each batch.

There is no way to distinguish the detail records from the other detail records, the only difference is that they lie in different batchs.

Can this functionality be achieved using a JCL ?
_________________
Regards,
Programmer
Back to top
View user's profile Send private message
Alain Benveniste
Beginner


Joined: 04 May 2003
Posts: 92
Topics: 4
Location: Paris, France

PostPosted: Tue Jul 20, 2004 12:22 pm    Post subject: Reply with quote

Do you have the same number of records in each group ?

Alain
Back to top
View user's profile Send private message
programmer1
Beginner


Joined: 18 Feb 2004
Posts: 138
Topics: 14

PostPosted: Tue Jul 20, 2004 1:35 pm    Post subject: Reply with quote

No, There can be any number of records in each group and the number is not fixed. All the batches can have different number of records.
_________________
Regards,
Programmer
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Tue Jul 20, 2004 1:37 pm    Post subject: Reply with quote

programmer1,

Please post the LRECL,RECFM of the input file. Also tell us the postion where the record identifier is (i.e position of BH, BT in the file)

Also Will there be a corresponding trailer(BT) record for every header record(BH)?

i.e Every batch has a Header(BH) record and is followed by 'N' number of detail records and then finally ending up with a Trailer record(BT). If that is true then it is very easy to split the file into batches.

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
programmer1
Beginner


Joined: 18 Feb 2004
Posts: 138
Topics: 14

PostPosted: Wed Jul 21, 2004 7:01 am    Post subject: Reply with quote

Hi Kolusu,

The LRECL is 1675 bytes and the its Fixed Block.

The indicator (BH, BT, FH, FT) can be located at position 08 - 09 bytes. (2 Bytes).

Yes, There will always be a corresponding Batch Trailer for every Batch Header and we want the detail records with in this batch to be written to a output file.

Please lemme know, if you need any other info..
_________________
Regards,
Programmer
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Wed Jul 21, 2004 7:39 am    Post subject: Reply with quote

Programmer1,

The following DFSORT/ICETOOL JCL will give you the desired results. If you have syncsort at your shop then change the pgm name to synctool. A brief description of the solution.

The first copy operator takes in the input file and creates 2 files. We just take the indicator (BH, BT, FH, FT) which is 2 bytes from position 08 and add a seqnum to each record with outrec.

Now we split the file into 2 file , BH & BT . The BH file will have all the batch header records and BT file will have the batch trailer records.

Using OUTREC we create dynamic control with STARTREC & ENDREC parms.

Now the second SORT operator takes the contatenation of the above 2 files and actually creates the dynamic control cards. Since you wanted only the first 8 batches, we write out only the first 8 control cards.
Code:

//STEP0100 EXEC PGM=ICETOOL         
//TOOLMSG   DD SYSOUT=*             
//DFSMSG    DD SYSOUT=*             
//IN        DD DSN=YOUR INPUT FILE,
//             DISP=SHR
//BH        DD DSN=&BH,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)     
//BT        DD DSN=&BT,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)     
//CON       DD DSN=&BH,DISP=OLD,VOL=REF=*.BH                   
//          DD DSN=&BT,DISP=OLD,VOL=REF=*.BT                   
//BATCH001  DD DSN=YOUR 1ST BATCH RECORDS,
//             DISP=(NEW,CATLG,DELETE),
//             UNIT=SYSDA,
//             SPACE=(CYL,(X,Y),RLSE)
//BATCH002  DD DSN=YOUR 2ND BATCH RECORDS,
//             DISP=(NEW,CATLG,DELETE),
//             UNIT=SYSDA,
//             SPACE=(CYL,(X,Y),RLSE)
....
//BATCH008  DD DSN=YOUR 8TH BATCH RECORDS,
//             DISP=(NEW,CATLG,DELETE),
//             UNIT=SYSDA,
//             SPACE=(CYL,(X,Y),RLSE)
//TOOLIN    DD *               
  COPY FROM(IN)  USING(CTL1)   
  SORT FROM(CON) USING(CTL2)   
  COPY FROM(IN)  USING(CTL3)   
//CTL1CNTL  DD *                                           
  OUTREC FIELDS=(8,2,SEQNUM,8,ZD)                         
  OUTFIL FNAMES=BH,INCLUDE=(1,2,CH,EQ,C'BH'),             
  OUTREC=(C' OUTFIL FNAMES=BATCH',SEQNUM,3,ZD,             
          C',STARTREC=',3,8,                               
          C',ENDREC=00000000',80:X,SEQNUM,8,ZD)           
  OUTFIL FNAMES=BT,INCLUDE=(1,2,CH,EQ,C'BT'),             
  OUTREC=(49X,3,8,80:X,SEQNUM,8,ZD)                       
//CTL2CNTL  DD *                                           
  SORT FIELDS=(81,8,CH,A)                                 
  SUM FIELDS=(50,8,ZD)                                     
  OUTFIL FNAMES=CTL3CNTL,ENDREC=8,OUTREC=(1,80)           
//CTL3CNTL  DD DSN=&C1,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)
/*                                                         


The above job will copy the first 8 batches with their batch header and batch trailer record.

If you do not want the batch header and trailer then change the CTL1CNTL to the following

Code:

//CTL1CNTL  DD *                                               
  OUTREC FIELDS=(8,2,SEQNUM,8,ZD)                               
  OUTFIL FNAMES=BH,INCLUDE=(1,2,CH,EQ,C'BH'),                   
  OUTREC=(C' OUTFIL FNAMES=BATCH',SEQNUM,3,ZD,                 
          C',STARTREC=',+1,ADD,3,8,ZD,EDIT=(TTTTTTTT),         
          C',ENDREC=00000000',80:X,SEQNUM,8,ZD)                 
  OUTFIL FNAMES=BT,INCLUDE=(1,2,CH,EQ,C'BT'),                   
  OUTREC=(49X,+1,SUB,3,8,ZD,EDIT=(TTTTTTTT),80:X,SEQNUM,8,ZD)   


This will allow you to copy just the detail records.

Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
programmer1
Beginner


Joined: 18 Feb 2004
Posts: 138
Topics: 14

PostPosted: Wed Jul 21, 2004 12:17 pm    Post subject: Reply with quote

Hi Kolusu,

Thanx alot for helping me.

I tried this JCL, but then I guess there is some problem with this:

The concatenated Dataset has not come up correctly. Are we using the SUM fields correctly ? I assume that there is some error in the CTL2CNTL.

Also, in the statement

OUTFIL FNAMES=CTL3CNTL,ENDREC=8,OUTREC=(1,80)

Can you please explain me the significance of ENDREC=8
_________________
Regards,
Programmer
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Wed Jul 21, 2004 12:31 pm    Post subject: Reply with quote

Programmer1,

Please post the error messages. As such the code runs fine on my machine. Post your sysout from DFSMSG and TOOLMSG.

ENDREC=8 means that the process stops after writting 8 records to the output file. In your first post you mentioned that you wanted to write only 8 batch detail records.

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
programmer1
Beginner


Joined: 18 Feb 2004
Posts: 138
Topics: 14

PostPosted: Thu Jul 22, 2004 9:15 am    Post subject: Reply with quote

Hi Kolusu,

Here are the error messages that I am getting:

DFSMSG:
Code:

ICE000I 0 - CONTROL STATEMENTS FOR 5740-SM1, DFSORT REL 14.0 - 11:31 ON THU JUL
           OUTFIL FNAMES=BATCH001,STARTREC=00000002,ENDREC=0000000F
                                                                  $
ICE007A 1 SYNTAX ERROR
                                                           0000001A
                                                           $
ICE007A 0 SYNTAX ERROR
           OUTFIL FNAMES=BATCH003,STARTREC=00000012,ENDREC=0000001F
                                                                  $
ICE007A 1 SYNTAX ERROR
                                                           0000002A
                                                           $
ICE007A 0 SYNTAX ERROR


TOOLMSG:

            COPY FROM(IN)  USING(CTL3)
ICE606I 0 DFSORT CALL 0003 FOR COPY FROM IN       TO OUTFIL   USING CTL3CNTL TERMINATED
ICE602I 0 OPERATION RETURN CODE:  16


If we see the $ sign above, it suggests that our concatenated file, which has dynamic control statements to allocate a file has some problem.
_________________
Regards,
Programmer
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Thu Jul 22, 2004 9:31 am    Post subject: Reply with quote

Programmer1,

The error you are getting is due to your shop default option of NZDPRINT which means do not convert positive ZD summation results to printable numbers.

So all you need to do is add this line in CTL2CNTL control card. Add this line as the first line.

Code:

  OPTION ZDPRINT 


ZDPRINT means convert positive ZD summation results to printable numbers.

Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Thu Jul 22, 2004 9:44 am    Post subject: Reply with quote

Note that in DFSORT R14, the shipped installation default for ZDPRINT is NO, but in z/OS DFSORT V1R5, we've changed the shipped installation default for ZDPRINT to YES.
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
programmer1
Beginner


Joined: 18 Feb 2004
Posts: 138
Topics: 14

PostPosted: Thu Jul 22, 2004 1:10 pm    Post subject: Reply with quote

Hi,

Thanx Kolusu / Frank,

I am sorry, but then there is still some problem while running the code. Here is the DFSMSG:

ICE000I 0 - CONTROL STATEMENTS FOR 5740-SM1, DFSORT REL 14.0 - 15:46 ON THU JUL
OUTFIL FNAMES=BATCH001,STARTREC=00000002,ENDREC=00000006
00000011
$
ICE007A 0 SYNTAX ERROR
OUTFIL FNAMES=BATCH003,STARTREC=00000012,ENDREC=00000016
00000021
$
ICE007A 0 SYNTAX ERROR
_________________
Regards,
Programmer
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Thu Jul 22, 2004 1:14 pm    Post subject: Reply with quote

programmer1,


Did you run the job shown by me? post your JCL.

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
programmer1
Beginner


Joined: 18 Feb 2004
Posts: 138
Topics: 14

PostPosted: Thu Jul 22, 2004 1:54 pm    Post subject: Reply with quote

Yes Kolusu,

I assume so. Here is the Job:
Code:

//STEP0100 EXEC PGM=ICETOOL
//TOOLMSG   DD SYSOUT=*
//DFSMSG    DD SYSOUT=*
//IN        DD DSN=XBHA153.SPLIT.TEST1,
//             DISP=SHR
//BH        DD DSN=&BH,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//BT        DD DSN=&BT,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//CON       DD DSN=&BH,DISP=OLD,VOL=REF=*.BH
//          DD DSN=&BT,DISP=OLD,VOL=REF=*.BT
//BATCH001  DD DSN=XBHA153.BATCH.FILE1,
//             DISP=(NEW,CATLG,DELETE),
//             UNIT=SYSDA,
//             SPACE=(CYL,(1,1),RLSE)
//BATCH002  DD DSN=XBHA153.BATCH.FILE2,
//             DISP=(NEW,CATLG,DELETE),
//             UNIT=SYSDA,
//             SPACE=(CYL,(1,1),RLSE)
//BATCH003  DD DSN=XBHA153.BATCH.FILE3,
//             DISP=(NEW,CATLG,DELETE),
//             UNIT=SYSDA,
//             SPACE=(CYL,(1,1),RLSE)
//BATCH004  DD DSN=XBHA153.BATCH.FILE4,
//             DISP=(NEW,CATLG,DELETE),
//             UNIT=SYSDA,
//             SPACE=(CYL,(1,1),RLSE)
//BATCH005  DD DSN=XBHA153.BATCH.FILE5,
//             DISP=(NEW,CATLG,DELETE),
//             UNIT=SYSDA,
//             SPACE=(CYL,(1,1),RLSE)
//BATCH006  DD DSN=XBHA153.BATCH.FILE6,
//             DISP=(NEW,CATLG,DELETE),
//             UNIT=SYSDA,
//             SPACE=(CYL,(1,1),RLSE)
//BATCH007  DD DSN=XBHA153.BATCH.FILE7,
//             DISP=(NEW,CATLG,DELETE),
//             UNIT=SYSDA,
//             SPACE=(CYL,(1,1),RLSE)
//BATCH008  DD DSN=XBHA153.BATCH.FILE8,
//             DISP=(NEW,CATLG,DELETE),
//             UNIT=SYSDA,
//             SPACE=(CYL,(1,1),RLSE)
//TOOLIN    DD *
  COPY FROM(IN)  USING(CTL1)
  SORT FROM(CON) USING(CTL2)
  COPY FROM(IN)  USING(CTL3)
//CTL1CNTL  DD *
  OUTREC FIELDS=(8,2,SEQNUM,8,ZD)
  OUTFIL FNAMES=BH,INCLUDE=(1,2,CH,EQ,C'BH'),
  OUTREC=(C' OUTFIL FNAMES=BATCH',SEQNUM,3,ZD,
          C',STARTREC=',3,8,
          C',ENDREC=00000000',80:X,SEQNUM,8,ZD)
  OUTFIL FNAMES=BT,INCLUDE=(1,2,CH,EQ,C'BT'),
  OUTREC=(49X,3,8,80:X,SEQNUM,8,ZD)
//CTL2CNTL  DD *
  OPTION ZDPRINT
  SORT FIELDS=(81,8,CH,A)
  SUM FIELDS=(50,8,ZD)
  OUTFIL FNAMES=CTL3CNTL,ENDREC=8,OUTREC=(1,80)
//CTL3CNTL  DD DSN=&C1,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)
/*

_________________
Regards,
Programmer
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Thu Jul 22, 2004 2:39 pm    Post subject: Reply with quote

Programmer/Kolusu,

You need to add the EQUALS parameter in CTL2CNTL. Kolusu - you probably have EQUALS as the default at your shop, whereas Programmer doesn't.

I got the same error Programmer got with:

Code:

  OPTION ZDPRINT


I changed it to:

Code:

  OPTION ZDPRINT,EQUALS


and the error disappeared.
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group