Summing positive and negative values

IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER
prachi249
Posts: 1
Joined: Thu Sep 04, 2008 12:27 pm
Skillset: JCL, COBOL
Referer: Friends

Summing positive and negative values

Postby prachi249 » Thu Sep 04, 2008 12:45 pm

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

User avatar
Frank Yaeger
Global moderator
Posts: 1079
Joined: Sat Jun 09, 2007 8:44 pm
Skillset: DFSORT, ICETOOL, ICEGENER
Referer: Search
Contact:

Re: Summing positive and negative values

Postby Frank Yaeger » Thu Sep 04, 2008 8:58 pm

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.

Code: Select all

//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:

Code: Select all

1000000000023 T062 0005 0000004500
1000000054012 T025 0006 00000-4420
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort


  • Similar Topics
    Replies
    Views
    Last post