×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

COBOL Copybook Explaination

COBOL Copybook Explaination

COBOL Copybook Explaination

(OP)
I have been asked to create a cobol copybook from a data dictionary. I have never used cobol or made a data dictionary. This is copybook will then be used wiith the program Data Junction. I have a sample of the data dictionary but I do not understand it. If someone could please help explain to me how to read and define what goes where. Like S9 and value(9) and so forth.

jtr

RE: COBOL Copybook Explaination

If all you are looking for is an example copybook.......here ya go!

01   PKLR1-DETAIL-LOAN-RECORD.                                   
    10  PKLR1-BASIC-SECTION.                                     
        20  PKLR1-SORT-CONTROL-FIELD.                            
            30  PKLR1-USER-IDENT         PIC X(1).               
            30  PKLR1-EXTRACT-CODE       PIC X(1).               
                88  PKLR1-DATE-RECORD            VALUE '*'.      
                88  PKLR1-DATA-RECORD            VALUE '0'.      
                88  PKLR1-END-OF-FILE            VALUE '9'.      
            30  PKLR1-SECTION            PIC X(1).               
            30  PKLR1-TYPE               PIC X(1).               
            30  PKLR1-NUMERIC-STATE-CODE PIC X(2).               
            30  PKLR1-CONTRACT-NUMBER    PIC X(10).              
        20  PKLR1-PAR-PEN-REG-CODE       PIC X(1).               
        20  PKLR1-VALUATION-CODE.                                
            30  PKLR1-MORTALITY-TABLE    PIC X(2).               
            30  PKLR1-LIVES-CODE         PIC X(1).               
            30  PKLR1-FUNCTION           PIC X(1).               
            30  PKLR1-VAL-INTEREST       PIC S9(2)V9(3) COMP-3.  
            30  PKLR1-MODIFICATION       PIC X(1).               
            30  PKLR1-INSURANCE-CLASS    PIC X(1).               
            30  PKLR1-SERIES             PIC X(5).               
        20  PKLR1-POLICY-STATUS          PIC X(2).               
        20  PKLR1-PAR-CODES.                                     
            30  PKLR1-PAR-TYPE           PIC X(1).               
            30  PKLR1-DIVIDEND-OPTION    PIC X(1).               
            30  PKLR1-OTHER-OPTION       PIC X(1).               
        20  PKLR1-ALPHA-STATE-CODE       PIC X(2).               

Thanks,

RE: COBOL Copybook Explaination

(OP)
Thank you Greenguy71 for the example. What I still don't understand is 1) Does the spacing matter? 2) How do I know if it is a pic or a value or to put something like COMP-3 after the size? Again the example helps. Thanks

jtr

RE: COBOL Copybook Explaination

Chimota,

I have a few question for you.

1. Does your sample data dictionary represent a cobol data file? ie.. Do you have a cobol file and also the layout of it as Greenguy71 posted.  

2. Do you know the cobol file type.  Sequential, Index etc.

Data Junction can read many different types of files as you know, but first you have to define to data junction what the file type is and its structure.

Can you post any information about your sample data dictionary?  What COBOL vendor produced this file?

The comp-3 etc that you mention determines how the internal value is read etc... So it matters greatly..

 
  

RE: COBOL Copybook Explaination

Chimota,

sounds like you are in dire need of a quick introduction into the COBOL language.
As i estimate, no short answer will do in response to your question; i'm going to give it a try, anyway.

Some points of interest may be these:

Every COBOL program source defines a section that is known as Working Storage. This  is a map of a section of memory the program in question uses to store input from files, intermediate results, output to be written to files, etc.
The Working-Storage Section of any COBOL program defines a map for that program. Parts of that map can be hard coded in every program; however, is several programs manipulate e.g. the same file, it makes sense to define the layout for that file into a copybook. Each program can incorporate the exact same layout (= the copybook) in it's working storage by use of the COPY statement.

A Working-Storage definition follows strict rules; so will any copybook. Some of them are (using the example GreenGuy71 gave you):

The words are identifiers to give the program a reference to access a certain portion of memory, i.e. PKLR1-CONTRACT-NUMBER (12th line) defines a 10 byte section of alphameric data. The numbers at the beginning of each line are level numbers; the top level is identified by '01', every number beneath that defines a part of the '01'-level.
For instance, PKLR1-DETAIL-LOAN-RECORD' references the whole definition, since it is at 01-level; PKLR1-BASIC-SECTION is the only defintion at 10-level, and therefore superfluous; every 20-level listed in the example divides the 10-level (and therfore the 01-level) up into several bits that may be manipulated indivdually.

The 'PIC'-clause (PICture) defines the way the referenced bytes should be looked at. I.e. PIC X(10) means 10 bytes of alphameric content, PIC 9(02) means 2 bytes of numeric content, with each byte containing 1 digit, PIC S9(02) means the same, burt with a sign (= positive or negative). The adjective 'COMP-3' means that the numeric content should be stored in a specific format, where each nibble (=4 bits) holds 1 digit. This saves space in the memory occupied.

About spacing: every line in a COBOL program is devided up into 2 sections; area 'A', in the case of your copybook, runs froms position 7 up to 11; position 7 is reserved for comment characters, and the '01' level indicator should be in the positions from 8 to 11 (usually starting at 8). Every other bit should be in the 'B'-section, from position 12 up to the end of the line (usually 72). In section 'B'. spacing is mostly relevant for legibility, as long as each part of a line (that is, level nember, identifier name, 'PIC'-clause, picture, etc.) is at least seperated be a single space.

About value: the 'VALUE'-clause presets the defined memory area to a certain value. Normally, this is determined by the program while executing; however, it can be used to set the value for certain identifiers at the start of execution, either as an initial value, or as a value for a constant.

I hope this lengthy response gets you on the way and NOT confuses you even more !

Good luck !

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close