Posted: Tue Jul 20, 2004 11:34 am Post subject: Split a file into different files
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
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
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
Posted: Tue Jul 20, 2004 1:37 pm Post subject:
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.
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
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
Posted: Wed Jul 21, 2004 7:39 am Post subject:
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.
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
Posted: Wed Jul 21, 2004 12:31 pm Post subject:
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.
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
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
Posted: Thu Jul 22, 2004 9:31 am Post subject:
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.
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Thu Jul 22, 2004 9:44 am Post subject:
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
Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Thu Jul 22, 2004 2:39 pm Post subject:
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
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