IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Group with previous and subsequent records


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue May 22, 2012 6:33 pm
Reply with quote

Kolusu showed you the output from the given input, and it has your exact example.

You are saying, when there is one PAYM you want the record in front, the PAYM, and the record after. When there are two PAYM you want the record in front of the first, the two PAYM and the one after the second?

Can there be more than two PAYM, so we again try to get the whole thing at once?
Back to top
View user's profile Send private message
scorp_rahul23

New User


Joined: 06 May 2008
Posts: 96
Location: Delhi

PostPosted: Tue May 22, 2012 11:50 pm
Reply with quote

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.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Fri Jun 07, 2013 2:49 pm
Reply with quote

Frank Yaeger wrote:
So for the one, two, three, etc PAYM records, you want the record before the first PAYM record and the record after the last PAYM record.
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.
I was just going through some of the older topics here, the TS said that he needs the record following the last 'PAYM' record also, pretty much same as what Frank had asked earlier. Do we have a solution yet for this?

Sorry for bringing up an year-old topic. icon_redface.gif
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Jun 07, 2013 5:30 pm
Reply with quote

This one suits the subject, I haven't gone through the topic :-)

The 83,1,ZD,EQ,1 (which is looking at the match marker) identifies the last record.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Fri Jun 07, 2013 5:46 pm
Reply with quote

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 icon_smile.gif

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! icon_eek.gif
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Fri Jun 07, 2013 9:33 pm
Reply with quote

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 icon_smile.gif

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! icon_eek.gif



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
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Sat Jun 08, 2013 10:29 am
Reply with quote

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
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Sat Jun 08, 2013 3:26 pm
Reply with quote

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 icon_smile.gif
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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Sat Jun 08, 2013 3:54 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Jun 11, 2013 4:26 am
Reply with quote

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
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Tue Jun 11, 2013 5:40 pm
Reply with quote

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. icon_confused.gif
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Wed Jun 12, 2013 1:45 am
Reply with quote

Arun we are trying to wake a dead horse. icon_smile.gif we can take the discussion offline if you are interested.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL Goto page 1, 2  Next

 


Similar Topics
Topic Forum Replies
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Join multiple records using splice DFSORT/ICETOOL 5
No new posts EZT program to build a flat file with... All Other Mainframe Topics 9
No new posts JCL sortcard to print only the records DFSORT/ICETOOL 11
Search our Forums:

Back to Top