Composing a dataset name from already existing dataset name.



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Composing a dataset name from already existing dataset name.

Postby vinodj » Fri Jan 20, 2012 7:17 pm

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.
vinodj
 
Posts: 29
Joined: Wed Nov 23, 2011 6:16 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Composing a dataset name from already existing dataset name.

 

Re: Composing a dataset name from already existing dataset n

Postby Robert Sample » Fri Jan 20, 2012 7:43 pm

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.
Robert Sample
Global moderator
 
Posts: 3367
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 222 times

Re: Composing a dataset name from already existing dataset n

Postby BillyBoyo » Sat Jan 21, 2012 6:06 am

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.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Composing a dataset name from already existing dataset n

Postby vinodj » Mon Jan 23, 2012 12:14 pm

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
vinodj
 
Posts: 29
Joined: Wed Nov 23, 2011 6:16 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Composing a dataset name from already existing dataset n

Postby BillyBoyo » Mon Jan 23, 2012 1:04 pm

If you wanted a utility to do it, why post in the Cobol forum? Your Sort product can do this.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Composing a dataset name from already existing dataset n

Postby vinodj » Mon Jan 23, 2012 5:40 pm

It worked with STRING, UNSTRING and INSPECT.

Thanks.
vinodj
 
Posts: 29
Joined: Wed Nov 23, 2011 6:16 pm
Has thanked: 0 time
Been thanked: 0 time


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post