Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Referring previous record's content

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
dudenithy

New User


Joined: 02 Mar 2012
Posts: 48
Location: India

PostPosted: Fri Jan 02, 2015 4:15 pm    Post subject: Referring previous record's content
Reply with quote

Hello all,

I have one requirement where could some one of you help me in this regard.

I have a file with card number and values as below with order sequence (card/value),
Code:
111111 123456
111111 123457
111111 999999
111111 999999
222222 999999
333333 456789
333333 999999
...

My requirement is for each card, when it has value 999999, then I should check if previous record has same card number with good value, if so, I have to take the previous value and increase it by 1 and store it current record. If the previous record doesn't have same card number, then set the current record value as 000000. Like as below,
Code:
111111 123456
111111 123457
111111 123458
111111 123459
222222 000000
333333 456789
333333 456790
...

I planned to do that via COBOL, but I feel it can done via ICETOOL / SYNCSORT. Thanks for your response.
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7241

PostPosted: Fri Jan 02, 2015 5:50 pm    Post subject: Reply to: Referring previous record's content
Reply with quote

See if your SyncSort has KEYBEGIN in WHEN=GROUP.

Where there are existing number (not nines) are they guaranteed to be correct?

Code:
111111 123456
111111 123457
111111 999999
111111 999999


So 12357 (and any like it) will always be correct?
Back to top
View user's profile Send private message
dudenithy

New User


Joined: 02 Mar 2012
Posts: 48
Location: India

PostPosted: Fri Jan 02, 2015 6:28 pm    Post subject:
Reply with quote

Hi Bill,
I will check SYNCSORT function. Yes, the numbers other than 999999 will always be correct.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7241

PostPosted: Fri Jan 02, 2015 6:42 pm    Post subject: Reply to: Referring previous record's content
Reply with quote

Use WHEN=INIT to set up a SEQNUM with a START of zero and a RESTART pointing to the key. Make it long enough to cover the maximum number you can have within a key.

Use WHEN=GROUP with BEGIN for zero in the sequence number, PUSH the key after the sequence number.

Then another WHEN=INIT which "calculates" by adding the sequence to the PUSHed value.

Finally WHEN=(logicalexpression to test for nines and set to zero (OVERLAY) if there are.

Use IFOUTLEN (fixed-length records) or BUILD (variable-length records) to get rid of the extended data.

Edited for clarity :-)
Back to top
View user's profile Send private message
mistah kurtz

Active User


Joined: 28 Jan 2012
Posts: 268
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Fri Jan 02, 2015 8:29 pm    Post subject:
Reply with quote

Assuming that the valid values (except 999999) in column 8 to 13 will always be in sequence, you can try the below job:

Code:
//STEP01   EXEC PGM=SORT                                         
//SORTIN   DD *                                                 
----+----1----+----2----+----3----+----4----+----5----+----6----+
111111 123456                                                   
111111 123457                                                   
111111 999999                                                   
111111 999999                                                   
222222 999999                                                   
333333 456789                                                   
333333 999999                                                   
//SORTOUT  DD SYSOUT=*                                           
//SYSOUT   DD SYSOUT=*                                           
//SYSIN    DD *                                                 
  OPTION COPY                                                   
  INREC  IFTHEN=(WHEN=INIT,                                     
                 OVERLAY=(21:SEQNUM,1,ZD,START=0,RESTART=(1,6))),
         IFTHEN=(WHEN=GROUP,BEGIN=(21,1,CH,EQ,C'0'),             
                            PUSH=(31:8,6))                       
  OUTREC IFOUTLEN=20,                                           
         IFTHEN=(WHEN=INIT,                                     
                 OVERLAY=(8:31,6,ZD,ADD,                         
                            21,1,ZD,EDIT=(TTTTTT))),             
         IFTHEN=(WHEN=(8,6,CH,EQ,C'999999'),                     
                 OVERLAY=(8:C'000000'))                         


Output
Code:
111111 123456
111111 123457
111111 123458
111111 123459
222222 000000
333333 456789
333333 456790
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7241

PostPosted: Fri Jan 02, 2015 8:51 pm    Post subject: Reply to: Referring previous record's content
Reply with quote

Code:
  OPTION COPY                                                   
  INREC  IFTHEN=(WHEN=INIT,                                     
                 OVERLAY=(21:SEQNUM,1,ZD,START=0,RESTART=(1,6))),
         IFTHEN=(WHEN=GROUP,BEGIN=(21,1,CH,EQ,C'0'),             
                            PUSH=(31:8,6)),                       
         IFTHEN=(WHEN=INIT,                                     
                 OVERLAY=(8:31,6,ZD,ADD,                         
                            21,1,ZD,EDIT=(TTTTTT))),             
         IFTHEN=(WHEN=(8,6,CH,EQ,C'999999'),                     
                 OVERLAY=(8:C'000000')),
         IFOUTLEN=20


A slight rearrangement. Largely to highlight that WHEN=INIT can also appear after WHEN=GROUP and to show that the location of IFOUTLEN is not significant.

For developing, it is convenient to leave "gaps" when extending records, but they should the gaps need to be removed if the data is to be sorted (not here, where it wouldn't matter much).
Back to top
View user's profile Send private message
mistah kurtz

Active User


Joined: 28 Jan 2012
Posts: 268
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Sun Jan 04, 2015 2:31 pm    Post subject:
Reply with quote

Thanks Bill.

Quote:
I planned to do that via COBOL, but I feel it can done via ICETOOL / SYNCSORT.

@dudenithy: Please note that I have tested this job in Syncsort V1.4 and not in DFSORT. But hopefully it should work in DFSORT as well.
Back to top
View user's profile Send private message
dudenithy

New User


Joined: 02 Mar 2012
Posts: 48
Location: India

PostPosted: Mon Jan 05, 2015 4:28 pm    Post subject:
Reply with quote

Hi Bill and Mistah,

I have just started analysing the options today (No access to host from home). I found the complete piece of coding here from you all. I believe completely that it willwork . Thanks a lot for your time. icon_biggrin.gif icon_biggrin.gif icon_biggrin.gif
Back to top
View user's profile Send private message
dudenithy

New User


Joined: 02 Mar 2012
Posts: 48
Location: India

PostPosted: Mon Jan 05, 2015 7:58 pm    Post subject:
Reply with quote

Hi Bill,

I just have one question. My input file is a VB file (maximum rec length, say 100 bytes). So is it good to keep the extended data at the last after the real data, or to have these extended data at the beginning of the real data? If as in above example (extended data after the real data), I'm not sure how to give the reference position. Could you kindly help ?
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7241

PostPosted: Mon Jan 05, 2015 8:20 pm    Post subject: Reply to: Referring previous record's content
Reply with quote

For a VB, you should extend at the beginning of the record.

I'd put in another INIT as the first one with BUILD=(1,4,7X,5) to make space for the extension.

Then change the first OVERLAY, 5: for the sequence number, and 6: for the key in the PUSH, and change the other locations as necessary.

To get rid of the extension, you can no longer use IFOUTLEN.

To keep it simple, because of the IFTHEN=(WHEN=logical expression), I'd use a simple OUTREC with BUILD=(1,4,12). This will ignore the 7 bytes from position five.
Back to top
View user's profile Send private message
dudenithy

New User


Joined: 02 Mar 2012
Posts: 48
Location: India

PostPosted: Mon Jan 05, 2015 9:19 pm    Post subject:
Reply with quote

Yes Bill, Even I thought that should be the easiest and simple. Thanks four confirmation.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts How to update a portion of text in a ... Bill Woodger DFSORT/ICETOOL 25 Wed Nov 09, 2016 9:41 pm
This topic is locked: you cannot edit posts or make replies. How to pass the previous month date i... Suganya87 DFSORT/ICETOOL 5 Mon Oct 31, 2016 4:13 pm
No new posts How to get previous month in SYMNAMES Suganya87 SYNCSORT 9 Fri Oct 28, 2016 1:37 pm
No new posts sort with previous record anatol DFSORT/ICETOOL 9 Thu Oct 06, 2016 2:36 am
No new posts Get Record count in summary record fo... Atul Banke DFSORT/ICETOOL 21 Fri Sep 23, 2016 4:17 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us