View previous topic :: View next topic
Author
Message
die7nadal Active User Joined: 23 Mar 2005Posts: 156
Here is my input file 30/FB
Code:
AA1111111012345678901234
DDDDDDDDD000000000000234
DDDDDDDDD000000000000234
DDDDDDDDD000000000000234
DDDDDDDDD000000000000234
DDDDDDDDD000000000000234
DDDDDDDDD000000000000234
My output file should look like
Code:
AA0000003000000000000468
DDDDDDDDD000000000000234
DDDDDDDDD000000000000234
I should pick the first 3 records including the header record identified by 'AA' in the first 2 chars. Then I will have to adjust the record count to 3 in 3,7 and sum in 10,15 of the header. I should sum the detail records in 13,3. The number of records that I pick is variable, so it will not always be 3.
I know how to arrive at the solution using multiple passes of the file. But is there any solution using just one ot two passes of the file (using SECTIONS). I am just trying to figure if there is a better way than mine.
Back to top
dick scherrer Moderator Emeritus Joined: 23 Nov 2006Posts: 19244 Location: Inside the Matrix
Hello,
It may help someone help you if you post what you have working now. . .
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
die7nadal,
Here's a two-pass DFSORT/ICETOOL job that will do what you asked for:
Code:
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=... input file (FB/30)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//OUT DD DSN=... output file (FB/30)
//TOOLIN DD *
COPY FROM(IN) USING(CTL1)
SORT FROM(T1) TO(OUT) USING(CTL2)
/*
//CTL1CNTL DD *
OPTION COPY,STOPAFT=3
OUTFIL FNAMES=T1,REMOVECC,
OMIT=(1,2,CH,EQ,C'AA'),
TRAILER1=('AA',COUNT+1=(M11,LENGTH=7),
TOT=(10,15,ZD,TO=ZD,LENGTH=15))
/*
//CTL2CNTL DD *
OPTION EQUALS
SORT FIELDS=(1,2,CH,A)
/*
Quote:
The number of records that I pick is variable, so it will not always be 3.
You can change the STOPAFT value to whatever you need.
Back to top
die7nadal Active User Joined: 23 Mar 2005Posts: 156
Frank, I knew you would come up with something. Thanks a lot.
Back to top
Skolusu Senior Member Joined: 07 Dec 2007Posts: 2205 Location: San Jose
die7nadal,
FWIW here is a 1 pass solution
Code:
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=Your input fb 30 bytes,DISP=SHR
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY,STOPAFT=3
INREC IFTHEN=(WHEN=INIT,BUILD=(1,30,91:SEQNUM,1,ZD)),
IFTHEN=(WHEN=GROUP,BEGIN=(91,1,ZD,EQ,1),PUSH=(61:1,30)),
IFTHEN=(WHEN=GROUP,BEGIN=(91,1,ZD,EQ,2),PUSH=(31:1,30))
OUTFIL INCLUDE=(91,1,ZD,EQ,3),
BUILD=(61,2,C'0000003',10,15,ZD,ADD,40,15,ZD,ZD,LENGTH=15,85,6,/,
31,30,/,1,30)
//*
Back to top
die7nadal Active User Joined: 23 Mar 2005Posts: 156
Thanks a lot Skolusu.
Back to top
Please enable JavaScript!