how to change copybook name at run time in cobol



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

how to change copybook name at run time in cobol

Postby nikesh_rai » Mon Nov 26, 2012 2:36 pm

Hi,

I am working on a requirement where i need to pass the name of the copybook to a cobol program at run time. the name of the copybook i will be passing using JCL parms. but the problem is how i will use it in cobol. this is something like allocating copybook dynamically to the cobol module.is there any way to do it. please suggest me some solution if there is any other way to achieve it
Thanks
Nikesh Rai
nikesh_rai
 
Posts: 205
Joined: Tue Oct 18, 2011 1:27 am
Has thanked: 17 times
Been thanked: 0 time

Re: how to change copybook name at run time in cobol

Postby BillyBoyo » Mon Nov 26, 2012 3:08 pm

What do you want to do with the "copybook" at run-time?
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: how to change copybook name at run time in cobol

Postby Robert Sample » Mon Nov 26, 2012 3:29 pm

Let us review the steps in writing a COBOL program:
1) Design
2) Code
3) Compile
4) Linkage edit / binder
5) Execute the program

It is not possible for your program, while executing, to recompile itself. Accessing a copy book at execution time would require recompiling the program. So either you have not explained what you want to do well enough for us to understand you yet, or what you want to do cannot be done in COBOL at all. Why don't you tell us what problem you are attempting to solve and we can direct you further -- but be aware that what you want to do may not be possible in COBOL?
Robert Sample
Global moderator
 
Posts: 3720
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: how to change copybook name at run time in cobol

Postby nikesh_rai » Tue Nov 27, 2012 11:30 pm

Thanks Robert,

compilation and recompilation is not the problem here. the actual problem is how i will use the copybook in COBOL. the copybook name will be passed from JCL parm
every time i will pass the new copybook name.. the COBOL program will be compiled by tool and this part is over. But the problem remains is how i will use that copybook whose will be passed from JCL to COBOL through parm

My requirement is to create a tool which can format the data in a file with given layout. please suggest me if you have some better idea..
Thanks
Nikesh Rai
nikesh_rai
 
Posts: 205
Joined: Tue Oct 18, 2011 1:27 am
Has thanked: 17 times
Been thanked: 0 time

Re: how to change copybook name at run time in cobol

Postby Akatsukami » Tue Nov 27, 2012 11:41 pm

nikesh_rai wrote:My requirement is create a tool which can format the data in a file wich given layout. please suggest me if you have better idea..

This is rather incoherent. Is not the reformatting of data the whole (OK, maybe not whole, but a significant part) purpose of writing a program in the first place? Are you seriously contemplating writing a proprietary compiler? If so, why? (And not "because it's the requirement"; anyone who gives such a task to a newbie software engineer is either a sadist or a moron.)
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1058
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

Re: how to change copybook name at run time in cobol

Postby Robert Sample » Wed Nov 28, 2012 12:30 am

1. What will you do with the copy book in your program? You have not yet explained this at all.

2. If you expect to be able to use the copy book to read (or write) a file in your COBOL program, then be aware that what you want to do cannot be done in COBOL -- PERIOD. File attributes, such as fixed or variable records, record lengths, key lengths (if any), and so forth, are specified at compile time and cannot be modified in any way by an executing COBOL program.

3. It sounds like you are attempting to develop a tool like File Aid or File Manager. If this is your goal, you need to stop wasting your (and your company's) time and resources since the commercial products are cheaper in the long run. Furthermore, the rule-of-thumb I first learned in college classes is that tools are 3 times hard to develop than application programs, and operating systems are 3 times harder than tools. If you have not been coding application programs for at least 10 years, your experience is woefully short of what you need to develop a tool.
Robert Sample
Global moderator
 
Posts: 3720
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: how to change copybook name at run time in cobol

Postby nikesh_rai » Wed Nov 28, 2012 12:48 am

Yes Robert, you are correct. even i have a discussion with my seniors and they told me the same. what I am trying to do is not possible in COBOL. i am really very sorry for wasting your time. i will try to get it through SAS or REXX.
Thanks
Nikesh Rai
nikesh_rai
 
Posts: 205
Joined: Tue Oct 18, 2011 1:27 am
Has thanked: 17 times
Been thanked: 0 time

Re: how to change copybook name at run time in cobol

Postby Akatsukami » Wed Nov 28, 2012 1:48 am

nikesh_rai wrote:Yes Robert, you are correct. even i have a discussion with my seniors and they told me the same. what I am trying to do is not possible in COBOL. i am really very sorry for wasting your time. i will try to get it through SAS or REXX.

Did you understand Mr. Sample's statement that "you need to stop wasting your (and your company's) time and resources since the commercial products are cheaper in the long run"? If you are doing this purely as a learning exercise, you can ask questions (with the understanding that you may learn nothing from our answers save that you've taken much too large a bite), but if you're actually trying to develop a usable tool, fuggediboutit; it's been done, better and cheaper than you hope to accomplish it, and the result is freely available.
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1058
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

Re: how to change copybook name at run time in cobol

Postby dick scherrer » Wed Nov 28, 2012 2:14 am

Hello,

Just curious, what do you believe using sas or rexx might accomplish? Fiddling with COBOL "copybooks" with either of these will only yield some generated code that references some copybooks. The output of which would still have to be compiled. There would be no "runtime" use of the copybook in the cobol code.

As has been mentioned, what you want to do is no task for a beginner and is a waste of personal and company resources.

I am working on a requirement where i need to pass the name of the copybook to a cobol program at run time.
Who in your management believes this is an appropriate "requirement" or is this just "something you wanted to look into"?

Possibly i misunderstand what your requirement actually is. From the earlier dialog, i may well not (understand).

You mention dynamically using the copybook - would there not be 2 - one for input and one for output?

As i mentioned, i believe i'm lost :?
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post