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

Referring previous record's content


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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

Moderator Emeritus


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

PostPosted: Fri Jan 02, 2015 5:50 pm
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
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

Moderator Emeritus


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

PostPosted: Fri Jan 02, 2015 6:42 pm
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: 316
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Fri Jan 02, 2015 8:29 pm
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

Moderator Emeritus


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

PostPosted: Fri Jan 02, 2015 8:51 pm
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: 316
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Sun Jan 04, 2015 2:31 pm
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
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
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

Moderator Emeritus


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

PostPosted: Mon Jan 05, 2015 8:20 pm
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts To find whether record count are true... DFSORT/ICETOOL 6
No new posts Validating record count of a file is ... DFSORT/ICETOOL 13
Search our Forums:

Back to Top