Page 1 of 1

how to change copybook name at run time in cobol

PostPosted: Mon Nov 26, 2012 2:36 pm
by nikesh_rai
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

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

PostPosted: Mon Nov 26, 2012 3:08 pm
by BillyBoyo
What do you want to do with the "copybook" at run-time?

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

PostPosted: Mon Nov 26, 2012 3:29 pm
by Robert Sample
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?

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

PostPosted: Tue Nov 27, 2012 11:30 pm
by nikesh_rai
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..

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

PostPosted: Tue Nov 27, 2012 11:41 pm
by Akatsukami
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.)

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

PostPosted: Wed Nov 28, 2012 12:30 am
by Robert Sample
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.

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

PostPosted: Wed Nov 28, 2012 12:48 am
by nikesh_rai
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.

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

PostPosted: Wed Nov 28, 2012 1:48 am
by Akatsukami
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.

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

PostPosted: Wed Nov 28, 2012 2:14 am
by dick scherrer
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 :?