MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

COBOL pgm (or standard util) to analyze a copybook

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
gkreth
Beginner


Joined: 28 May 2004
Posts: 29
Topics: 10

PostPosted: Thu Jul 08, 2004 9:47 am    Post subject: COBOL pgm (or standard util) to analyze a copybook Reply with quote

I hope someone somewhere has already done this, so I don't have to re-invent the wheel....

I need a COBOL program to read a copy book member and output the byte locations for each field. For example, a copybook like this:
Code:
01  LON-EXTRACT.                                             
    05  LON-PAGE-CALC                      PIC 9(09).       
    05  LON-LOAN-DATA.                                       
        10  LON-LOAN-NBR-ID.                                 
            15  LON-PERS-SSN               PIC 9(09).       
            15  LON-LOAN-SUFX-GRP.                           
                20  LON-LOAN-PROG-CODE     PIC X(01).       
                    88  LON-GSL-LOAN            VALUE 'G'.   
                    88  LON-PLUS-LOAN           VALUE 'P'.   
                    88  LON-SLS-LOAN            VALUE 'S'.   
                    88  LON-CONS-LOAN           VALUE 'C'.   
                    88  LON-RFIN-LOAN           VALUE 'R'.   
                20  LON-LOAN-SEQN-NBR      PIC 9(02).       
        10  LON-LOAN-STAT                  PIC X(02).       
Might have output something like this:
Code:

Level               Field            Fmt Length Start Byte End Byte
----- ------------------------------ --- ------ ---------- --------
  01  LON-EXTRACT                           23       1       23
  05  LON-PAGE-CALC                   9      9       1        9
  05  LON-LOAN-DATA                         14      10       23
  10  LON-LOAN-NBR-ID                       12      10       21
  15  LON-PERS-SSN                    9      9      10       18
  15  LON-LOAN-SUFX-GRP                      3      19       21
  20  LON-LOAN-PROG-CODE              X      1      19       19
  88  LON-GSL-LOAN                    X      1      19       19
  88  LON-PLUS-LOAN                   X      1      19       19
  88  LON-SLS-LOAN                    X      1      19       19
  88  LON-CONS-LOAN                   X      1      19       19
  88  LON-RFIN-LOAN                   X      1      19       19
  20  LON-LOAN-SEQN-NBR               9      2      20       21
  10  LON-LOAN-STAT                   X      2      22       23
I assume the easiest way would be to load up an array of field names as you went along, reading each rec of the copybook. When you hit a REDEFINES clause, you'd need to go back thru the array to find the field being redefined, to get its offset byte location. Of course, you'd also have to compute COMP-3, COMP-4, etc.

88 Levels would be easy: They simply take the values from their "parent fields."

Group levels would probably be best done after all the sub-ordinate fields are finished; e.g., for the Level 15 LON-LOAN-SUFX-GRP above, when the next Level <= 15 was found (in this example, the Level 10 field LON-LOAN-STAT), the largest offset byte computed in the previous "group" (byte 21) would also be last offset byte of LON-LOAN-SUFX-GRP.

Is there a "standard" IBM/MVS util to do this? Is the data available as part of a compile option? Maybe someone has long ago written a COBOL pgm to do this, and would be willing to share? Or am I the only one who thinks something like this would be incredibly useful?

TIA,

--Greg
Back to top
View user's profile Send private message
NutCracker
Beginner


Joined: 13 Dec 2002
Posts: 45
Topics: 3
Location: 3rd Block from the SUN

PostPosted: Thu Jul 08, 2004 9:52 am    Post subject: Reply with quote

Re-inventing the wheel !?
I suppose File-Aid would might solve your requirements. Wink
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Thu Jul 08, 2004 9:59 am    Post subject: Reply with quote

gkreth,

As nutcracker said, option 8 of file-aid does a good job of this. You can also check the "Create DFSORT Symbols from COBOL COPYs" Smart DFSORT Trick which discusses about converting COBOL copybooks to DFSORT symbols, which essentially is the field-names with the start-pos,length and type:

http://www.ibm.com/servers/storage/support/software/sort/mvs/tricks/

Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu


Last edited by kolusu on Fri Sep 15, 2006 8:30 am; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website
gkreth
Beginner


Joined: 28 May 2004
Posts: 29
Topics: 10

PostPosted: Thu Jul 08, 2004 10:04 am    Post subject: Reply with quote

File-Aid! Of course! I should have looked there first! Thanks!

--Greg
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group