|
View previous topic :: View next topic
|
| Author |
Message |
zh_lad
Active User
Joined: 06 Jun 2009 Posts: 115 Location: UK
|
|
|
|
Hi,
I have symbol (SYSNAMES) built using below code:
| Code: |
OPTION COPY
INREC BUILD=(C'MYDATE,''',15,5,C'''',80:X) |
This result in
Julian date in YYDDD format. In next step, I want to covert this into Gregorian format (CCYYMMDD) and OVERLAY at position 15.
I have below code in step 2.
| Code: |
OPTION COPY
OUTREC IFTHEN=(WHEN=INIT,
OVERLAY=(15:MYDATE,15,5,Y2T,TOGREG=Y4T)) |
This resulting in:
| Code: |
| C00000010I1817020180619 |
My expected result is:
I searched forum, there are various examples on this conversion but none of them uses symbol.
Many thanks. |
|
| Back to top |
|
 |
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2482 Location: @my desk
|
|
|
|
zh_lad,
You could try creating the symbol itself in Gregorian format in your step1 and use it in Step2. |
|
| Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2283 Location: USA
|
|
|
|
What is the idea of full mess-up when dealing with SYMNAMES in your task???
What is the role, or any benefit from your MYDATE???
Now you get what you have requested: at position 15 there is your original date, while converted date goes right next to it. |
|
| Back to top |
|
 |
zh_lad
Active User
Joined: 06 Jun 2009 Posts: 115 Location: UK
|
|
|
|
Thanks Arun. My input date file has date in three formats:
YYMMDD, DDMMYY, YYDDD
Yes I can use YYMMDD format for this particular step (input file).
However, I have to write lots of steps to change the date on different input files, all have different date format. This would mean, for each input file, I will have to create symbol file.
I was hoping TOJUL and TOGREG will allow to get all the formats I need. |
|
| Back to top |
|
 |
zh_lad
Active User
Joined: 06 Jun 2009 Posts: 115 Location: UK
|
|
|
|
| sergeyken wrote: |
What is the idea of full mess-up when dealing with SYMNAMES in your task???
What is the role, or any benefit from your MYDATE???
Now you get what you have requested: at position 15 there is your original date, while converted date goes right next to it. |
I want to re use SYSNAMES dataset to populate date on different files.
I want to user to provide date
Yes, I know but I didn't know how to convert date same time at position 15.
Thanks.
Please note file is VB. |
|
| Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2283 Location: USA
|
|
|
|
| zh_lad wrote: |
| sergeyken wrote: |
What is the idea of full mess-up when dealing with SYMNAMES in your task???
What is the role, or any benefit from your MYDATE???
Now you get what you have requested: at position 15 there is your original date, while converted date goes right next to it. |
I want to re use SYSNAMES dataset to populate date on different files.
I want to user to provide date
Yes, I know but I didn't know how to convert date same time at position 15.
Thanks.
Please note file is VB. |
Split the two of them (value substitution, and date conversion)
1) either into INREC + OUTREC,
2) or into separate WHEN=...,OVERLAY= groups |
|
| Back to top |
|
 |
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2482 Location: @my desk
|
|
|
|
| zh_lad wrote: |
Thanks Arun. My input date file has date in three formats:
YYMMDD, DDMMYY, YYDDD
Yes I can use YYMMDD format for this particular step (input file).
However, I have to write lots of steps to change the date on different input files, all have different date format. This would mean, for each input file, I will have to create symbol file.
I was hoping TOJUL and TOGREG will allow to get all the formats I need. |
How about creating 3 different date symbols corresponding to each date format, write all of them in your SYMNAMES once and then use whichever you want in the subsequent steps.
Something like this:
| Code: |
//STEP01 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
18170
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
OUTFIL BUILD=(C'MYDATEJ1,''',01,5,C'''',80:X,/,
C'MYDATEG1,''',01,5,Y2T,TOGREG=Y4T,C'''',/,
C'MYDATEG2,''',01,5,Y2T,TOGREG=Y4W,C'''') |
would give:
| Code: |
MYDATEJ1,'18170'
MYDATEG1,'20180619'
MYDATEG2,'06192018' |
|
|
| Back to top |
|
 |
zh_lad
Active User
Joined: 06 Jun 2009 Posts: 115 Location: UK
|
|
|
|
Thanks sergeyken.
I did try INREC + OUTREC but I couldn't syntax right. I will try little better this time.
Thanks. I didn't realise I have multiple IFTHEN and WHEN. Will try both options.
Cheers |
|
| Back to top |
|
 |
zh_lad
Active User
Joined: 06 Jun 2009 Posts: 115 Location: UK
|
|
|
|
Thanks Arun. I have gone with having multiple symbols method. It's quite easy to use. I wasn't aware we can use more than one symbol on a file.
Here is my input date file:
| Code: |
| 180619 190618 18170 200618 18171 18169 000000Y TUE13 |
Here is my sort code to create symbols, dates in different format:
| Code: |
OPTION COPY
OUTFIL BUILD=(C'MYDATE,''',1,6,C'''',80:X,/,
C'MYDATEJ1,''',15,5,C'''',/,
C'MYDATEG1,''',15,5,Y2T,TOGREG=Y4T,C'''',/,
C'MYDATEG2,''',15,5,Y2T,TOGREG=Y2T(/),C'''',/,
C'MYDATEG3,''',15,5,Y2T,TOGREG=Y4W,C'''',/,
C'MYDATEG4,''',8,6,C'''',/,
C'MYDATEG5,''',8,2,C'/',10,2,C'/',12,2,C'''',/,
C'MYDB2DT1,''',15,5,Y2T,TOGREG=Y4T(-),C'''') |
Here is what it produces:
| Code: |
MYDATE,'180619'
MYDATEJ1,'18170'
MYDATEG1,'20180619'
MYDATEG2,'18/06/19'
MYDATEG3,'06192018'
MYDATEG4,'190618'
MYDATEG5,'19/06/18'
MYDB2DT1,'2018-06-19' |
I am now cruising along in amending dates on 200 odd files. This jcl will be used often to move dates to a new date for 200 files.
Thanks and regards. |
|
| Back to top |
|
 |
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2482 Location: @my desk
|
|
|
|
zh_lad,
Thanks for posting. Glad it worked out well for you.! |
|
| Back to top |
|
 |
zh_lad
Active User
Joined: 06 Jun 2009 Posts: 115 Location: UK
|
|
|
|
Hi again,
Is there any function or keyword which can convert Julian date to DDMMCCYY.
I can see Arun has used:
| Code: |
| C'MYDATEG3,''',15,5,Y2T,TOGREG=Y4W,C'''' |
to convert Julian date into MMDDCCYY.
Thanks. |
|
| Back to top |
|
 |
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
| Not from what I can see in the manual. Seems strange that one of the most used formats is not catered for. |
|
| Back to top |
|
 |
zh_lad
Active User
Joined: 06 Jun 2009 Posts: 115 Location: UK
|
|
|
|
yeah.
I have built is from DDMMYY (P8,L6).
| Code: |
| C'MYDATEG6,''',8,4,C'20',12,2,C'''',/, |
Thanks. |
|
| Back to top |
|
 |
steve-myers
Active Member
Joined: 30 Nov 2013 Posts: 917 Location: The Universe
|
|
|
|
- What bone head designed the contents of this data set? Well, that's something we will never know. Not 20 years ago our industry went through considerable pain to resolve issues with two digit dates and we still have boneheads putting 2 digit years into data. Resolving the same issues in the 2090s will be even more of a nightmare than the Y2K issues in the 1990s. At least 2000 was a leap year. 2100 is not.
- The sort products have built in tools to transform two digit years to correct 4 digit years. These tools will not work correctly in 20 or 30 years, but they work correctly now. Find these tools in your sort product documentation and use them.
- Dates expressed as yyddd have often been called a "Julian" date. This is not correct. A Julian date is a date expressed, for the most part, like any other date.
|
|
| Back to top |
|
 |
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2482 Location: @my desk
|
|
|
|
| zh_lad wrote: |
yeah.
I have built is from DDMMYY (P8,L6).
| Code: |
| C'MYDATEG6,''',8,4,C'20',12,2,C'''',/, |
Thanks. |
You could do the conversion just once from YYDDD to CCYYMMDD and then in the output, just rearrange the data as you need instead of trying to convert for each symbol. |
|
| Back to top |
|
 |
zh_lad
Active User
Joined: 06 Jun 2009 Posts: 115 Location: UK
|
|
|
|
Thanks Arun.
One last question on this thread.
Is there a way I can draw or convert date into DD-MMM-YY (e.g. 19-JUN-18) or similar format where first three letters of month is displayed?
I understand I can have conditional check on MM (06) to populate first three bytes of month name (in this case JUN).
Cheers |
|
| Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2283 Location: USA
|
|
|
|
| zh_lad wrote: |
Thanks Arun.
One last question on this thread.
Is there a way I can draw or convert date into DD-MMM-YY (e.g. 19-JUN-18) or similar format where first three letters of month is displayed?
I understand I can have conditional check on MM (06) to populate first three bytes of month name (in this case JUN).
Cheers |
1) first, convert to
2) then use
| Code: |
FINDREP=(INOUT=(C'/01/',C'-JAN-',
. . . . . . . . . . . . .
C'/12/',C'-DEC-')) |
|
|
| Back to top |
|
 |
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2482 Location: @my desk
|
|
|
|
| Quote: |
| I understand I can have conditional check on MM (06) to populate first three bytes of month name (in this case JUN). |
You could OVERLAY a 3 character month at the end of your input record and use it in your OUTFIL.
| Code: |
//STEP01 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTOUT DD SYSOUT=*
//SORTIN DD *
180619 190618 18170 200618 18171 18169 000000Y
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:03,2,X)),
IFTHEN=(WHEN=INIT,
FINDREP=(INOUT=(C'01',C'JAN',C'02',C'FEB',C'03',C'MAR',
C'04',C'APR',C'05',C'MAY',C'06',C'JUN',
C'07',C'JUL',C'08',C'AUG',C'09',C'SEP',
C'10',C'OCT',C'11',C'NOV',C'12',C'DEC'),
STARTPOS=81)) |
|
|
| Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2283 Location: USA
|
|
|
|
| Arun Raj wrote: |
| Quote: |
| I understand I can have conditional check on MM (06) to populate first three bytes of month name (in this case JUN). |
You could OVERLAY a 3 character month at the end of your input record and use it in your OUTFIL.
| Code: |
//STEP01 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTOUT DD SYSOUT=*
//SORTIN DD *
180619 190618 18170 200618 18171 18169 000000Y
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:03,2,X)),
IFTHEN=(WHEN=INIT,
FINDREP=(INOUT=(C'01',C'JAN',C'02',C'FEB',C'03',C'MAR',
C'04',C'APR',C'05',C'MAY',C'06',C'JUN',
C'07',C'JUL',C'08',C'AUG',C'09',C'SEP',
C'10',C'OCT',C'11',C'NOV',C'12',C'DEC'),
STARTPOS=81)) |
|
FINDREP= must convert digits enclosed in separators. Otherwise also days, and/or years, and/or combinations of days/months/years could be converted to month names! |
|
| Back to top |
|
 |
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2482 Location: @my desk
|
|
|
|
| sergeyken wrote: |
| FINDREP= must convert digits enclosed in separators. Otherwise also days, and/or years, and/or combinations of days/months/years could be converted to month names! |
Enclosing in separators is not really required. If you notice the control statements above, only the month portion is OVERLAYed at pos-81 and the FINDREP scanning is set to start at pos-81 to convert the month(mm) to JAN, FEB, etc... The rest of the data would remain unaffected. |
|
| Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2283 Location: USA
|
|
|
|
| Arun Raj wrote: |
| sergeyken wrote: |
| FINDREP= must convert digits enclosed in separators. Otherwise also days, and/or years, and/or combinations of days/months/years could be converted to month names! |
Enclosing in separators is not really required. If you notice the control statements above, only the month portion is OVERLAYed at pos-81 and the FINDREP scanning is set to start at pos-81 to convert the month(mm) to JAN, FEB, etc... The rest of the data would remain unaffected. |
Not recommended, and non-flexible approach. Such methods, in general, are the main reasons why modern software requires monthly/weekly/daily/hourly updates, while old stable programs do work for years and years without problems. |
|
| Back to top |
|
 |
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2482 Location: @my desk
|
|
|
|
| The STARTPOS ENDPOS subparameters are there just to serve this very purpose. Ie. To limit the FIND REPLACE to specific positions. I don't see how it will be a non flexible approach. And old stable programs working for several years without any problems has nothing to do with this. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|