Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

How to get the right string from Variable using PARSE VAR ?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
View previous topic :: :: View next topic  
Author Message
jackzhang75

Active User


Joined: 09 Jun 2014
Posts: 106
Location: windsor

PostPosted: Mon Nov 16, 2015 10:04 pm    Post subject: How to get the right string from Variable using PARSE VAR ?
Reply with quote

Hi experts,

I want to get only 2015.317 from following variable like
Code:
"A=DATASET-OWNER-----(NULL)     CREATION--------2015.317"

How to use
Code:
PARSE VAR
to get right word you want like in this case
2015.317 ? Thanks
Back to top
View user's profile Send private message

enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10203
Location: italy

PostPosted: Mon Nov 16, 2015 10:30 pm    Post subject: Reply to: How to get the right string from Variable using PARSE VAR ?
Reply with quote

Code:
a = "DATASET-OWNER-----(NULL)     CREATION--------2015.317"

parse var a with . "CREATION--------" crdate .

say crdate
Back to top
View user's profile Send private message
RahulG31

Active User


Joined: 20 Dec 2014
Posts: 331
Location: USA

PostPosted: Mon Nov 16, 2015 10:38 pm    Post subject: Reply to: How to get the right string from Variable using PARSE VAR ?
Reply with quote

You can also know this if you know the starting position of date:
Code:
 A = "DATASET-OWNER-----(NULL)     CREATION--------2015.317"
 PARSE VAR A 46 CRDATE
 SAY CRDATE
Back to top
View user's profile Send private message
jackzhang75

Active User


Joined: 09 Jun 2014
Posts: 106
Location: windsor

PostPosted: Mon Nov 16, 2015 11:31 pm    Post subject:
Reply with quote

Thank you expters , thats work perfect
Back to top
View user's profile Send private message
jackzhang75

Active User


Joined: 09 Jun 2014
Posts: 106
Location: windsor

PostPosted: Tue Nov 17, 2015 12:02 am    Post subject:
Reply with quote

Another question , how to split 2015.317 into two varible ? one for 2015 as YEAR one for 317 as Date ?
Back to top
View user's profile Send private message
RahulG31

Active User


Joined: 20 Dec 2014
Posts: 331
Location: USA

PostPosted: Tue Nov 17, 2015 12:39 am    Post subject: Reply to: How to get the right string from Variable using PARSE VAR ?
Reply with quote

If you understand the above 2 methods then it should be really simple. What method are you using ?
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1715
Location: UK

PostPosted: Tue Nov 17, 2015 8:32 pm    Post subject:
Reply with quote

As that line is fixed format you could have used SUBSTR.
Read the manual about PARSE.
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1219
Location: Israel

PostPosted: Tue Nov 17, 2015 9:00 pm    Post subject: Reply to: How to get the right string from Variable using PARSE VAR ?
Reply with quote

There are many ways:
Code:
CreationDate = Right(Strip(A),8)
Back to top
View user's profile Send private message
Willy Jensen

New User


Joined: 01 Sep 2015
Posts: 96
Location: Switzerland

PostPosted: Thu Nov 19, 2015 1:31 am    Post subject:
Reply with quote

you could also do
dv=word(translate(var,' ','-'),5)
yes I know you asked for PARSE
Back to top
View user's profile Send private message
Willy Jensen

New User


Joined: 01 Sep 2015
Posts: 96
Location: Switzerland

PostPosted: Thu Nov 19, 2015 1:59 am    Post subject:
Reply with quote

or with parse, as there is only one dot in the string:
parse var v . '.' -4 dv +8 .
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 -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. Checking wether a string starts from ... sundaram.naveen CLIST & REXX 9 Thu Oct 06, 2016 11:56 am
No new posts Format to pipe delimited with variabl... pshongal SYNCSORT 6 Wed Sep 14, 2016 2:48 pm
No new posts Random Password (in string format) ge... ezhavendhan COBOL Programming 10 Mon Aug 29, 2016 3:18 pm
No new posts How to insert a lengthy string havin... vidyaa DB2 7 Thu Aug 25, 2016 5:20 pm
No new posts Which function does the Ampersand (&a... Andi1982 PL/I & Assembler 3 Wed Aug 24, 2016 2:05 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us