IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Convert YYYYMMDD to YYYMMDD in R.O.C format


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
jacobdng

New User


Joined: 27 Aug 2006
Posts: 51
Location: Taiwan

PostPosted: Wed Nov 04, 2015 2:09 pm
Reply with quote

Hello,

I need to convert western current date "20151104" to "1041104",which is the date format of my country - Republic of Chinese (Taiwan).

The syntax I used :
Code:
OUTFIL BUILD=(DATE1,SUB,+19110000,TO=CH,LENGTH=6)


and, the error message :
Code:

********************************* TOP OF DATA **********************************
ICE200I 0 IDENTIFIER FROM CALLING PROGRAM IS 0001                               
ICE805I 0 JOBNAME: YBAI1099 , STEPNAME: S0                                     
ICE802I 0 BLOCKSET     TECHNIQUE IN CONTROL                                     
ICE143I 0 BLOCKSET     COPY  TECHNIQUE SELECTED                                 
ICE250I 0 VISIT http://www.ibm.com/storage/dfsort FOR DFSORT PAPERS, EXAMPLES AN
ICE000I 0 - CONTROL STATEMENTS FOR 5694-A01, Z/OS DFSORT V1R12 - 16:22 ON WED NO
          * OUTFIL OVERLAY=(139:(DATE1P,SUB,+20110000,M11,LENGTH=6))           
            OUTFIL BUILD=(DATE1,SUB,+20110000,TO=CH,LENGTH=6)                   
                                $                                               
ICE007A E SYNTAX ERROR                                                         
          * OUTFIL BUILD=(DATE1P,TO=CH,LENGTH=8)                               
ICE146I 0 END OF STATEMENTS FROM CTR1CNTL - PARAMETER LIST STATEMENTS FOLLOW   


Is it possible to treate DATE1P as a number in arithmetic expression?

Jacob
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Nov 04, 2015 2:30 pm
Reply with quote

Application Programming Guide wrote:
DATE1, &DATE1, DATE1(c), DATE1(c), DATE2, &DATE2, DATE2(c), &DATE2(c), DATE3, &DATE3, DATE3(c) or &DATE3(c) can be used to generate a character constant for the current date of the run. DATE1P, &DATE1P, DATE2P, &DATE2P, DATE3P or &DATE3P can be used to generate a packed decimal constant for the current date of the run.


Also, you say TO=CH, you want TO=ZD, and your LENGTH=6 will cause truncation.
Back to top
View user's profile Send private message
jacobdng

New User


Joined: 27 Aug 2006
Posts: 51
Location: Taiwan

PostPosted: Wed Nov 04, 2015 2:37 pm
Reply with quote

Bill,
Since "Packed Decimal" format cannot be displayed, I have to change it to "Character" format.

As for the issue of truncation, LENGTH=6 can be changed to LENGTH=7, but the syntax error is still there.

What is wrong with my sentence?

Jacob
Back to top
View user's profile Send private message
jacobdng

New User


Joined: 27 Aug 2006
Posts: 51
Location: Taiwan

PostPosted: Wed Nov 04, 2015 3:00 pm
Reply with quote

My office hour is over.
Will be back tomorrow.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Nov 04, 2015 4:59 pm
Reply with quote

I didn't do such a good job of formatting the quote from the manual, so I've fixed that.

You can't do arithmetic with a "character" field.

You can't do arithmetic, like that, with a date-constant.

With a date-constant, modification by a number of days or months to give a future or past date is possible, it is built in. However, there is a limit of 9999 days, or months, that you can modify by. Your 1911 years would be too many months.


Quote:
Is it possible to treat DATE1P as a number in arithmetic expression?


No. So you have to do it a different way.

It looks as though you are just testing to use the code later. So your final code may be different.

So, for illustration:

Code:
  OPTION COPY
  OUTFIL IFOUTLEN=7,
        IFTHEN=(WHEN=INIT,
                 BUILD=(DATE1)),
        IFTHEN=(WHEN=INIT,
                 OVERLAY=(1,4,ZD,
                           SUB,
                            +1911,
                           TO=ZD,
                           LENGTH=4)),
        IFTHEN=(WHEN=INIT,
                 OVERLAY=(2,7))


The output is:

Code:
1041104


It is the second IFTHEN which is significant and which makes the amendment to the year portion of a date.

The first IFTHEN puts the 8-character date into the current record.

The third IFTHEN shifts the data left so that you get your seven-character date in the first seven positions.

The IFOUTLEN=7 says "once IFTHEN processing is complete, make the record-length seven".

If you can provide an example of how you want to actually use this, some more directly relevant code can be provided.

I assume that you have realised you must only do this conversion of the date as the last thing. If you were to convert early, or take already converted data and use DFSORT's date functions, you will not (always) get the correct result, because your starting-point year is not going to allow the correct calculation of leap-years for the date functions.
Back to top
View user's profile Send private message
jacobdng

New User


Joined: 27 Aug 2006
Posts: 51
Location: Taiwan

PostPosted: Thu Nov 05, 2015 6:38 am
Reply with quote

Bill,
Thanks for your answer.
It is enough to know that the date-constant cannot be treated as what I thought before.

Your solution is good for my situation.

Jacob
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Populate last day of the Month in MMD... SYNCSORT 2
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Need to convert date format DFSORT/ICETOOL 20
No new posts Keep leading zero(s) after convert fl... SYNCSORT 7
No new posts InfoSphere OPTIM CSV ouput vs DSNTIUA... IBM Tools 3
Search our Forums:

Back to Top