Page 1 of 2

Extract field name in COBOL

PostPosted: Mon Dec 03, 2012 3:44 pm
by nikesh_rai
Hi,

Is it possible to extract field name in COBOL. please don't be confused with field name and field value. i need to extract the all the field name under a group variable. for example. if WS-FMTD-FILE-LAYOUT is group variable and it is defined as given below:
01 WS-FMTD-FILE-LAYOUT
06 WV55-HIER-DOC-PT-ID PIC 9(10) VALUE ZEROES.
06 WV55-HIER-PRORD-SEQ-NBR PIC Z(7) VALUE ZEROES.
06 WV55-PLN-PRTY PIC 9(5) VALUE ZEROES.
06 WV55-PRCG-PLAN-ID PIC X(8).

I want to extarct all fields name under the group variable 01 WS-FMTD-FILE-LAYOUT with their length. Length I know but no idea about extracting field name.

Re: Extract field name in COBOL

PostPosted: Mon Dec 03, 2012 5:35 pm
by enrico-sorichetti
Your requirement is pretty foggy...

You mean that at run time You want to <print> verbatim

WV55-HIER-DOC-PT-ID
WV55-HIER-PRORD-SEQ-NBR
WV55-PLN-PRTY
WV55-PRCG-PLAN-ID


???

Re: Extract field name in COBOL

PostPosted: Mon Dec 03, 2012 5:54 pm
by Robert Sample
How are you expecting to do the extract -- read the COBOL source? use something in the load module (which, by the way, will NOT happen since COBOL does not store that type of data with the load module -- some third party products generate that type of data but not COBOL)? some other method you haven't bothered to explain?

WHY do you want to extract the variable names? If this is a "requirement", you need to explain the full requirement instead of making us guess.

Re: Extract field name in COBOL

PostPosted: Mon Dec 03, 2012 6:58 pm
by nikesh_rai
I am already using these variables through a copybook.. I have to create a header file which will have name of all the variables used in the COBOL module.
if it is not possible in cobol.. can you please suggest me if i can achieve this using JCL or REXX or something else..

Re: Extract field name in COBOL

PostPosted: Mon Dec 03, 2012 7:20 pm
by enrico-sorichetti
if it is not possible in cobol.. can you please suggest me if i can achieve this using JCL or REXX or something else..


why would You want to do that!

Your SCM ( ENDEVOR, CHANGEMAN, SCLM ) should already be able to provide the cross reference copybooks/programs

in any case You would have to replicate part of the compiler processing,
better to try to process the compiler listing with a program written in any language You are comfortable with

Re: Extract field name in COBOL

PostPosted: Mon Dec 03, 2012 8:22 pm
by Robert Sample
1. A copybook is nothing more -- or less -- than a piece of COBOL code (DATA DIVISION or PROCEDURE DIVISION most typically) that is kept external to the program. Note that once your program is compiled, you cannot tell, in any way, whether a particular variable came from the internal program code or from external program code. COBOL does not generate run-time information about variables, except in very limited and specifc cases (such as when using SSRANGE) that do not involve the variable names.

2. You could write a COBOL program to read the output of the compile and pick out variable names. This could also be done using REXX or the programming language of your choice (sorry, you cannot do this using JCL as you requested since JCL does one thing and only one thing -- it executes programs -- although you could use JCL executing a program to do it). The problem in either case is limiting the variables to those you want to include.

3. Products such as STROBE or Xpediter already provide run-time access to variable information so the question really is, why are you attempting to re-invent something already done commercially?

Re: Extract field name in COBOL

PostPosted: Mon Dec 03, 2012 9:01 pm
by nikesh_rai
thanks Robert.. point 2 is really useful ( i don't know why it didn't strike in my mind).. i will do as you told and let you know the result.. :)

Re: Extract field name in COBOL

PostPosted: Mon Dec 03, 2012 9:59 pm
by dick scherrer
Hello,

I have to create a header file which will have name of all the variables used in the COBOL module.
Why does someone believe this is wanted or needed?

If a "thing" has no real value, time would be better used elsewhere . . .

Re: Extract field name in COBOL

PostPosted: Mon Dec 03, 2012 10:33 pm
by BillyBoyo
We still don't know why you want it, which would probably help.

Ensure that you get the "data map" from your compile listing, the datanames and lengths are in "normalised" positions, and you can tell from the normalised level-numbers what belongs where, although you show a very simple layout so won't need it. You don't show any REDEFINES or decimal places, so no problem there.

Re: Extract field name in COBOL

PostPosted: Mon Dec 03, 2012 11:58 pm
by nikesh_rai
BillyBoyo wrote:We still don't know why you want it, which would probably help.

Ensure that you get the "data map" from your compile listing, the datanames and lengths are in "normalised" positions, and you can tell from the normalised level-numbers what belongs where, although you show a very simple layout so won't need it. You don't show any REDEFINES or decimal places, so no problem there.


I have already mentioned above I am using these variables through a copybook.. I have to create a header file which will have name of all the variables used in the COBOL module. I have to work on the requirement and i have nothing to do with why this requirement is. however i got some suggestion from Robert and working on same. Once done.. will update on forum.