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

I need to replace date value in a string


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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: 8797
Location: Welsh Wales

PostPosted: Fri Jun 10, 2011 2:24 pm
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
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
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: 2481
Location: Netherlands, Amstelveen

PostPosted: Fri Jun 10, 2011 2:38 pm
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: 8797
Location: Welsh Wales

PostPosted: Fri Jun 10, 2011 2:39 pm
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: 8797
Location: Welsh Wales

PostPosted: Fri Jun 10, 2011 2:40 pm
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: 2481
Location: Netherlands, Amstelveen

PostPosted: Fri Jun 10, 2011 2:40 pm
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

Moderator Emeritus


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

PostPosted: Fri Jun 10, 2011 2:45 pm
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
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
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
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: 8696
Location: Dubuque, Iowa, USA

PostPosted: Fri Jun 10, 2011 2:57 pm
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: 1788
Location: Bloomington, IL

PostPosted: Fri Jun 10, 2011 3:02 pm
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
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

Moderator Emeritus


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

PostPosted: Fri Jun 10, 2011 3:37 pm
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

Superior Member


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

PostPosted: Fri Jun 10, 2011 6:39 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
Search our Forums:

Back to Top