Page 1 of 1

Composing a dataset name from already existing dataset name.

PostPosted: Fri Jan 20, 2012 7:17 pm
by vinodj
Hello,

I have a dataset name in a variable, source_dsn.

Let's say source_dsn is P12345.T43X.Z0009.DATA.SOME. I am logically designating the five segments as <1.XP>.<2.XP>.<3.XP>.<4.XP>.<5.XP>
so that <1.XP> stands for P12345
<2.XP> stands for T43X
<3.XP> stands for Z0009 and so on...

I have another variable, target_dsn.
Let's say I am specifying the content of target_dsn as B1678NG.<4.XP>.<2.XP>.DATA

Now I want this target_dsn to be calculated finally as : B1678NG.DATA.T43X.DATA (as <4.XP> stands for DATA and <2.XP> stands for T43X according to previous conventions. I want static part to remain as it is. e.g. B1678NG should be same as previous.)

There is one more restriction.

If I specify my target_dsn as B1678NG.<4.XP>.<2.XP>.<D.XP>.<T.XP>

then <D.XP> should be replaced by current date and <T.XP> should be replaced by current time. In short the target_dsn would look like following :

B1678NG.DATA.T43X.D201143.T020305

Kindly tell me how could this be done in COBOL.

Regards,
Vinod.

Re: Composing a dataset name from already existing dataset n

PostPosted: Fri Jan 20, 2012 7:43 pm
by Robert Sample
Kindly tell me how could this be done in COBOL.
By writing code. Start by writing pseudocode that does what you explained, then convert the pseudocode into COBOL statements. Since this is a HELP forum, not a WRITE-YOUR-CODE-FOR-YOU forum, we won't write the code for you (unless we get paid, of course -- 1000 U.S. dollars or equivalent is a typical rate). We will, however, help steer you correctly when you post some indication that you've made progress but cannot figure out where your code is going awry.

Re: Composing a dataset name from already existing dataset n

PostPosted: Sat Jan 21, 2012 6:06 am
by BillyBoyo
I'd suggest you read up on UNSTRING, INSPECT and STRING in the Cobol manuals. What is your source for the date? For the time, have a look at the "intrinsic functions" as well.

Re: Composing a dataset name from already existing dataset n

PostPosted: Mon Jan 23, 2012 12:14 pm
by vinodj
Hello Billy,

I was thinking along the same lines of string and unstring. I was just wondering if there was some utility to separate the qualifiers of dataset name that I was not aware of hence posted this query.

Thanks.
Vinod

Re: Composing a dataset name from already existing dataset n

PostPosted: Mon Jan 23, 2012 1:04 pm
by BillyBoyo
If you wanted a utility to do it, why post in the Cobol forum? Your Sort product can do this.

Re: Composing a dataset name from already existing dataset n

PostPosted: Mon Jan 23, 2012 5:40 pm
by vinodj
It worked with STRING, UNSTRING and INSPECT.

Thanks.