I have two input files of length (FB/54)
I need to merge these and sort them. And need to pick only the first occurrence of a record with a key combination.
for this I tried the following code and it is working fine.
//TOOLIN DD *
COPY FROM(IN1) TO(TMPIN)
COPY FROM(IN2) TO(TMPIN)
SORT FROM(TMPIN) TO(TMPOUT) USING(CTL1)
SELECT FROM(TMPOUT) TO(FNLOUT) ON(1,8,BI) ON(11,10,CH) FIRST
/*
//CTL1CNTL DD *
SORT FIELDS=(1,8,BI,A,11,10,CH,A,39,4,CH,D,33,2,CH,D,36,2,CH,D)
/*
//CTL2CNTL DD *
SORT FIELDS=COPY
/*
COPY FROM(IN1) TO(TMPIN)
COPY FROM(IN2) TO(TMPIN)
SORT FROM(TMPIN) TO(TMPOUT) USING(CTL1)
SELECT FROM(TMPOUT) TO(FNLOUT) ON(1,8,BI) ON(11,10,CH) FIRST
/*
//CTL1CNTL DD *
SORT FIELDS=(1,8,BI,A,11,10,CH,A,39,4,CH,D,33,2,CH,D,36,2,CH,D)
/*
//CTL2CNTL DD *
SORT FIELDS=COPY
/*
My question is if I have defined the two input files under the same DD name IN1.
IN1 DD DSN=FILE,DISP=SHR
DD DSN=FILE,DISP=SHR
DD DSN=FILE,DISP=SHR
and change the toolin like this, the sort function is not considering the all records from both the files and the sort order is not as expected.
//TOOLIN DD *
COPY FROM(IN) TO(TMPOUT) USING(CTL1)
SELECT FROM(TMPOUT) TO(FNLOUT) ON(1,8,BI) ON(11,10,CH) FIRST
/*
COPY FROM(IN) TO(TMPOUT) USING(CTL1)
SELECT FROM(TMPOUT) TO(FNLOUT) ON(1,8,BI) ON(11,10,CH) FIRST
/*
Why is this happening and the sort is not as expected, when the above first approach is working ?