Extract field name in COBOL



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

Extract field name in COBOL

Postby nikesh_rai » Mon Dec 03, 2012 3:44 pm

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.
Thanks
Nikesh Rai
nikesh_rai
 
Posts: 205
Joined: Tue Oct 18, 2011 1:27 am
Has thanked: 17 times
Been thanked: 0 time

Re: Extract field name in COBOL

Postby enrico-sorichetti » Mon Dec 03, 2012 5:35 pm

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


???
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2994
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times

Re: Extract field name in COBOL

Postby Robert Sample » Mon Dec 03, 2012 5:54 pm

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

Re: Extract field name in COBOL

Postby nikesh_rai » Mon Dec 03, 2012 6:58 pm

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..
Thanks
Nikesh Rai
nikesh_rai
 
Posts: 205
Joined: Tue Oct 18, 2011 1:27 am
Has thanked: 17 times
Been thanked: 0 time

Re: Extract field name in COBOL

Postby enrico-sorichetti » Mon Dec 03, 2012 7:20 pm

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
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2994
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times

Re: Extract field name in COBOL

Postby Robert Sample » Mon Dec 03, 2012 8:22 pm

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

Re: Extract field name in COBOL

Postby nikesh_rai » Mon Dec 03, 2012 9:01 pm

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.. :)
Thanks
Nikesh Rai
nikesh_rai
 
Posts: 205
Joined: Tue Oct 18, 2011 1:27 am
Has thanked: 17 times
Been thanked: 0 time

Re: Extract field name in COBOL

Postby dick scherrer » Mon Dec 03, 2012 9:59 pm

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 . . .
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

Re: Extract field name in COBOL

Postby BillyBoyo » Mon Dec 03, 2012 10:33 pm

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

Re: Extract field name in COBOL

Postby nikesh_rai » Mon Dec 03, 2012 11:58 pm

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.
Thanks
Nikesh Rai
nikesh_rai
 
Posts: 205
Joined: Tue Oct 18, 2011 1:27 am
Has thanked: 17 times
Been thanked: 0 time

Next

Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post