View previous topic :: View next topic
|
Author |
Message |
Digvijay Singh
Active User
Joined: 20 Apr 2022 Posts: 153 Location: India
|
|
|
|
Hi Team ,
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....? |
|
Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2209 Location: USA
|
|
|
|
Resolve your issue step-by-step:
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)
RTFM |
|
Back to top |
|
 |
Digvijay Singh
Active User
Joined: 20 Apr 2022 Posts: 153 Location: India
|
|
|
|
Multiple steps is not concern.
How we can use FINDREP because the date is changing and not constant.
I can use FINDREP at least to change the Month MAR to 03 for different month I can use multiple FINDREP condition.
Like below
'10-MAR-24' can be changed to 10-03-24.
Bit stuck at to convert this to 2024-03-10.
any hint for this step..? |
|
Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2209 Location: USA
|
|
|
|
Digvijay Singh wrote: |
How we can use FINDREP because the date is changing and not constant.
|
Code: |
FINDREP=(INOUT=(C'-JAN-',C'01',
C'-FEB-',C'02',
C'-MAR-',C'03',
C'-APR-',C'04',
C'-MAY-',C'05',
C'-JUN-',C'06',
C'-JUL-',C'07',
C'-AUG-',C'08',
C'-SEP-',C'09',
C'-OCT-',C'10',
C'-NOV-',C'11',
C'-DEC-',C'12'))
|
RTFM |
|
Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2209 Location: USA
|
|
|
|
Digvijay Singh wrote: |
'10-MAR-24' can be changed to 10-03-24.
Bit stuck at to convert this to 2024-03-10. |
Code: |
IFTHEN=(WHEN=INIT,
OVERLAY=(67:70,2,67,2,73,2)), '10-03-24' --> '031024'
IFTHEN=(WHEN=INIT,
BUILD=(...new_pos:67,6,Y2W,DT=(4MD-)) '031024' --> '2024-03-10'
|
RTFM |
|
Back to top |
|
 |
Digvijay Singh
Active User
Joined: 20 Apr 2022 Posts: 153 Location: India
|
|
|
|
Thanks for above, I already had this solution to change the month to numbers.
I am stuck at second step.
Like below
'10-MAR-24' can be changed to 10-03-24.
Bit stuck at to convert this to 2024-03-10.
how 10-03-24 can be converted to 2024-03-10. |
|
Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2209 Location: USA
|
|
|
|
Digvijay Singh wrote: |
Thanks for above, I already had this solution to change the month to numbers.
I am stuck at second step.
Like below
'10-MAR-24' can be changed to 10-03-24.
Bit stuck at to convert this to 2024-03-10.
how 10-03-24 can be converted to 2024-03-10. |
RTFM
And above... |
|
Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3087 Location: NYC,USA
|
|
|
|
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 .. |
|
Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2209 Location: USA
|
|
|
|
Rohit Umarjikar wrote: |
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. |
|
Back to top |
|
 |
Rohit Umarjikar
Global Moderator

Joined: 21 Sep 2010 Posts: 3087 Location: NYC,USA
|
|
|
|
Agree .. However I always recommend to have a date converter module handy at any site .. |
|
Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2209 Location: USA
|
|
|
|
Rohit Umarjikar wrote: |
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. |
|
Back to top |
|
 |
Digvijay Singh
Active User
Joined: 20 Apr 2022 Posts: 153 Location: India
|
|
|
|
Hi
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 :
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 any hint is fine I am doing some small mistake heretried multiple time getting sam error again and again. |
|
Back to top |
|
 |
Garry Carroll
Senior Member
Joined: 08 May 2006 Posts: 1207 Location: Dublin, Ireland
|
|
|
|
The asterisk in the output is your hint from the sort - count your open and close parentheses! Very basic stuff, imho.
Also, you're using SYNCSORT which has a separate section to this DFSORT section.
Garry. |
|
Back to top |
|
 |
Digvijay Singh
Active User
Joined: 20 Apr 2022 Posts: 153 Location: India
|
|
|
|
sergeyken wrote: |
Digvijay Singh wrote: |
'10-MAR-24' can be changed to 10-03-24.
Bit stuck at to convert this to 2024-03-10. |
Code: |
IFTHEN=(WHEN=INIT,
OVERLAY=(67:70,2,67,2,73,2)), '10-03-24' --> '031024'
IFTHEN=(WHEN=INIT,
BUILD=(...new_pos:67,6,Y2W,DT=(4MD-)) '031024' --> '2024-03-10'
|
RTFM |
I am talking about this sort card.
i have rectified the syntax error now my job is running fine but in output file i am getting is not correct.
sort card:
Code: |
//SYSIN DD *
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=INIT,
OVERLAY=(05:08,2,05,2,01,2)),
IFTHEN=(WHEN=INIT,
BUILD=(1:05,6,Y2W,DT=(4MD-)))
/* |
output file:
Code: |
Command ===>
****** ********************
000001 9999-99-99
****** ******************** |
please let know if sort card has any issue...? I have used the one suggested to me in above conversation. |
|
Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2209 Location: USA
|
|
|
|
Digvijay Singh wrote: |
sergeyken wrote: |
Digvijay Singh wrote: |
'10-MAR-24' can be changed to 10-03-24.
Bit stuck at to convert this to 2024-03-10. |
Code: |
IFTHEN=(WHEN=INIT,
OVERLAY=(67:70,2,67,2,73,2)), '10-03-24' --> '031024'
IFTHEN=(WHEN=INIT,
BUILD=(...new_pos:67,6,Y2W,DT=(4MD-)) '031024' --> '2024-03-10'
|
RTFM |
I am talking about this sort card. |
My expectation was that you are able to count the balance of parenthesis by yourself, not only to copy-and-paste a ready-to-use code.
Digvijay Singh wrote: |
i have rectified the syntax error now my job is running fine but in output file i am getting is not correct.
sort card:
Code: |
//SYSIN DD *
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=INIT,
OVERLAY=(05:08,2,05,2,01,2)),
IFTHEN=(WHEN=INIT,
BUILD=(1:05,6,Y2W,DT=(4MD-)))
/* |
output file:
Code: |
Command ===>
****** ********************
000001 9999-99-99
****** ******************** |
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.
Please, RTFM a little bit!!! |
|
Back to top |
|
 |
Digvijay Singh
Active User
Joined: 20 Apr 2022 Posts: 153 Location: India
|
|
|
|
Here is my input field :
Code: |
Command ===>
=COLS> ----+----1----+----2----+----3----+
****** ***************************** Top o
000001 10-03-24
****** **************************** Bottom |
date part is stating from 5th position here.
you mean to say the first Overlay part is not producing the correct date ..?
Code: |
INREC IFTHEN=(WHEN=INIT,
OVERLAY=(05:08,2,05,2,01,2)), |
|
|
Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2209 Location: USA
|
|
|
|
Digvijay Singh wrote: |
Here is my input field :
Code: |
Command ===>
=COLS> ----+----1----+----2----+----3----+
****** ***************************** Top o
000001 10-03-24
****** **************************** Bottom |
date part is stating from 5th position here.
you mean to say the first Overlay part is not producing the correct date ..?
Code: |
INREC IFTHEN=(WHEN=INIT,
OVERLAY=(05:08,2,05,2,01,2)), |
|
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?
Please, RTFM a little bit!!! |
|
Back to top |
|
 |
Digvijay Singh
Active User
Joined: 20 Apr 2022 Posts: 153 Location: India
|
|
|
|
I was able to do that in two step, i was not much confident with overlay i used below two step:
step1 sort:
Code: |
//**************************************
//* 5TH
//* 10-03-24 031024 **********
//* 67TH *********
//* 10-03-24 031024 **********
//**************************************
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
OUTREC FIELDS=(1:8,2,03:05,2,5:11,2) |
Step2 sort:
Code: |
//***********************************************
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=INIT,
BUILD=(01:01,06,Y2W,DT=(4MD-))) |
**************************** Bottom of Data *****
output i got :
Code: |
***********
2024-03-10 |
*********** |
|
Back to top |
|
 |
Joerg.Findeisen
Senior Member

Joined: 15 Aug 2015 Posts: 1387 Location: Bamberg, Germany
|
|
|
|
No need to specify the obvious starting positions here. It will start at position one.
Code: |
OUTREC BUILD=(8,2,5,2,11,2) |
Same applies to the other BUILD statement. |
|
Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2209 Location: USA
|
|
|
|
No need to make simple things too complex for no reason:
Code: |
//**************************************
//* 5TH
//* 10-03-24 031024 **********
//**************************************
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
INREC FIELDS=(8,2, MM
5,2, DD
11,2) YY
SORT FIELDS=COPY
OUTREC BUILD=(01,06,Y2W, MMDDYY
DT=(4MD-))) YYYY-MM-DD
END
//* |
P.S.
OVERLAY also can be used, after some thinking about it. |
|
Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2209 Location: USA
|
|
|
|
Extra parenthesis to be fixed:
Code: |
//**************************************
//* 5TH
//* 10-03-24 031024 **********
//**************************************
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
INREC FIELDS=(8,2, MM
5,2, DD
11,2) YY
SORT FIELDS=COPY
OUTREC BUILD=(01,06,Y2W, MMDDYY
DT=(4MD-)) YYYY-MM-DD
END
//* |
|
|
Back to top |
|
 |
|
|