|
View previous topic :: View next topic
|
| Author |
Message |
Suraj.Nair
New User
Joined: 07 Jun 2011 Posts: 17 Location: Canada
|
|
|
|
Hi
I have an input file which has some records. It has a header and trailer. I would like to split the file based on two consecutive characters present in the detail records. The characters can be either 'AB' or 'AC'. The two files hence generated should have header copied from the original file. After splitting the trailer has to be updated to the new files with the new count. The trailer also has some text at the beginning and at the end of the trailer record the count has to be updated( count being of 8 character length). Kindly help
Thanks Suraj |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Your description is too vague.
Please show an example of the records in your input file (relevant fields only) and what you expect for output. Explain the "rules" for getting from input to output. Give the starting position, length and format of each relevant field. Give the RECFM and LRECL of the input file.
Tell or show us what identifies the header and trailer.
Also, run this job and show the //SYSOUT messages you receive, so I can see what level you're at:
| Code: |
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
RECORD
//SORTOUT DD DUMMY
//SYSIN DD *
OPTION COPY
/*
|
|
|
| Back to top |
|
 |
Suraj.Nair
New User
Joined: 07 Jun 2011 Posts: 17 Location: Canada
|
|
|
|
Input file layout:
000 20110606165432
0011134567860123456AB E 145190273033344
0011222333344445555AB E 145190273033344
0011139567890123456AC E 145190273033344
0011222333244445555AC E 145190273033344
999999999999999999900000004
The starting position of the field is 20, length is 2 and the type is character
The output files
File1:
000 20110606165432
0011134567860123456AB E 145190273033344
0011222333344445555AB E 145190273033344
999999999999999999900000004
File2:
000 20110606165432
0011139567890123456AC E 145190273033344
0011222333244445555AC E 145190273033344
999999999999999999900000004 |
|
| Back to top |
|
 |
Suraj.Nair
New User
Joined: 07 Jun 2011 Posts: 17 Location: Canada
|
|
|
|
Sorry... the output files should have the new count
Input file layout:
000 20110606165432
0011134567860123456AB E 145190273033344
0011222333344445555AB E 145190273033344
0011139567890123456AC E 145190273033344
0011222333244445555AC E 145190273033344
999999999999999999900000004
The starting position of the field is 20, length is 2 and the type is character
The output files
File1:
000 20110606165432
0011134567860123456AB E 145190273033344
0011222333344445555AB E 145190273033344
999999999999999999900000002
File2:
000 20110606165432
0011139567890123456AC E 145190273033344
0011222333244445555AC E 145190273033344
999999999999999999900000002 |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
Suraj.Nair,
Assuming your input is FB recfm and LRECL =80, the following DFSORT JCL will give you the desired results
| Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
000 20110606165432 COPY
0011134567860123456AB E 145190273033344
0011222333344445555AB E 145190273033344
0011139567890123456AC E 145190273033344
0011222333244445555AC E 145190273033344
999999999999999999900000004
//ABOUT DD SYSOUT=*
//ACOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL FNAMES=ABOUT,IFOUTLEN=80,
INCLUDE=(1,3,SS,EQ,C'000,999',OR,20,2,CH,EQ,C'AB'),
IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD)),
IFTHEN=(WHEN=(1,3,CH,EQ,C'999'),
OVERLAY=(20:81,8,ZD,SUB,+2,M11,LENGTH=8))
OUTFIL FNAMES=ACOUT,IFOUTLEN=80,
INCLUDE=(1,3,SS,EQ,C'000,999',OR,20,2,CH,EQ,C'AC'),
IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD)),
IFTHEN=(WHEN=(1,3,CH,EQ,C'999'),
OVERLAY=(20:81,8,ZD,SUB,+2,M11,LENGTH=8))
//* |
|
|
| Back to top |
|
 |
Suraj.Nair
New User
Joined: 07 Jun 2011 Posts: 17 Location: Canada
|
|
|
|
| Thanks Kolusu for the help... |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Alternatively, you can do it with the new IFTRAIL function of DFSORT like this:
| Code: |
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
000 20110606165432
0011134567860123456AB E 145190273033344
0011222333344445555AB E 145190273033344
0011139567890123456AC E 145190273033344
0011222333244445555AC E 145190273033344
999999999999999999900000004
//OUT1 DD SYSOUT=*
//OUT2 DD SYSOUT=*
//SYSIN DD *
OPTION COPY
OUTFIL FNAMES=OUT1,INCLUDE=(20,2,CH,EQ,C'AB'),
IFTRAIL=(HD=YES,TRLID=(1,3,CH,EQ,C'999'),
TRLUPD=(20:COUNT=(M11,LENGTH=8)))
OUTFIL FNAMES=OUT2,INCLUDE=(20,2,CH,EQ,C'AC'),
IFTRAIL=(HD=YES,TRLID=(1,3,CH,EQ,C'999'),
TRLUPD=(20:COUNT=(M11,LENGTH=8)))
/*
|
For more information on IFTRAIL, see:
www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000242 |
|
| Back to top |
|
 |
Suraj.Nair
New User
Joined: 07 Jun 2011 Posts: 17 Location: Canada
|
|
|
|
| Thanks Frank... |
|
| Back to top |
|
 |
Suraj.Nair
New User
Joined: 07 Jun 2011 Posts: 17 Location: Canada
|
|
|
|
Hi
A small update to the above question.
Can we update the output files header with the type of accounts that are present, meaning, if the type is AB it should be present in the 19 position of the header.
Thanks in advance
Suraj |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
You can replace my DFSORT control statements with the following to make that change:
| Code: |
OPTION COPY
OUTFIL FNAMES=OUT1,INCLUDE=(1,3,CH,EQ,C'000',OR,20,2,CH,EQ,C'AB'),
IFTHEN=(WHEN=(1,3,CH,EQ,C'000'),OVERLAY=(19:C'AB')),
IFTRAIL=(TRLID=(1,3,CH,EQ,C'999'),
TRLUPD=(20:COUNT-1=(M11,LENGTH=8)))
OUTFIL FNAMES=OUT2,INCLUDE=(1,3,CH,EQ,C'000',OR,20,2,CH,EQ,C'AC'),
IFTHEN=(WHEN=(1,3,CH,EQ,C'000'),OVERLAY=(19:C'AC')),
IFTRAIL=(TRLID=(1,3,CH,EQ,C'999'),
TRLUPD=(20:COUNT-1=(M11,LENGTH=8)))
|
|
|
| Back to top |
|
 |
Suraj.Nair
New User
Joined: 07 Jun 2011 Posts: 17 Location: Canada
|
|
|
|
Hi
In the above count of records if I want to add the count of header and trailer as well, what would be needed to be done. Kindly help.
Thanks Suraj |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
| Suraj.Nair wrote: |
Hi
In the above count of records if I want to add the count of header and trailer as well, what would be needed to be done. Kindly help.
Thanks Suraj |
Change Count-1 to Count+1 to add the count of header and trailer. |
|
| Back to top |
|
 |
Suraj.Nair
New User
Joined: 07 Jun 2011 Posts: 17 Location: Canada
|
|
|
|
Hi
I tried that....it doesnt work....
Thanks Suraj |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
| Suraj.Nair wrote: |
Hi
I tried that....it doesnt work....
Thanks Suraj |
What do you mean it doesn't work? I ran this job
| Code: |
//STEP0400 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
000 20110606165432
0011134567860123456AB E 145190273033344
0011222333344445555AB E 145190273033344
0011139567890123456AC E 145190273033344
0011222333244445555AC E 145190273033344
999999999999999999900000004
//OUT1 DD SYSOUT=*
//OUT2 DD SYSOUT=*
//SYSIN DD *
OPTION COPY
OUTFIL FNAMES=OUT1,INCLUDE=(1,3,CH,EQ,C'000',OR,20,2,CH,EQ,C'AB'),
IFTHEN=(WHEN=(1,3,CH,EQ,C'000'),OVERLAY=(19:C'AB')),
IFTRAIL=(TRLID=(1,3,CH,EQ,C'999'),
TRLUPD=(20:COUNT+1=(M11,LENGTH=8)))
OUTFIL FNAMES=OUT2,INCLUDE=(1,3,CH,EQ,C'000',OR,20,2,CH,EQ,C'AC'),
IFTHEN=(WHEN=(1,3,CH,EQ,C'000'),OVERLAY=(19:C'AC')),
IFTRAIL=(TRLID=(1,3,CH,EQ,C'999'),
TRLUPD=(20:COUNT+1=(M11,LENGTH=8)))
//* |
and I got
| Code: |
000 20110606165432AB
0011134567860123456AB E 145190273033344
0011222333344445555AB E 145190273033344
999999999999999999900000004
|
The count is 4 records . You need to show me what you did. |
|
| Back to top |
|
 |
Suraj.Nair
New User
Joined: 07 Jun 2011 Posts: 17 Location: Canada
|
|
|
|
Hi SKolusu,
You are right. I hadn't changed the TRLUPD for the first output so didnt get the updated count. Sorry for the inconvenience.
Thanks Suraj |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|