Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
What is the purpose of the compare? What do you want to do if you find the transaction key on the master, what if there is no transaction for a master, and what if there is no master for the transaction?
Can the two transaction files be combined into a single combined transaction file?
Here is some simple compare pseudo logic making these assumptions. 1 ? the two transaction files have been combined into a single sorted transaction file the same as the master file, ascending 2 ? nothing will be done if there is no transaction for a master, 3 ? the master will be updated with the transaction data if the keys are equal. 4 ? There can be more than one transaction for each master 5 ? error reporting if there is no master file for the transaction.
I'll assume you want to do something when the keys of the 3 files are equal. I won't write the code for you - takes too much of my time (and why should I have all the fun? ), but I will give you some insights.
Sort all 3 files on the same key.
Then, in your COBOL pgm, do a first read on all 3 files. Then in a loop to EOF on all 3 files you:
determine the hi-key.
test each file's key against that
when less than, read a rec for that file
when greater than or equal, do nothing
also test if all 3 keys are equal (not sure where this goes)
if equal do your thing then read all 3 files
Well, that's the basis of it, but as they say, the devil's in the details.
You're best doing READ INTO and setting the key to hi-vals at EOF for each file and don't forget to by-pass the read if the file is already at EOF.
The logic I provided should make this unneccessary, but if you have to change it, keep the point in mind.
My program has to read three ADABAS files and to create three output files for next days trade calculation , i was sure about comparing two sorted files and creating one out file after editing . PSB the code for the same.
034400 PERFORM S300-FD.
034500 IF END-FLG2 = 'E'
034600 MOVE SPACE TO END-FLG2
034700 GO TO MAIN-030
034900 GO TO MAIN-020.
035200 PERFORM S400-LK.
035300 PERFORM S410-SR.
035400 PERFORM S500-LK.
035500 PERFORM S510-SR.
035600 PERFORM S800-LK. T2KS0010
035700 PERFORM S810-SR. T2KS0010
036000 IF KEY-1 NOT = KEY-2
036100 GO TO MAIN-050.
036200 IF KEY-2 NOT = KEY-3 T2KS0010
036300 GO TO MAIN-045. T2KS0010
036400 IF KEY-1 = HIGH-VALUE
036500 GO TO MAIN-010.
036600*** PERFORM S520-EDIT. T2KS0010
036700 MOVE ADA-DATA4 TO WK-DATA. T2KS0010
036800 MOVE '1' TO IX110-CH. T2KS0010
036900 MOVE WK-DATA TO ADA-DATA4. T2KS0010
037000 PERFORM S820-EDIT. T2KS0010
037100 PERFORM S510-SR.
037200 PERFORM S410-SR.
037300 PERFORM S810-SR. T2KS0010
037400 GO TO MAIN-040.
037500 MAIN-045. T2KS0010
037600 IF KEY-2 < KEY-3 T2KS0010
037700 GO TO MAIN-047. T2KS0010
037800 PERFORM S820-EDIT. T2KS0010
037900 PERFORM S810-SR. T2KS0010
038000 GO TO MAIN-040. T2KS0010
038100 MAIN-047. T2KS0010
038200 PERFORM S520-EDIT. T2KS0010
038300 PERFORM S510-SR. T2KS0010
038400 PERFORM S410-SR. T2KS0010
038500 GO TO MAIN-040. T2KS0010
038800 IF KEY-1 < KEY-2
038900 GO TO MAIN-060.
039000 IF KEY-2 > KEY-3 T2KS0010
039100 GO TO MAIN-055. T2KS0010
039200 PERFORM S520-EDIT.
039300 PERFORM S510-SR.
039400 GO TO MAIN-040.
039500 MAIN-055. T2KS0010
039600 PERFORM S820-EDIT. T2KS0010
039700 PERFORM S810-SR. T2KS0010
039800 GO TO MAIN-040. T2KS0010
040000 IF KEY-1 NOT = KEY-3 T2KS0010
040100 GO TO MAIN-065. T2KS0010
040200 MOVE ADA-DATA4 TO WK-DATA. T2KS0010
040300 IF IX110-CH = SPACE T2KS0010
040400 PERFORM S820-EDIT T2KS0010
040500 END-IF. T2KS0010
040600 PERFORM S410-SR. T2KS0010
040700 PERFORM S810-SR. T2KS0010
040800 GO TO MAIN-040. T2KS0010
040900 MAIN-065. T2KS0010
041000 IF KEY-1 > KEY-3 T2KS0010
041100 GO TO MAIN-067. T2KS0010
041200 PERFORM S420-EDIT.
041300 PERFORM S410-SR.
041400 GO TO MAIN-040.
041500 MAIN-067. T2KS0010
041600 PERFORM S820-EDIT. T2KS0010
041700 PERFORM S810-SR. T2KS0010
041800 GO TO MAIN-040. T2KS0010
042000 PERFORM S600-END.
042100 STOP RUN.
Joined: 07 Nov 2005 Posts: 1105 Location: The Netherlands at Hole 19
Here a solution which is a standard in our country. It's without goto's and the only comparison for < is to determine the smaller key. We're used to call it BALANCE_LINE. I used some pseudo-code just as an example