1 / 260

Enterprise COBOL Concepts

Enterprise COBOL Concepts. Dr. David Woolbright woolbright_david@columbusstate.edu 2013. Video Link. Watch the Introductory video lesson here. COBOL?. Co mmon B usiness O riented L anguage Billions of lines of existing code with more added each year Designed for business processing

stamos
Download Presentation

Enterprise COBOL Concepts

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Enterprise COBOL Concepts Dr. David Woolbright woolbright_david@columbusstate.edu 2013

  2. Video Link • Watch the Introductory video lesson here

  3. COBOL? • Common Business Oriented Language • Billions of lines of existing code with more added each year • Designed for business processing • Great compilers • Cobol programs execute quickly • Relatively simple to learn • Not your father’s or mother’s COBOL - The language keeps evolving (XML, OO)

  4. Enterprise Cobol for z\OS IBM COBOL: • http://www-01.ibm.com/software/awdtools/cobol/zos/ Languagage Reference • http://publibfp.boulder.ibm.com/epubs/pdf/igy3lr50.pdf Programming Guide • http://publibfp.boulder.ibm.com/epubs/pdf/igy3pg50.pdf

  5. Program Organization • Program – Organized like a book • Division – Identification, Environment, Data, Procedure • Section • Paragraph • Sentence • Clause • Phrase • Word

  6. Grammatical Hierarchy • The grammatical hierarchy follows this form: • Identification division • Paragraphs • Entries • Clauses • Environment division • Sections • Paragraphs • Entries • Clauses • Phrases • Data division • Sections • Entries • Clauses • Phrases • Procedure division • Sections • Paragraphs • Sentences • Statements • Phrases

  7. Coding Rules • Cols 1-6 – left blank. Editor fills in with sequence numbers • Col 7 – Usually blank,* means comment line, - is continuation, D for debugging lines • Cols 8-11 – “A” margin or Area A • Cols 12-72 – “B” margin or Area B • Cols 73-80 – unused • 1 2 3 4 5 6|7| 8 9 10 11|12 13 …71 72 | Seq Nos | | Area A | Area B |

  8. Continuation of Statements • Statements can be continued on the next line in Area B

  9. Continuation of Literals • Continue the constant through column 71 • Put a “-” in column 7 • Continue constant with a ‘ OR “ • Continue constant in area B

  10. Things That Go in Area A Area A items: • Division headers • Section headers • Paragraph headers or paragraph names • Level indicators or level-numbers (01 and 77) • DECLARATIVES and END DECLARATIVES • End program, end class, and end method markers

  11. Things That Go in Area B Area B items: • Entries, sentences, statements, and clauses • Continuation lines

  12. Things That Go in A or B • Level-numbers • Comment lines • Compiler-directing statements • Debugging lines • Pseudo-text

  13. Preparing a Program Your Cobol Program Object Module Load Module CoboL Compiler Linkage Editor

  14. Things You Should Try • You will need to create a PDS (Partitioned Data Set) to hold the programs (members) you create. You can watch a video about how to create a PDS here. • You will also need a load library where the linkage editor can place the executable programs (load modules) you create. Here is a video that describes how to build a load library.

  15. Things You Should Try • When you’re beginning to learn a new language, it’s a good idea to type in a few programs from scratch. Here is a Hello, World program you should create in your PDS. And here is a video of how to create the program. • Here’s a link to some JCL that can be modified to compile, link, and run a COBOL program on your system.

  16. Things You Should Try • Here is a video that discusses how to change the JCL to fit your situation.

  17. Video Link • Watch the Video lesson #2 here

  18. Structure of a Program

  19. IDENTIFICATION DIVISION IDENTIFICATION DIVISION. PROGRAM-ID. HELLO. AUTHOR. JOE SMITH. INSTALLATION. TSYS. DATE-WRITTEN. 12/03/2011. DATE-COMPILED. 12/03/2011. • Only PROGRAM-ID is required • Some interesting parms can be coded on the PROGRAM-ID

  20. ENVIRONMENT DIVISION This division connects external DD file names with internal file names. ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT MSTRFILE ASSIGN TO MSTRFILE SELECT CUSTOMER-FILE ASSIGN TO CUSTMAST ORGANIZATION IS INDEXED ACCESS MODE IS RANDOM RECORD KEY IS COSTOMER-KEY FILE STATUS IS CUSTOMER-FILE-STATUS. Internal File Name External DD File Name

  21. DATA DIVISION • Used to create variables and constant fields • Only three data types • numeric PIC 99999. • alphanumeric (text/string) PIC XXX. • alphabetic PIC AAA. • Level numbers indicate subordination of fields. Use levels 01-49 • Alphabetic is seldom used

  22. Level Numbers • Group item – a subdivided field • Elementary item – a non-subdivided field • 01 – Group or independent item • Higher numbers indicate subordinate fields

  23. Level Numbers • 66, 77, 88 have special significance • 66 – Used to rename (no longer used) • 77 – An independent item (choose 01) • 88 – Condition name

  24. Level Numbers 01 XXX. 05 YYY. 10 AAA PIC X. 10 BBB PIC X. 05 ZZZ PIC X(20). 77 AAA PIC 999V99.

  25. Condition Names • 01 TRAN-CODE PIC X. 88 GOOD VALUE ‘G’. 88 BAD VALUE ‘B’. 88 INDIFFERENT VALUE ‘I’. … SET GOOD TO TRUE … IF (GOOD) … Equivalent to MOVE ‘G’ TO TRAN-CODE Equivalent to IF TRAN-CODE = ‘G’

  26. Level 88

  27. Condition Names

  28. Picture Clauses • Picture clause values usually use 9, X, V, S, A • 9 – a decimal digit • X – any alphanumeric character • V – an implied decimal point • S – a sign • A – A-Z, and blank

  29. Picture Clauses • PIC 9(6) • PIC 9(6)V99 • PIC 999999V99 • PICTURE X(10) • PIC XXXXXXXXXX • PIC S9(4)V9(4) • PIC S9999V9999 • PIC 9(18)

  30. Numeric Edited Fields • XXXBXXBXXXX • 99/99/99 • ZZ,ZZZ.99DB • ***,***.99 • ----.99 • $$$9.99 • 99999.99

  31. USAGE Clause • Specifies the format in which data is stored in memory • Normally, the phrase “USAGE IS” is omitted 01 COST USAGE IS PACKED-DECIMAL PIC S9(5). 01 COST PACKED-DECIMAL PIC S9(5). 01 FIRST-NAME USAGE ISDISPLAY PIC X(20). 01 FIRST-NAME PIC X(20).

  32. DATA DIVISION We define data used in input-output operations. FILE SECTION. FD CUSTOMER-FILE. 01 CUSTOMER-MASTER. 05 CUST-NUM PIC 9(2). 05 CUST-FNAME PIC X(20). 05 CUST-LNAME PIC X(20). FD SALES-REPORT. 01 REPORT-AREA PIC X(132).

  33. Data Formats Older terms: Modern terms: • COMPUTATIONAL BINARY • COMP BINARY • COMP-1 FLOATING POINT • COMP-2 FLOATING POINT • COMP-3 PACKED-DECIMAL • COMP-4 BINARY • COMP-5 BINARY (NATIVE) 05 XDATA PIC S9(5) PACKED-DECIMAL. 05 YDATA PIC S9(4) BINARY.

  34. EBCDIC • EBCDIC is an IBM format for storing alphanumeric characters A - X’C1’ J - X’D1’ B - X’C2’ K - X’D2’ S – X’E2’ C - X’C3’ L - X’D3’ T – X’E3’ D - X’C4’ M - X’D4’ U – X’E4’ E - X’C5’ N - X’D5’ V – X’E5’ F - X’C6’ O - X’D6’ W – X’E6’ G - X’C7’ P - X’D7’ X – X’E7’ H - X’C8’ Q - X’D8’ Y – X’E8’ I - X’C9’ R - X’D9’ Z – X’E9’

  35. EBCDIC • EBCDIC is an IBM format for storing alphanumeric characters 0 - X’F0’ SPACE – X’40’ 1 – X’F1’ . - X’4B’ 2 - X’F2’ , - X’6B’ 3 – X’F3’ * - X’5C’ 4 - X’F4’ - - X’60’ 5 – X’F5’ 6 - X’F6’ 7 – X’F7’ 8 – X’F8’ 9 – X’F9’

  36. BINARY DATA • Stored in 2’s Complement format • Leftmost bit is a sign ( 0  +, 1  - ) • If the number is positive, interpret it as plain binary 01011 = 8 + 2 + 1 = + 11 • If the number is negative, compute the complement – Invert. (Change all 1’s to 0’s and 0’s to 1’s.) Add 1. The result is the additive complement

  37. BINARY DATA • 10011 is a negative number. Inverting we have 01100. Adding 1 we have 01100 + 1 = 01101. This is a positive number. 01101  8 + 4 + 1 = 13, so the original number is -13.

  38. BINARY DATA • Declaring a data field as BINARY causes the data to be stored in 2’s complement format. • 01 X-FIELD PIC S9(4) BINARY VALUE -1. • X-FIELD will contain 1111111111111111 = X’FFFF’. • Binary data is processed in a register

  39. PACKED-DECIMAL DATA • Defining a field to be PACKED-DECIMAL or Computational-3 causes the data to be stored internally in a packed decimal format. • There are 2 decimal digits stored in each byte. A sign is stored in the rightmost “nibble”. (C  +, D  -) • Y-FIELD PIC S999 VALUE -23 PACKED-DECIMAL. produces a 2 byte field containing X’023D’ • Most business arithmetic occurs in packed decimal.

  40. Packed No-Sign Data • Packed no-sign data is a non-native data type that was created to save space on a disk when storing dates • If the digits in a date like 10/23/89 were stored in a packed field, the field would require 4 bytes: 01|02|38|9C • By removing the sign, the date fits in 3 bytes: 10|23|89

  41. Packed No-Sign Data • These type fields require special handling in Cobol • Program PKNOSIGN illustrates how a displayable date can be recovered from a packed no-sign field.

  42. ZONED-DECIMAL DATA • A numeric field which is described as DISPLAY, or in which the usage clause is omitted, is stored in a zoned decimal format. • In zoned decimal, each digit takes up one byte, and a sign is stored in the zone portion of the rightmost byte of the field. • Z-FIELD PIC S999 VALUE -32 produces a 3 byte field containing X’F0F3D2’.

  43. ZONED-DECIMAL DATA • Z-FIELD PIC S999 VALUE -32. produces a 3 byte field containing X’F0F3D2’. • Z-FIELD PIC S999 VALUE 32. produces a 3 byte field containing X’F0F3C2’. • W-FIELD PIC 999 VALUE 0. MOVE -32 TO W-FIELD produces a 3 byte field containing X’F0F3C2’.

  44. DATA DIVISION Define the data needed for internal processing in the WORKING-STORAGE SECTION. Storage is statically allocated and exists for the life of the rununit. WORKING-STORAGE SECTION. 01 TOTAL-FIELDS. 05 CUST-TOTAL PIC S9(7)V99 VALUE 0. 05 COST-TOTAL PIC S9(7)V99 VALUE 0. 01 DATE-AND-TIME. 05 CD-YEAR PIC 9999. 05 CD-MONTH PIC 99.

  45. DATA RELATIONSHIPS BINARY PACKED-DECIMAL CHARACTER or ALPHANUMERIC ZONED-DECIMAL

  46. DATA DIVISION • Describe data that exists in another program, or storage you want to associate with a symbolic name in the LINKAGE SECTION. LINKAGE SECTION. 01 LK-DATA-AREA 05 NAME PIC X(40). 05 AGE PIC 999.

  47. DATA DIVISION The LOCAL-STORAGE SECTION is used to have storage allocated each time a program is entered, and deallocated on return from the program. Used for compatibility with C or Java. LOCAL-STORAGE SECTION. 01 CUST-NO PIC X(3). 01 COST PIC 9(5)V99.

  48. Initialization of Storage • WORKING-STORAGE for programs is allocated at the start of the run unit. • Any data items with VALUE clauses are initialized to the appropriate value at that time.

  49. Initialization of Storage • For the duration of the run unit, WORKING-STORAGE items persist in their last-used state. Exceptions are: 1) A program with INITIAL specified in the PROGRAM-ID paragraph In this case, WORKING-STORAGE data items are reinitialized each time the program is entered. IDENTIFICATION DIVISION. PROGRAM-ID. MAIN IS INITIAL. ...

  50. Initialization of Storage • For the duration of the run unit, WORKING-STORAGE items persist in their last-used state. Exceptions are: 2) A subprogram that is dynamically called and then canceled In this case, WORKING-STORAGE data items are reinitialized on the first reentry into the program following the CANCEL. MOVE ‘PROG23’ TO PROGID CALL PROGID CANCEL PROGID CALL PROGID

More Related