Quantcast
Channel: COBOL How can I sort and merge two unordered files? - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Answer by NealB for COBOL How can I sort and merge two unordered files?

$
0
0

Check out this link. It gives several examples illustrating how to use the COBOL sort verb. This link should give you plenty of hints. As for testing date ranges, consider doing it within the INPUT PROCEDURE. See the MaleSort.cbl example from the link where records are included/excluded based on having a specific gender code.

Adding 6 months to a date can be a bit of a trick. There are a number of intrinsic date manipulation functions in COBOL but using them may be a bit beyond where you are at right now, but have a look at: date-of-integer and integer-of-date and maybe dateval. On the other hand, you might find it just a easy to do the arithmetic yourself.

If you choose to do your own date math, try something along the lines of:

             ADD 6 TO RUN-MONTH             DIVIDE RUN-MONTH BY 12                  GIVING WS-YEAR-ROLLOVER                 REMAINDER IN RUN-MONTH             END-DIVIDE             COMPUTE RUN-YEAR = RUN-YEAR + WS-YEAR-ROLLOVER

Since your RUN-YEAR is only 2 digits long, you might have to deal with century rollover if WS-DATE is prior to year 2000 (I can't believe that anybody would still be using 2 digit dates in this day and age). Another thing to watch out for are the number of days - August 31 plus 6 months gets you to... February which only has 28 or 29 days.

Have fun.


Viewing all articles
Browse latest Browse all 2

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>