I have a dataset a gdg version which looks like below, I have date in position 67 to 75 in format 10-MAR-24 and it changes every day accordingly.
file:
Code:
Command ===> Scroll ===> CSR
=COLS> --3----+----4----+----5----+----6----+----7----+----8----+----9----+----
****** ***************************** Top of Data ******************************
000001 14-NOV-23 10-MAR-24 09-MAR-24 8-1-6 T 24
****** **************************** Bottom of Data ****************************
My requirement is i need to convert this date in postion 65 to 75 below format:
2024-03-10 where year should be first and month and day. I am not finding a way to do is it possible to it through sort....?
1) convert your date from '10-MAR-24' to '031024' format (by using PARSE and/or FINDREP)
2) convert the previous result from '031024' to '2024-03-10' (by using Y2W,DT=(4MD-) format)
Why force yourself for DFSORT only ? You could write a cobol date converter program for multipurpose use in your organization, right ? Think about that as well .
Also if you have a db2 then it’s so many date functions which can make life easier to convert to a specific format ..
Why force yourself for DFSORT only ? You could write a cobol date converter program for multipurpose use in your organization, right ? Think about that as well .
Also if you have a db2 then it’s so many date functions which can make life easier to convert to a specific format ..
About 40%-50% of the existing extremely messy COBOL programs do nothing but converting datasets from one format to another one.
About 80%-90% of those 40%-50% can be easily replaced with SORT utility, at the same time improving their performance significantly.
Agree .. However I always recommend to have a date converter module handy at any site ..
In my career I've created a lot of date format converters, in PL/I, COBOL, C/C++, REXX, Assembler/Macro, - when it was really needed inside of a more complex algorithm.
But in case of dataset conversion only, the best way is using SORT utility.
i have used the given sort card to convert the date but getting error
i have input file in whcih i have extracted only the date part and now it looks like below:
Code:
Command ===>
****** *****************************
000001 100324
****** **************************** B
expected ouput :
Code:
2024-03-10
sort card used given above changed the field position accordingly.
Code:
//SYSIN DD *
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=INIT,
OVERLAY=(01:03,2,01,2,06,2)),
IFTHEN=(WHEN=INIT,
BUILD=(1:01,6,Y2W,DT=(4MD-))
/*
**************************** Bottom of Data
Code:
error i am getting :
SYNCSORT LICENSED FOR CPU SERIAL NUMBER 03CD7, MODEL 8561 605
SYSIN :
SORT FIELDS=COPY
OUTREC IFTHEN=(WHEN=INIT,
OVERLAY=(01:03,2,01,2,06,2)),
IFTHEN=(WHEN=INIT,
BUILD=(1:01,6,Y2W,DT=(4MD-))
*
WER813I INSTALLATION OPTIONS IN MFX LOAD LIBRARY WILL BE USED
WER268A OUTREC STATEMENT : SYNTAX ERROR
WER211B SYNCSMF CALLED BY SYNCSORT; RC=0000
WER449I SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE
******************************** END OF DATA ********
please let know if sort card has any issue...? I have used the one suggested to me in above conversation.
'9999-99-99' means that your input field did not contain any CORRECT DATE VALUE in required format Y2W.
Change your BUILD in that way: to show BOTH: initial date value, AND converted date value.
Display in one single line, but in different positions of the same line:
1) the source field coming to your program
2) the result of the first conversion (from OVERLAY), which is also the input to the second conversion
3) the result of the second conversion (which is '9999-99-99' so far)
Then, compare all three fields to find out: what you've done wrong, and in which step?