|
View previous topic :: View next topic
|
| Author |
Message |
Indrajit_57 Warnings : 1 New User
Joined: 27 Jun 2006 Posts: 60
|
|
|
|
Hi,
I have the following requirement: -
A flat file of fixed length 80 bytes has a numeric value from 01 to 99 in the first two positions. Based on this value, we need to split this file into 99 different files. For example, if the Value is 01, it should write to FILE01, if it has a Value 02, it should write to FILE02 and so on.
I know, I can use OUTFIL FNAMES and INCLUDE COND parameters to achieve this. But in doing so I need to write 99 such statements.
Can this be done in any better way using DFSORT?
Thanks,
Indrajit |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| What problems do you feel you have doing it that way? |
|
| Back to top |
|
 |
sqlcode1
Active Member
Joined: 08 Apr 2010 Posts: 577 Location: USA
|
|
|
|
Indrajit_57,
If you are leaning towards a solution to dynamically build sort control statements then you can use sample job as below which requires an extra input file with sequence number from 01-99 (or any number you want).
Below is an example for 4 files only but you will get the idea. Alternatively, you can create a sequence number file using SORT or other utility as well. You can also create entire JCL dynamically (if you don't want to code 99 FILE01-FILE99 dd statements) and submit through INTRDR.
| Code: |
//STEP0001 EXEC PGM=SORT
//SORTIN DD *
01
02
03
04
//SORTOUT DD DSN=&&SRTCRD,UNIT=SYSDA,SPACE=(TRK,(5,5)),DISP=(,PASS)
//SYSIN DD *
OPTION COPY
OUTFIL REMOVECC,
HEADER1=(2:'OPTION COPY'),
BUILD=(2:C'OUTFIL FNAMES=FILE',1,2,C',',80:X,/,
2:C'INCLUDE=(1,2,ZD,EQ,',1,2,C')')
/*
//SYSOUT DD SYSOUT=*
//*
//STEP0002 EXEC PGM=SORT
//SORTIN DD *
01SQLCODE01A
02SQLCODE02B
02SQLCODE02C
03SQLCODE03D
03SQLCODE03E
03SQLCODE03F
04SQLCODE04G
04SQLCODE04H
04SQLCODE04I
04SQLCODE04J
//FILE01 DD SYSOUT=*
//FILE02 DD SYSOUT=*
//FILE03 DD SYSOUT=*
//FILE04 DD SYSOUT=*
//SORTOUT DD SYSOUT=*
//SYSIN DD DSN=&&SRTCRD,DISP=SHR
//SYSOUT DD SYSOUT=*
//* |
Thanks, |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
If you have a problem coding the OUTFIL/INCLUDE statements you can generate them like shown below.
| Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
DUMMY RECORD
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL REPEAT=100,IFOUTLEN=80,
IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,3,ZD,START=0)),
IFTHEN=(WHEN=(81,3,ZD,EQ,0),BUILD=(3:C'OPTION COPY')),
IFTHEN=(WHEN=NONE,
BUILD=(3:C'OUTFIL FNAMES=OUT',SEQNUM,2,ZD,
C',INCLUDE=(1,2,ZD,EQ,',SEQNUM,2,ZD,C')'))
//* |
|
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|