|
View previous topic :: View next topic
|
| Author |
Message |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
| Arun Raj wrote: |
Hi Bill,
I just went through the topic you gave, i doubt if the same can be applied here in this case, anyways that was a good one though!. Thanks Bill
btw for this one, I just worked out one method, but can't post it here due to compatibility issues. The topic is old, but I got surprised by the number of views!  |
Arun,
Here is a version which would get the desired results.
| Code: |
//STEP0100 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD *
DATA1
DATA2
DATA3
PAYM
DATA4
DATA5
DATA6
DATA1
PAYM
PAYM
DATA2
DATA3
DATA4
DATA5
DATA6
//OUT DD SYSOUT=*
//TOOLIN DD *
SELECT FROM(IN) TO(OUT) ON(32501,8,CH) ALLDUPS USING(CTL1)
//CTL1CNTL DD *
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=INIT,OVERLAY=(32501:SEQNUM,8,ZD)),
IFTHEN=(WHEN=GROUP,BEGIN=(1,4,CH,EQ,C'PAYM'),RECORDS=2,
PUSH=(32510:SEQ=1)),
IFTHEN=(WHEN=(32510,1,CH,GT,C' '),
OVERLAY=(32501:32501,8,ZD,SUB,32510,1,ZD,M11,LENGTH=8))
OUTFIL BUILD=(1,32500)
//* |
The output from this is
| Code: |
DATA3
PAYM
DATA4
DATA1
PAYM
PAYM
DATA2 |
|
|
| Back to top |
|
 |
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
Hi,
I thought this topic was dead and buried, this was a solution I had but requires 2 passes of the file
| Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
DATA1
DATA2
DATA3
PAYM
DATA4
DATA5
DATA6
DATA1
PAYM
PAYM
DATA2
DATA3
DATA4
DATA5
DATA6
//DRIVER DD DSN=&&DRIVER,
// DISP=(,PASS,DELETE),
// UNIT=SYSDA,
// SPACE=(TRK,(10,5),RLSE)
//ALL#RECS DD DSN=&&ALL#RECS,
// DISP=(,PASS,DELETE),
// UNIT=SYSDA,
// SPACE=(TRK,(10,5),RLSE)
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=INIT,
OVERLAY=(81:SEQNUM,8,ZD,
89:81,8,ZD,SUB,+1,EDIT=(TTTTTTTT),
97:81,8,ZD,ADD,+1,EDIT=(TTTTTTTT)))
OUTFIL FNAMES=DRIVER,INCLUDE=(1,4,CH,EQ,C'PAYM'),
BUILD=(81,8,/,89,8,/,97,8)
OUTFIL FNAMES=ALL#RECS,INCLUDE=(81,8,ZD,GT,+0)
//*
//STEP0200 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=&&DRIVER,
// DISP=(OLD,DELETE)
//SORTOUT DD DSN=&&SORTOUT,
// DISP=(,PASS,DELETE),
// UNIT=SYSDA,
// SPACE=(TRK,(10,5),RLSE)
//SYSIN DD *
SORT FIELDS=(1,8,BI,A)
SUM FIELDS=NONE
//*
//STEP0300 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//INA DD DSN=&&SORTOUT,
// DISP=(OLD,DELETE)
//INB DD DSN=&&ALL#RECS,
// DISP=(OLD,DELETE)
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
JOINKEYS F1=INA,FIELDS=(01,8,A),SORTED,NOSEQCK
JOINKEYS F2=INB,FIELDS=(81,8,A),SORTED,NOSEQCK
JOIN UNPAIRED
REFORMAT FIELDS=(F2:1,080,?)
OUTFIL INCLUDE=(081,1,CH,EQ,C'B'),
BUILD=(1,80)
/* |
Gerry |
|
| Back to top |
|
 |
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2482 Location: @my desk
|
|
|
|
| scorp_rahul23 wrote: |
I want to have all records with PAYM whether they are 2 or 3. They will always be continuos.
And apart from that I need a records which is just before first PAYM record and just after last paym record. |
Hi Kolusu,
Looks like the TS needs consecutive 'PAYM' records in output even if there are more than 2. I guess it would need some tweaking in order to handle multple 'PAYM's.
Gerry's version can handle this, but at the expense of multiple passes. I tried out a version which I believe would give this in single pass. Below is the input used and expected output. Suggestions are welcome
| Code: |
//STEP0100 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD *
DATA1
DATA2
DATA3
PAYM
DATA4
DATA5
DATA6
DATA1
PAYM
PAYM
PAYM
DATA2
DATA3
DATA4
DATA5
DATA6
//OUT DD SYSOUT=*
//TOOLIN DD *
SELECT FROM(IN) TO(OUT) ON(81,8,CH) ALLDUPS USING(CTL1)
//CTL1CNTL DD *
OPTION COPY
INREC IFTHEN=(WHEN=INIT,
OVERLAY=(81:SEQNUM,8,ZD,89:SEQNUM,8,ZD,RESTART=(1,5))),
IFTHEN=(WHEN=GROUP,
BEGIN=(1,4,CH,EQ,C'PAYM',AND,89,8,ZD,EQ,1),
END=(1,4,CH,NE,C'PAYM'),
PUSH=(97:SEQ=8)),
IFTHEN=(WHEN=(97,8,CH,GT,C' '),
OVERLAY=(81:81,8,ZD,SUB,97,8,ZD,M11,LENGTH=8))
OUTFIL FNAMES=OUT,BUILD=(1,80) |
Output
| Code: |
DATA3
PAYM
DATA4
DATA1
PAYM
PAYM
PAYM
DATA2 |
|
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
The thing about the actual solution is the record-length that the TS has, 32,000+. Since an entire record from before (and after) the current one is needed, that lets out the JOINKEYS and PUSH solutions for the actual question.
I think I'll try to "tidy" the topic, split it into the TS's two different questions and give it a less "interesting" subject :-) |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
With records up to half the maximum length, Kolusu's JOINKEYS gets the current and preceding records "side-by-side" on the REFORMAT record, so selection of required records is "easy" (first part of REFORMAT if "record" and "paym" or "paym" and "paym", second part of REFORMAT is "paym" and "record").
Here is an alternative, only possible if records are <= 1/3 of the maximum length.
I don't know if the multiple PUSHs outperform the JOINKEYS or not, but somewhere I have a better way to test for odd/even using bit masks (a suggestion of Frank Yaeger's that I came across).
The topic linked-to here, also has a JOINKEYS example.
For the actual question (with the big records) the inclusion of the END works well, Arun. I thing the eight digits for that sequence number are "excessive"... and I've never liked GT space when NE space is fine :-) |
|
| Back to top |
|
 |
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2482 Location: @my desk
|
|
|
|
| Bill Woodger wrote: |
| With records up to half the maximum length, Kolusu's JOINKEYS gets the current and preceding records "side-by-side" on the REFORMAT record, so selection of required records is "easy" |
Hi Bill,
I could not see a JOINKEYS solution by Kolusu here. Moreover the output from his job would be different from mine/Gerry's.  |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
Arun we are trying to wake a dead horse. we can take the discussion offline if you are interested. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|