Page 1 of 1

Summing positive and negative values

PostPosted: Thu Sep 04, 2008 12:45 pm
by prachi249
I am looking for a solution for the below sample data,

1000000000023 T062 0001 00000-4500
1000000000023 T062 0002 0000000000
1000000000023 T062 0002 0000009000

1000000054012 T025 0003 00000-3500
1000000054012 T025 0002 0000000-20
1000000054012 T025 0001 000000-900

For the above, o/p should be as below

1000000000023 T062 0005 0000004500
1000000054012 T025 0006 00000-4620

- Prachi

Re: Summing positive and negative values

PostPosted: Thu Sep 04, 2008 8:58 pm
by Frank Yaeger
It would have helped if you'd explained the "rules" for getting from input to to output instead of making us guess. But I'll give it a shot.

Assuming that the second output record should have -4420 (the correct total), not -4620 (the incorrect total), the following DFSORT job will give you the output you asked for. However, I'm not really sure what the rules are for the last field which seems to have an embedded minus sign in the middle of it. Anyway, hopefully this will give you the idea of how to do what you want to do.

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD *
1000000000023 T062 0001 00000-4500
1000000000023 T062 0002 0000000000
1000000000023 T062 0002 0000009000
1000000054012 T025 0003 00000-3500
1000000054012 T025 0002 0000000-20
1000000054012 T025 0001 000000-900
/*
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
  OPTION COPY
  OUTFIL REMOVECC,NODETAIL,
    SECTIONS=(1,13,
      TRAILER3=(1,19,
        20:TOT=(20,4,ZD,TO=ZD,LENGTH=4),
        24:24,6,
        30:TOT=(30,6,SFF,EDIT=(STTTT),SIGNS=(0,-))))
/*


SORTOUT would have:

1000000000023 T062 0005 0000004500
1000000054012 T025 0006 00000-4420