convert cobol logic to joinkey sort.



Support for NetApp SyncSort for z/OS, Visual SyncSort, SYNCINIT, SYNCLIST and SYNCTOOL

convert cobol logic to joinkey sort.

Postby arpitpatel01 » Wed Mar 25, 2015 9:42 am

I have to convert below cobol code logic to sort. Kindly help

IF WS-PREV-KEY   = WS-CURR-KEY
   IF I-PREV-SEG = I-CURR-SEG 
       PERFORM 2100-READ-PREV
       PERFORM 2100-READ-CURR
   ELSE                               
   MOVE I-CURR-REC(1:10) TO WS-OUTA
   PERFORM 2300-WRITE-DELTA
   PERFORM 2100-READ-PREV 
   PERFORM 2100-READ-CURR 
ELSE                                   
   IF WS-PREV-KEY  <  WS-CURR-KEY     
      MOVE I-PREV-REC(1:10) TO WS-OUTA
      PERFORM 2300-WRITE-DELTA
      PERFORM 2100-READ-PREV 
   ELSE
      MOVE I-CURR-REC(1:10) TO WS-OUTA
      PERFORM 2300-WRITE-DELTA
      PERFORM 2100-READ-CURR 
   END-IF
END-IF.

FYI:
01  I-PREV-REC.                               
    05  I-PREV-KEY                 PIC X(10).
    05  I-PREV-DUMMY-KEY     PIC X(03).
    05  I-PREV-SEG-KEY          PIC X(09).
    05  I-PREV-SEG                 PIC X(067).

01  I-CURR-REC.                               
    05  I-CURR-KEY                 PIC X(10).
    05  I-CURR-DUMMY-KEY     PIC X(03).
    05  I-CURR-SEG-KEY          PIC X(09).
    05  I-CURR-SEG                 PIC X(067).


Coded'd
arpitpatel01
 
Posts: 15
Joined: Wed Mar 25, 2015 9:32 am
Has thanked: 0 time
Been thanked: 0 time

Re: convert cobol logic to joinkey sort.

 

Re: convert cobol logic to joinkey sort.

Postby BillyBoyo » Wed Mar 25, 2015 1:24 pm

Where are you having a problem? You read the documentation for JOINKEYS and experiment. Look for examples. Read. Experiment.

If you get to something you can't understand, show us what you have, and what you've done.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: convert cobol logic to joinkey sort.

Postby arpitpatel01 » Wed Mar 25, 2015 2:50 pm

@ BillyBoyo: If first IF clause fails, then how the condtion in the ELSE clause (IF WS-PREV-KEY < WS-CURR-KEY ) be handled thru sort?
arpitpatel01
 
Posts: 15
Joined: Wed Mar 25, 2015 9:32 am
Has thanked: 0 time
Been thanked: 0 time

Re: convert cobol logic to joinkey sort.

Postby arpitpatel01 » Wed Mar 25, 2015 2:50 pm

If first IF clause fails, then how the condtion in the ELSE clause (IF WS-PREV-KEY < WS-CURR-KEY ) be handled thru sort?
arpitpatel01
 
Posts: 15
Joined: Wed Mar 25, 2015 9:32 am
Has thanked: 0 time
Been thanked: 0 time

Re: convert cobol logic to joinkey sort.

Postby BillyBoyo » Wed Mar 25, 2015 3:45 pm

Differently. You never see those IFs, just the results:

 JOIN UNMATCHED,F1,F2


That gives you matched records, and unmatched F1 and unmatched F2.

Then you need some OUTFILs with INCLUDE=/OMIT= which do the comparison work.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: convert cobol logic to joinkey sort.

Postby arpitpatel01 » Wed Mar 25, 2015 6:05 pm

Input 1:
1234567890ABC
5678971554FYU

Input 2:
123456789OMG
849798979HOL

OUTPUT
1234567890ABC1234567890OMG
5678971554FYU
849798979HOL


For this output how will i compare (1,10) of 2nd record with (11,10) of 3rd record thru sort???? is it possible?

Kindly refer to the query again!
arpitpatel01
 
Posts: 15
Joined: Wed Mar 25, 2015 9:32 am
Has thanked: 0 time
Been thanked: 0 time

Re: convert cobol logic to joinkey sort.

Postby BillyBoyo » Wed Mar 25, 2015 7:11 pm

Find an example, preferably with the JOIN statement I showed previously.

You seem to want one OUTFIL only. So you'll need an INCLUDE=/OMIT= which covers your requirements. OMIT=(prevseg,EQ,currseg) would seem to do you. Then you just need to BUILD the key, and you have one IFTHEN=(WHEN=(logical expression) to BUILD from a different source position when you have the unmatched F2 (all the F1 data on the REFORMAT statement will be blank).
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times


Return to Syncsort/Synctool

 


  • Related topics
    Replies
    Views
    Last post