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
Summing positive and negative values
- 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
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.
SORTOUT would have:
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
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
-
- 2
- 1581
-
by sergeyken
View the latest post
Sun Jan 26, 2025 3:07 am
-
-
Moving High-Values from Comp-3 - COBOL Ver 6.4
by girik1001 » Thu Jul 20, 2023 12:08 pm » in IBM Cobol - 1
- 3923
-
by sergeyken
View the latest post
Thu Jul 20, 2023 6:38 pm
-