Hi Team,
I have an FB file as below, consisting of 5 fields - A,B,C,D(YEARMM),E(Amount), delimited by pipe symbol
I need to sum-up amounts and count no of records, for all matching A,B,C,D(YEARMM) and write to a new file having fields- A,B,C,D(YEARMM), accumulated/summarized AMOUNT and no of records having same A,B,C,D.
I/P:
----+----1----+----2----+----3----+----4----+----5----+----
C1AW|1013300 |16L00000 |202201|0001
C1AW|1013300 |16L00000 |202202|0001
C1AW|1013300 |16L00000 |202202|0001
C1AW|1020000 |16L21000 |202112|0001
C1AW|1020000 |16000000 |202103|0001
C1AW|1020000 |16000000 |202103|0002
C1AW|1020000 |16000000 |202106|0001
O/P Expected:
-----------------
C1AW|1013300 |16L00000 |202201|0001|1
C1AW|1013300 |16L00000 |202202|0002|2
C1AW|1020000 |16L21000 |202112|0001|1
C1AW|1020000 |16000000 |202103|0003|2
C1AW|1020000 |16000000 |202106|0001| 1
I can sum-up amounts based on column:A,B,C,D using SUM FIELDS=NONE and use M10 function to count records, having individual steps. But again, i need to merge these individual steps which is inefficient.
Hence i would need your help, can this be done in single step - both summing up and writing count of records based on matched key.
Kindly help.
Thanks a lot,
Naveen S
SORT - SUM and count of records by key
-
- Posts: 21
- Joined: Mon Nov 23, 2009 10:59 am
- Skillset: cobol/jcl/db2/expeditor/spufi
- Referer: Internet and google search
- sergeyken
- Posts: 458
- Joined: Wed Jul 24, 2019 10:12 pm
- Skillset: Assembler, JCL, Utilities, PL/I, C/C++, DB2, SQL, REXX, COBOL, etc. etc. etc.
- Referer: Internet search
Re: SORT - SUM and count of records by key
0. Please, learn how to use the Code button to format your code properly
1. Please understand that you cannot do your job using JCL. You need to use any SORT utility
2. Please read the Dividing a Report into Sections part of SYNCSORT manual (Page 3.42). Then, try to use this new information in your task.
3. Finally, present you results at this forum, if you still have extra questions.
1. Please understand that you cannot do your job using JCL. You need to use any SORT utility
2. Please read the Dividing a Report into Sections part of SYNCSORT manual (Page 3.42). Then, try to use this new information in your task.
3. Finally, present you results at this forum, if you still have extra questions.
Javas and Pythons come and go, but JCL and SORT stay forever.
- sergeyken
- Posts: 458
- Joined: Wed Jul 24, 2019 10:12 pm
- Skillset: Assembler, JCL, Utilities, PL/I, C/C++, DB2, SQL, REXX, COBOL, etc. etc. etc.
- Referer: Internet search
Re: SORT - SUM and count of records by key
2.1. In case you are using DFSORT utility, please read SECTIONS part of the manual (Page 339).
Javas and Pythons come and go, but JCL and SORT stay forever.
-
- Posts: 21
- Joined: Mon Nov 23, 2009 10:59 am
- Skillset: cobol/jcl/db2/expeditor/spufi
- Referer: Internet and google search
Re: SORT - SUM and count of records by key
Sorry, I have logged in to the forum after a long time. I have just realized I should have posted this in DFSORT group. Thank you.
-
- Similar Topics
- Replies
- Views
- Last post
-
-
SUM and count of records by key, using SORT utility
by naveenkumar sudha » Mon May 09, 2022 10:11 pm » in DFSORT/ICETOOL/ICEGENER - 2
- 6524
-
by ssbylzh
View the latest post
Sat May 21, 2022 5:10 pm
-
-
-
SORT the records based on the second word
by seethahexa » Wed Aug 19, 2020 1:30 pm » in DFSORT/ICETOOL/ICEGENER - 1
- 1394
-
by sergeyken
View the latest post
Wed Aug 19, 2020 6:08 pm
-
-
-
Split file, SORT then append records.
by Esmayeelhusen » Fri Aug 04, 2023 6:37 pm » in DFSORT/ICETOOL/ICEGENER - 10
- 5056
-
by Esmayeelhusen
View the latest post
Wed Aug 09, 2023 7:39 am
-
-
-
COBOL SORT - How to sort entire file first & sort by Key
by k_ekam » Thu Dec 01, 2022 12:58 pm » in IBM Cobol - 3
- 1531
-
by Robert Sample
View the latest post
Wed Dec 07, 2022 7:32 am
-
-
-
Insert records from File1 between records of File2
by Daouchiche » Wed Nov 10, 2021 6:37 am » in DFSORT/ICETOOL/ICEGENER - 6
- 2327
-
by sergeyken
View the latest post
Thu Nov 11, 2021 12:43 am
-