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
 

 

I need to replace date value in a string

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

New User


Joined: 06 Jul 2010
Posts: 12
Location: hyderabad

PostPosted: Fri Jun 10, 2011 2:13 pm    Post subject: I need to replace date value in a string
Reply with quote

Hi,

I have a string eg: string1 ="username.system.ccyymmdd.abc".

That string is a dataset name and the date value is dynamic which changes on daily bases. I dont know the lenght of the dataser name. It is also dynamic.

How can I change the value of the date everyday.

Please suggest me.
Back to top
View user's profile Send private message

expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Fri Jun 10, 2011 2:24 pm    Post subject:
Reply with quote

The 3LQ will be invalid on the mainframe
Back to top
View user's profile Send private message
nigelosberry

New User


Joined: 06 Jan 2009
Posts: 88
Location: Ggn, IN

PostPosted: Fri Jun 10, 2011 2:25 pm    Post subject: Re: I need to replace date value in a string
Reply with quote

omprakash.mf wrote:
Hi,

I dont know the lenght of the dataser name. It is also dynamic.

Please suggest me.


Can you confirm if the date part i.e. ccyymmdd will always be the third qualifer in the dataset name?

A qualifier must start with a character.
Back to top
View user's profile Send private message
omprakash.mf

New User


Joined: 06 Jul 2010
Posts: 12
Location: hyderabad

PostPosted: Fri Jun 10, 2011 2:36 pm    Post subject:
Reply with quote

Hi nigelosberry,

Yes, it is always the third qualifier in the dataset name.

Ok think it that the third qualifier be like this ACCYYMMDD. where 'A' is a character.
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2422
Location: Netherlands, Amstelveen

PostPosted: Fri Jun 10, 2011 2:38 pm    Post subject:
Reply with quote

A qualifier of 9 characters is not valid.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Fri Jun 10, 2011 2:39 pm    Post subject:
Reply with quote

Wrong, maximum length of eight for each qualifier
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Fri Jun 10, 2011 2:40 pm    Post subject:
Reply with quote

Peter, what are you doing here, you are supposed to be on the naughty step
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2422
Location: Netherlands, Amstelveen

PostPosted: Fri Jun 10, 2011 2:40 pm    Post subject:
Reply with quote

expat wrote:
Wrong, maximum length of eight for each qualifier


My my expat,

a little slow?
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Fri Jun 10, 2011 2:45 pm    Post subject: Reply to: I need to replace date value in a string
Reply with quote

Various ways (once you sort out the validity). Check, as always it seems, STRING, UNSTRING & INSPECT in the manuals.

You don't need the century in your date. You're not going to back-date any datasets 11 years are you? And, at a guess, the same system isn't going to be running in 89 years time.
Back to top
View user's profile Send private message
omprakash.mf

New User


Joined: 06 Jul 2010
Posts: 12
Location: hyderabad

PostPosted: Fri Jun 10, 2011 2:45 pm    Post subject:
Reply with quote

Hi Expat,

Ok. Qualifier will be with 7 bytes size and it is in th form like AYYMMDD.
Back to top
View user's profile Send private message
nigelosberry

New User


Joined: 06 Jan 2009
Posts: 88
Location: Ggn, IN

PostPosted: Fri Jun 10, 2011 2:45 pm    Post subject:
Reply with quote

omprakash.mf wrote:
Hi nigelosberry,

Ok think it that the third qualifier be like this ACCYYMMDD. where 'A' is a character.


As suggested, the qualifier must fit in 8 bytes.

I have seen data set names using dates in past. The format there looks something like:

dyymmdd

where :
'd' is a constant
yy, mm and dd are diff components of date date

but if you want to include the full 'ccyy' in your dateset name instead of only 'yy', you could as well consider using date in julian(i.e. ordinal) format.
Back to top
View user's profile Send private message
nigelosberry

New User


Joined: 06 Jan 2009
Posts: 88
Location: Ggn, IN

PostPosted: Fri Jun 10, 2011 2:53 pm    Post subject: Re: I need to replace date value in a string
Reply with quote

omprakash.mf wrote:
Hi,

I have a string eg: string1 ="username.system.ccyymmdd.abc".

That string is a dataset name and the date value is dynamic which changes on daily bases. I dont know the lenght of the dataser name. It is also dynamic.

How can I change the value of the date everyday.

Please suggest me.


By the way -
(1)are you creating a dataset from inside your cobol program dynamically?
(2)Or you just want to process the dataset name(for writing to a report etc.)?
(3)Or you have this dataset name in your jcl which needs changing daily?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7905
Location: Bellevue, IA

PostPosted: Fri Jun 10, 2011 2:57 pm    Post subject:
Reply with quote

COBOL does not have "strings" like C, Visual Basic, Perl, or .... In COBOL, the maximum length of EVERY variable is known at compile time. Making statements like
Quote:
I dont know the lenght of the dataser name. It is also dynamic.
shows just how little you know about COBOL. The only time a variable length can be dynamic is if (1) the variable has OCCURS DEPENDING ON, and (2) the variable is defined in LINKAGE SECTION. And even if those conditions are met, there still are no strings involved -- just alphanumeric variables.

omprakash.mf, terminology is critical in IT, where similar terms may mean very different things. Your using the term "string" when talking about COBOL indicates a lot of your lack of knowledge and skill. You need to learn the right COBOL terms and use them.

As long as your date value is in the third level of the data set name qualifier, you can use INSPECT or reference modification to find the three periods in the data set name; 2 bytes past the third period will start your date.
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1738
Location: Bloomington, IL

PostPosted: Fri Jun 10, 2011 3:02 pm    Post subject: Re: Reply to: I need to replace date value in a string
Reply with quote

Bill Woodger wrote:
Various ways (once you sort out the validity). Check, as always it seems, STRING, UNSTRING & INSPECT in the manuals.

You don't need the century in your date. You're not going to back-date any datasets 11 years are you? And, at a guess, the same system isn't going to be running in 89 years time.

Yeah, that's what we said back in 1979 icon_wink.gif
Back to top
View user's profile Send private message
nigelosberry

New User


Joined: 06 Jan 2009
Posts: 88
Location: Ggn, IN

PostPosted: Fri Jun 10, 2011 3:08 pm    Post subject: Re: I need to replace date value in a string
Reply with quote

An easy way I could think of:

Code:
INITIALIZE W-1LQ W-2LQ W-3LQ W-4LQ           
                                             
UNSTRING W-X DELIMITED BY '.'                 
INTO W-1LQ W-2LQ W-3LQ W-4LQ                 
                                             
MOVE W-YOUR-DATE TO W-3LQ                     
MOVE SPACES TO W-X                           
                                             
STRING W-1LQ '.' W-2LQ '.' W-3LQ '.' W-4LQ   
DELIMITED BY SPACE                           
INTO W-X               



where W-X is the dataset name.

(Please test icon_smile.gif )
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Fri Jun 10, 2011 3:37 pm    Post subject: Reply to: I need to replace date value in a string
Reply with quote

Test data

Code:

This line intentionally left blank
ABC
ABC.DEF
ABC.DEF.dateplaceholder
ABC.DEF.dateplaceholder.GHI
ABC.DEF.GHI.dateplaceholder
ABC.DEF.GHI
ABC.DEF.GHI
dateplaceholder
ABC.dateplaceholder.DEF
ABC.DEF.GHI.JKL.MNO.PQR etc to max no of qualifiers
etc
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Fri Jun 10, 2011 6:39 pm    Post subject:
Reply with quote

If I got the question correctly, searching for EZACFSM1 might give you what you are looking for.
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 TOT & DATE parameter in ICEMAN hemanthj642 DFSORT/ICETOOL 4 Mon Nov 14, 2016 5:19 am
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
This topic is locked: you cannot edit posts or make replies. Get correct date and time when curren... balaji81_k DB2 24 Fri Oct 14, 2016 10:40 pm
No new posts Replace repeated JCL with looping REXX prino CLIST & REXX 3 Thu Oct 13, 2016 5:30 am
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


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