I should get the below result in output file (total of all credit records and debit records in the input file)
300 700
this I can acquire by the below sortcards and splice
sort exec pgm=icetool
toolin dd dsn=&splicecardlib,disp=shr
sortin dd dsn=&input file,disp=shr
temp dd dsn=&&tmpfile,disp=(mod,pass),
unit=sysda,space=(trk,(20,20),rlse)
sortout dd dsn=&outfile,
ctl1cntl dd dsn=&cardlib1,disp=shr
ctl2cntl dd dsn=&cardlib2,disp=shr
CARDLIB1:
INCLUDE COND=(1,01,CH,EQ,C'C')
SORT FIELDS=(1,01,CH,A)
SUM FIELDS=(2,3,ZD)
OUTREC BUILD=(1:2,3,ZD,TO=ZD,LENGTH=5,
6:99X,
100:C'1')
CARDLIB2:
INCLUDE COND=(1,01,CH,EQ,C'D')
SORT FIELDS=(1,01,CH,A)
SUM FIELDS=(2,3,ZD)
OUTREC BUILD=(1:2,3,ZD,TO=ZD,LENGTH=5,
6:99X,
100:C'1')
splice cardlib:
sort from(input) to (temp) using ctl1
sort from(input) to (temp) using ctl2
splice from(temp) -
to (output) -
on(100,1,zd) -
with(1,3)
But the same logic is not working if the input file has same set of records(either debit or credit) the output file is empty for the above condition.
the temp file is only has 1 record for one set of records (either credit or debit) It's not finding the other record to compare with the unique indicator in 100th position and write it to outfile as one record.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
It's not clear what you're trying to do. Showing us what you did that didn't work without explaining what you're trying to do makes it difficult to help you.
Please start over and show examples of the input records and expected output for various cases (including the one that doesn't work with your job). Explain the "rules" for getting from input to output. Give the RECFM and LRECL of the input file. Give the starting position, length and format of each relevant field.
i am having the input file with credit/debit indicator and amount.
LRECL is 80
file layout is given below
01 C/D indicator pic x(01)
01 Amount pic s9(3)v99
Now whatever i have explained above is working fine,if the input file is having both credit and debit records.
If the input file is having only credit or only debit records(one sided records),The amount is summing up for either credit or debit.But the other amount is getting displayed as spaces.
for example
If input file contains
C 100
C 200
The output file is getting only
300 spaces(DB amount)
as per the above code but i should not get these spaces. instead of these spaces i should move 000 amount to the db amount if no debit records found in the input file viceversa for credit amount also.