Can we put some effective logic to combine the below SORT Cards to avoid redundancy and improve maintainability. May be use SYMBOLS.
The difference between the 2 SORT Cards are highlighted in RED.
SORT CARD 1: -
SORT FIELDS=(1,22,CH,A)
OMIT COND=(1,3,CH,EQ,C'999')
OUTREC FIELDS=(1:1,3,
4:4,19,
23:23,3,
26:48,19,
45:109,3,
48:115,3,
51:118,19,
70:137,1,
.
.
.
1501:C'22')
There are around 1000 such fields mentioned in the OUTREC and in the end we append 22.
SORT CARD 2: -
SORT FIELDS=(1,22,CH,A)
OMIT COND=(1,3,CH,EQ,C'000',OR,1,3,CH,EQ,C'999')OUTREC FIELDS=(1:1,3,
4:4,19,
23:23,3,
26:48,19,
45:109,3,
48:115,3,
51:118,19,
70:137,1,
.
.
.
.
.
.
1501:C'11')
There are around 1000 such fields mentioned in the OUTREC (which is exactly same as that of SORT CARD 1) and in the end we append 11.
Dont you see both the cards performs different functions and even if you wanted to build them dynamically each time you need to understand that even to make use of symbols you need a code to generate each time
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
Possibly, you can use SYMNAMES but 1000 conditions sound little too much. If that many sub-combinations from input are needed, why not try to write the input file in required order at first place.
On the assumption that all the rearrangement is making the record smaller, do the new record on INREC, so less data goes into the SORT, so the sort will be faster.
Drop all the columns, which will vastly improve maintainability. As arranged above, all the data fields follow on one from anoher, which is, from what you showed, what was happening by you meticulously specifying the columns.
Definitely symbols/SYMNAMES. You can define a constant for the value you suffix to each record, have a PDS/PDSE member for the "record layout" and concatenate a different member for "constants" for each file. You could use symbols for the OMIT which would allow the identical sort card for both steps. It would be possible, assuming your DFSORT is reasonably up-to-date, to process both files at once, if you felt there was genuine benefit in that.
However, Anuj makes a good point. Why so much re-arranging of the data? If your records were created how you want, you'd not be left much to do (appending the value). If subsequent programs could be changed to use the record-layout as created, you get a similar outcome. So, why can't you do either of those?
As suggested, I have created one input file with the required data and I am just doing the comparison. So I have got rid of the redundant outrec coded in two SORT Cards.
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
OK. Thanks for letting us know. Where topics are related, it would be good to indicate. It may have saved people time and effort not to have looked at this one much.