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
scorp_rahul23

New User


Joined: 06 May 2008
Posts: 96
Location: Delhi

PostPosted: Tue May 08, 2012 1:20 am
Reply with quote

I have one more query.

I have my input file as

Code:

----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
***************************** Top of Data ******************************
            12122                                                       
000000000000FFFFF4444444444444444444444444444444444444444444444444444444
000000000000121230000000000000000000000000000000000000000000000000000000
      â  qo"  q ¤                                                       
FFFF00430997009394444444444444444444444444444444444444444444444444444444
FFFF0F2F086F0088F0000000000000000000000000000000000000000000000000000000
            12123                                                       
000000000000FFFFF4444444444444444444444444444444444444444444444444444444
000000000000121230000000000000000000000000000000000000000000000000000000
-----------------------------------------------------------------------
PAYM  O¶    ¾     `T715014         ð                1715014     S1894628
DCED00DB0001B002007EFFFFFF01014400080000000044444444FFFFFFF00101EFFFFFFF
71840166000F9C2202937150140A0A0000AC0000000000000000171501400A0A21894628
-----------------------------------------------------------------------
      â  qo"  q ¤                                                       
FFFF00430997009394444444444444444444444444444444444444444444444444444444
FFFF0F2F086F0088F0000000000000000000000000000000000000000000000000000000
            12125                                                       
000000000000FFFFF4444444444444444444444444444444444444444444444444444444
000000000000121230000000000000000000000000000000000000000000000000000000
      â  qo"  q ¤                                                       
FFFF00430997009394444444444444444444444444444444444444444444444444444444
FFFF0F2F086F0088F0000000000000000000000000000000000000000000000000000000


And I need to my output file as below.

Code:

            12123                                                       
000000000000FFFFF4444444444444444444444444444444444444444444444444444444
000000000000121230000000000000000000000000000000000000000000000000000000
-----------------------------------------------------------------------
PAYM  O¶    ¾     `T715014         ð                1715014     S1894628
DCED00DB0001B002007EFFFFFF01014400080000000044444444FFFFFFF00101EFFFFFFF
71840166000F9C2202937150140A0A0000AC0000000000000000171501400A0A21894628
-----------------------------------------------------------------------
      â  qo"  q ¤                                                       
FFFF00430997009394444444444444444444444444444444444444444444444444444444
FFFF0F2F086F0088F0000000000000000000000000000000000000000000000000000000


Logic behind this output file is I want the record which is above the PAYM recd and below the PAYM record.

In Input file it can have more than one PAYM record like



Code:

----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
***************************** Top of Data ******************************
            12122                                                       
000000000000FFFFF4444444444444444444444444444444444444444444444444444444
000000000000121230000000000000000000000000000000000000000000000000000000
      â  qo"  q ¤                                                       
FFFF00430997009394444444444444444444444444444444444444444444444444444444
FFFF0F2F086F0088F0000000000000000000000000000000000000000000000000000000
            12123                                                       
000000000000FFFFF4444444444444444444444444444444444444444444444444444444
000000000000121230000000000000000000000000000000000000000000000000000000
-----------------------------------------------------------------------
PAYM  O¶    ¾     `T715014         ð                1715014     S1894628
DCED00DB0001B002007EFFFFFF01014400080000000044444444FFFFFFF00101EFFFFFFF
71840166000F9C2202937150140A0A0000AC0000000000000000171501400A0A21894628
PAYM2  O¶    ¾     `T715014         ð                1715014     S1894628
DCED00DB0001B002007EFFFFFF01014400080000000044444444FFFFFFF00101EFFFFFFF
71840166000F9C2202937150140A0A0000AC0000000000000000171501400A0A21894628
-----------------------------------------------------------------------
      â  qo"  q ¤                                                       
FFFF00430997009394444444444444444444444444444444444444444444444444444444
FFFF0F2F086F0088F0000000000000000000000000000000000000000000000000000000
            12125                                                       
000000000000FFFFF4444444444444444444444444444444444444444444444444444444
000000000000121230000000000000000000000000000000000000000000000000000000
      â  qo"  q ¤                                                       
FFFF00430997009394444444444444444444444444444444444444444444444444444444
FFFF0F2F086F0088F0000000000000000000000000000000000000000000000000000000



Any suggestions whether this can be implemented in sort ..

thanks in advance
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Tue May 08, 2012 1:57 am
Reply with quote

Quote:
In Input file it can have more than one PAYM record like


And what do you want for output in that case?

You need to explain more clearly what you want to do before we can help.

Please explain the "rules" you want to use for all possible situations (one PAYM record, two PAYM records, etc). Also, give the RECFM and LRECL of the input file and any other relevant information.
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 08, 2012 8:07 am
Reply with quote

In output file I want the record which is just above the first PAYM record , all PAYM records and Record which is just after last PAYM records.

RECFM=FB. LRECL=32500
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Tue May 08, 2012 10:55 pm
Reply with quote

Clear as mud.

It's not clear if the PAYM records are always sequential (e.g. data records, 5 PAYM records, data records) or can be spread throughout the file (e.g. data records, PAYM record, data records, PAYM record, etc)?

Since you are having trouble describing what you want, you'll need to show examples (for any and all possible cases).
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19245
Location: Inside the Matrix

PostPosted: Tue May 08, 2012 11:26 pm
Reply with quote

Hello,

With this data:

Data1
Data2
Data3
PAYM
Data4
PAYM
PAYM
Data5
PAYM
Data6
Data7
Data8

i believe the desired output is:
Data3
PAYM
Data4
PAYM
PAYM
Data5
PAYM
Data6
Back to top
View user's profile Send private message
scorp_rahul23

New User


Joined: 06 May 2008
Posts: 96
Location: Delhi

PostPosted: Wed May 09, 2012 12:01 am
Reply with quote

Input file will be a little different it can be like this.

Data1
Data2
Data3
PAYM
Data4
Data5
Data6


Data1
PAYM
PAYM
Data2
Data3
Data4
Data5
Data6


Its like payment record will be together only and in a single bunch
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19245
Location: Inside the Matrix

PostPosted: Wed May 09, 2012 12:14 am
Reply with quote

Hello,

In your example, what should be the output?

The Data(n's) appear to repeat. . . icon_confused.gif

Your rule says:
Quote:
I want the record which is just above the first PAYM record , all PAYM records and Record which is just after last PAYM records
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


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

PostPosted: Wed May 09, 2012 12:19 am
Reply with quote

It looks like Batch Header (binary zeros), data, Batch Trailer (hex FFs).

Is there other data in some batches. so what you want is all the batches with PAYMs and which can only contain PAYMs, not be mixed with other data?
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Wed May 09, 2012 12:24 am
Reply with quote

scorp_rahul23 wrote:
Input file will be a little different it can be like this.

Data1
Data2
Data3
PAYM
Data4
Data5
Data6


Data1
PAYM
PAYM
Data2
Data3
Data4
Data5
Data6


Its like payment record will be together only and in a single bunch


and the expected output from this is ??????
Back to top
View user's profile Send private message
scorp_rahul23

New User


Joined: 06 May 2008
Posts: 96
Location: Delhi

PostPosted: Wed May 09, 2012 1:56 am
Reply with quote

Quote:

Data1
Data2
Data3
PAYM
Data4
Data5
Data6


Data1
PAYM
PAYM
Data2
Data3
Data4
Data5
Data6


Its like payment record will be together only and in a single bunch


Output will be


Data3
PAYM
Data4



Data1
PAYM
PAYM
Data2
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19245
Location: Inside the Matrix

PostPosted: Wed May 09, 2012 2:02 am
Reply with quote

Hello,

You still have not provided what is needed. . .

How does one know when one "group" ends and the next begins. . . icon_confused.gif

You need to post (in English sentences) the rules for the process to follow. . .
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Wed May 09, 2012 3:11 am
Reply with quote

I believe those are two separate sets of input records - right? It appears that the PAYM records will only appear at one point in the input file, but there could be more than one PAYM record at that point and they will be consecutive. 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.

Is that correct?
Back to top
View user's profile Send private message
scorp_rahul23

New User


Joined: 06 May 2008
Posts: 96
Location: Delhi

PostPosted: Wed May 09, 2012 9:01 am
Reply with quote

Yes Frank you are right
Back to top
View user's profile Send private message
Skolusu

Senior Member


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

PostPosted: Wed May 09, 2012 9:37 pm
Reply with quote

scorp_rahul23 wrote:
Yes Frank you are right


How do you explain
Code:

Data1
Data2
Data3
PAYM
Data4
Data5
Data6
Data1
PAYM
PAYM
Data2
Data3
Data4
Data5
Data6



Output will be

Code:

Data3
PAYM
Data4  <<< how did this get in the output which is after PAYM?

Data1
PAYM
PAYM
Data2



Assuming that data4 record is a typo , the following DFSORT/ICETOOL JCL will give you 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,X,       
                SEQNUM,8,ZD,RESTART=(1,4))),                 
  IFTHEN=(WHEN=(1,4,CH,EQ,C'PAYM',AND,32510,8,ZD,EQ,1),       
  OVERLAY=(32501:+1,SUB,32501,8,ZD,M11,LENGTH=8)),           
  IFTHEN=(WHEN=(1,4,CH,EQ,C'PAYM',AND,32510,8,ZD,EQ,2),       
  OVERLAY=(32501:+1,ADD,32501,8,ZD,M11,LENGTH=8))             
                                                             
  OUTFIL BUILD=(1,32500)                                     
//*


The output from the above is
Code:

Data3   
PAYM     
Data1   
PAYM     
PAYM     
Data2   
Back to top
View user's profile Send private message
scorp_rahul23

New User


Joined: 06 May 2008
Posts: 96
Location: Delhi

PostPosted: Sat May 12, 2012 2:11 am
Reply with quote

Thanks a lot it worked . U are too good
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 10:44 am
Reply with quote

If my data is like

Data1
Data2
Data3
PAYM
Data4
Data5
Data6


I need output like

Data3
PAYM
Data4


But the code is not giving me desired output. Any sugeestions why its not working
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


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

PostPosted: Tue May 22, 2012 11:17 am
Reply with quote

Suggest you post the sort cards, sysout and what is being produced.
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:41 am
Reply with quote

Code:

//STEP0100 EXEC PGM=ICETOOL                                   
//TOOLMSG  DD SYSOUT=*                                       
//DFSMSG   DD SYSOUT=*                                       
//IN       DD *                                               
Data1                                                         
Data2                                                         
Data3                                                         
PAYM                                                         
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,X,       
                SEQNUM,8,ZD,RESTART=(1,4))),                 
  IFTHEN=(WHEN=(1,4,CH,EQ,C'PAYM',AND,32510,8,ZD,EQ,1),       
  OVERLAY=(32501:+1,SUB,32501,8,ZD,M11,LENGTH=8)),           
  IFTHEN=(WHEN=(1,4,CH,EQ,C'PAYM',AND,32510,8,ZD,EQ,2),       
  OVERLAY=(32501:+1,ADD,32501,8,ZD,M11,LENGTH=8))             
                                                             
  OUTFIL BUILD=(1,32500)                                     
//*



Output was

Data3
PAYM
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


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

PostPosted: Tue May 22, 2012 11:59 am
Reply with quote

You missed commenting on what Kolusu said here.


Skolusu wrote:
scorp_rahul23 wrote:
Yes Frank you are right


How do you explain
Code:

Data1
Data2
Data3
PAYM
Data4
Data5
Data6
Data1
PAYM
PAYM
Data2
Data3
Data4
Data5
Data6



Output will be

Code:

Data3
PAYM
Data4  <<< how did this get in the output which is after PAYM?

Data1
PAYM
PAYM
Data2



Assuming that data4 record is a typo , the following DFSORT/ICETOOL JCL will give you the desired results.

[...]
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 4:46 pm
Reply with quote

I missed that out, but as per the my output file requirement its not a typo.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7310
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: 7310
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
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 Add column to existing records using ... JCL & VSAM 2
No new posts Reading subsequent rows in a query. DB2 12
No new posts Syncsort- Merging two records into on... SYNCSORT 3
No new posts How to find orphaned MCDS D records. JCL & VSAM 15
No new posts Selecting multiple constant records DB2 3
Search our Forums:

Back to Top