Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
UNSTRING monthyear into month and year

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
ravi30
Currently Banned

New User


Joined: 04 Oct 2007
Posts: 10
Location: chennai

PostPosted: Thu Oct 11, 2007 10:13 am    Post subject: UNSTRING monthyear into month and year
Reply with quote

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
View user's profile Send private message

hemanth.nandas

Active User


Joined: 18 Aug 2007
Posts: 120
Location: Chennai

PostPosted: Thu Oct 11, 2007 10:35 am    Post subject:
Reply with quote

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
View user's profile Send private message
ravi30
Currently Banned

New User


Joined: 04 Oct 2007
Posts: 10
Location: chennai

PostPosted: Thu Oct 11, 2007 10:38 am    Post subject:
Reply with 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.
Back to top
View user's profile Send private message
hemanth.nandas

Active User


Joined: 18 Aug 2007
Posts: 120
Location: Chennai

PostPosted: Thu Oct 11, 2007 10:49 am    Post subject:
Reply with quote

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
View user's profile Send private message
hemanth.nandas

Active User


Joined: 18 Aug 2007
Posts: 120
Location: Chennai

PostPosted: Thu Oct 11, 2007 10:55 am    Post subject:
Reply with quote

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
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu Oct 11, 2007 11:21 am    Post subject:
Reply with quote

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
View user's profile Send private message
rajaherein

New User


Joined: 11 Jan 2007
Posts: 23
Location: chennai

PostPosted: Wed Oct 24, 2007 11:46 am    Post subject:
Reply with quote

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
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1243
Location: Israel

PostPosted: Wed Oct 24, 2007 3:27 pm    Post subject:
Reply with quote

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
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Oct 24, 2007 7:36 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1243
Location: Israel

PostPosted: Wed Oct 24, 2007 9:04 pm    Post subject: Reply to: UNSTRING monthyear into month and year
Reply with quote

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
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Oct 24, 2007 9:18 pm    Post subject:
Reply with quote

Hi Marso,

Must only be for STRING - that'll teach me once again to post without first testing icon_smile.gif

I do hate when that happens icon_redface.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Fetch Previous month & year in MM... girishb2 DFSORT/ICETOOL 3 Thu Sep 21, 2017 9:54 pm
No new posts Reg:Displaying the particular month o... bhavana yalavarthi All Other Mainframe Topics 4 Sat Jul 08, 2017 8:13 pm
No new posts SORT to append Month and YEAR in MMYY... tisamf DFSORT/ICETOOL 1 Wed Mar 08, 2017 4:46 pm
No new posts 2 byte YEAR from Y'DATE2' field tecnokrat DFSORT/ICETOOL 2 Tue Feb 07, 2017 12:05 pm
This topic is locked: you cannot edit posts or make replies. How to pass the previous month date i... Suganya87 DFSORT/ICETOOL 5 Mon Oct 31, 2016 4:13 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us