My input file contains records having account number, time stamp, amount, an indicator etc. This file is probably taken from excel and sent to mainframe. Hence it has comma separated values. Along with it, the date value varies in different formats like M/D/YYYY or MM/D/YYYY or M/DD/YYYY or MM/DD/YYYY. Amount is having decimal point in it.
Primary Key - 1 -9 bytes, Secondary Key - 11-20 , Date - 22 -41, Indicator - 43-47,Amount - variable length upto 15 digits including decimal,Name - 50 characters
1 2 3 4 5 6
123456789012345678901234567890123456789012345678901234567890
987654321,1000023457,8/27/2021 12:00:00 AM,False,10.01,NAME1
987654321,1000023456,8/2/2021 12:00:00 AM,False,10.02,NAME2
987654320,1000023455,10/27/202112:00:00 AM,True ,20.01,NAME3
987654320,1000023454,8/27/2021 12:00:00 AM,False,20.02,NAME4
987654320,1000023453,8/27/2021 12:00:00 AM,False,20.03,NAME5
Desired output is -
987654321$$$$1000023457100108272021 NAME1 -> when 'False' indicator, one character after date and before Name field is blank.
987654321$$$$1000023456100208022021 NAME2
T987654321$$$$$$$000000002$$$$$$$$000000002003 -> Trailer record for same Primary key and space value for indicator - starting with 'T',Primary Key,spaces,number of records,spaces,sum of amount
987654320$$$$1000023454200208272021 NAME4
987654320$$$$1000023453200308272021 NAME5
T987654320$$$$$$$000000002$$$$$$$$000000004005 -> Trailer record for same Primary key and space value for indicator - starting with 'T',Primary Key,spaces,number of records,spaces,sum of amount
987654320$$$$1000023455200110272021VNAME3 -> when 'True ' indicator, one character after date and before Name field is 'V'.
T987654320$$$$$$$000000001$$$$$$$$000000002003V -> Trailer record for same Primary key and 'V' value for indicator - starting with 'T',Primary Key,spaces,number of records,spaces,sum of amount,indiactor 'V'
Value of key field is not known, neither how many different types of keys (and their records) would present on the file. But in output, all records of same primary key with False indicator grouped together followed by Trailer record for them and all records of same primary key with True indicator grouped together with separate Trailer record for them.
I am able to add trailer record (with indicator value True and False) in one file for one primary key. But cannot find solution for multiple primary keys. Also, date formatting is done based on different types of date format and hence change of '/' position but it required multiple (27 IFTHEN conditions). Is there simple way to reformat different date formats to one standard date format?
Please advise.
SORT to add trailer record on change of key + Date
-
- Posts: 1
- Joined: Fri Aug 27, 2021 8:15 pm
- Skillset: COBOL, JCL
- Referer: Internet
- 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 to add trailer record on change of key + Date
Lesson #1: this type of data is known as CSV (Comma Separated Values)
Lesson #2: learn about PARSE parameters of SORT control statements
Lesson #3: learn about WHEN=GROUP parameters of SORT control statements
Lesson #4: learn to resolve the issues one by one, not all the problems together
Lesson #2: learn about PARSE parameters of SORT control statements
Lesson #3: learn about WHEN=GROUP parameters of SORT control statements
Lesson #4: learn to resolve the issues one by one, not all the problems together
Javas and Pythons come and go, but JCL and SORT stay forever.
-
- Similar Topics
- Replies
- Views
- Last post
-
- 1
- 1932
-
by NicC
View the latest post
Sun Sep 06, 2020 5:10 pm
-
- 2
- 1386
-
by PRDVCF
View the latest post
Thu Nov 17, 2022 9:58 pm
-
-
Copy partial record after a string in a record using SORT.
by Esmayeelhusen » Thu May 04, 2023 3:03 pm » in DFSORT/ICETOOL/ICEGENER - 16
- 4121
-
by Esmayeelhusen
View the latest post
Mon May 22, 2023 3:50 pm
-
-
-
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
-
-
- 24
- 4350
-
by Pedro
View the latest post
Wed Jan 04, 2023 5:59 am