View previous topic :: View next topic
|
Author |
Message |
ravi30 Currently Banned New User
Joined: 04 Oct 2007 Posts: 10 Location: chennai
|
|
|
|
i am have monthyear x(6) as a variable. how can i unstring this into month x(2) and year x(4). what delimited phrase sould i use ?
help needed ! |
|
Back to top |
|
|
hemanth.nandas
Active User
Joined: 18 Aug 2007 Posts: 120 Location: India
|
|
|
|
Hi Ravi,
Instead of unstring, Just move monthyear x(6) to other variable like this.
Code: |
01 WS-MONTHYEAR.
05 WS-MONTH PIC X(2) VALUES SPACES.
05 WS-YEAR PIC X(4) VALUES SPACES. |
In working storage Move month year to working storage variable.
Code: |
MOVE MONTHYEAR TO WS-MONTHYEAR. |
If you need to do it in Unstring only let us know..
Thanks & Regards |
|
Back to top |
|
|
ravi30 Currently Banned New User
Joined: 04 Oct 2007 Posts: 10 Location: chennai
|
|
|
|
thanks a lot but cant we do this with unstring just delimiting it by the first 2 pic as date and the next 4 as year! i just wanna know if it is possible or not? as im a newbie pl advice. |
|
Back to top |
|
|
hemanth.nandas
Active User
Joined: 18 Aug 2007 Posts: 120 Location: India
|
|
|
|
Hi Ravi,
Yep ,You can do it in many ways, I mean By reference modification, Unstring, Move command.
As you are new to mainframe, I advice to read COBOL book By ROY & DASTIDHAR.
Thanks & Regards |
|
Back to top |
|
|
hemanth.nandas
Active User
Joined: 18 Aug 2007 Posts: 120 Location: India
|
|
|
|
Hi Ravi,
Quote: |
In working storage Move month year to working storage variable |
Sorry, Plse correct it as In procedure Division Move monthyear to other WS-variable.
Thanks & Regards |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
thanks a lot but cant we do this with unstring just delimiting it by the first 2 pic as date and the next 4 as year! i just wanna know if it is possible or not? as im a newbie pl advice. |
UNSTRING is probably not what you want to use. If you use the first 2 bytes as a delimiter, this could cause problems because all valid "month" values could be valid values of the 2 low-order positions of "year".
I believe the suggestions above (multi-field ws-monthyear or reference modification) would be better choices. |
|
Back to top |
|
|
rajaherein
New User
Joined: 11 Jan 2007 Posts: 23 Location: chennai
|
|
|
|
Use Redefines like below,
01 MonthYear Pic X(06).
01 Month-Year Redefines MonthYear.
05 Month Pic X(02).
05 Year Pic X(04).
Hope this Helps. |
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
I don't think UNSTRING can be used, because you would need to have a constant value as delimiter between the 2 values
For example, if you had "mm-yyyy" then you could use:
Code: |
UNSTRING monthyear DELIMITED BY '-' INTO month year |
without that '-' constant, what would you use ?
The best option is to use reference modification:
Code: |
MOVE monthyear (1:2) TO month
MOVE monthyear (3:4) TO year |
|
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
One might use "delimited by size". . . if one was totally detemiined to use UNSTRING.
As mentioned previously, unstring is not a good choice for this particular situation.
If is almost always a good idea to do a "thing" the simplest way. . . |
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
Quote: |
One might use "delimited by size". . . if one was totally detemined to use UNSTRING |
Dick, I was about to write this too, but it didn't sound right so I checked in the manual:
no "delimited by size" with UNSTRING. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hi Marso,
Must only be for STRING - that'll teach me once again to post without first testing
I do hate when that happens |
|
Back to top |
|
|
|