0% found this document useful (0 votes)
403 views42 pages

COBOL

1. Define a JOB card to initiate the compile job. 2. Specify the IGYWCL procedure which contains the compiler JCL. 3. Provide DD statements for the program source code (SYSIN), load module library (PGMLIB), and copy library (COPYLIB). 4. Identify the member name (GOPGM) containing the COBOL source to compile. 5. Submit the JCL to compile the program and generate a load module in the specified library.

Uploaded by

Kiran
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
403 views42 pages

COBOL

1. Define a JOB card to initiate the compile job. 2. Specify the IGYWCL procedure which contains the compiler JCL. 3. Provide DD statements for the program source code (SYSIN), load module library (PGMLIB), and copy library (COPYLIB). 4. Identify the member name (GOPGM) containing the COBOL source to compile. 5. Submit the JCL to compile the program and generate a load module in the specified library.

Uploaded by

Kiran
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 42

COBOL

COBOL: Common Business Oriented Language How many divisions in COBOL? IDENTIFICATION DIVISION ENVIRONMENT DIVISION DATA DIVISION PROCEDURE DIVISION What is the COBOL Language structure? Character -> Word -> Clause -> Statement -> Sentence -> Paragraph -> Section -> Division -> Program COBOL Characters: Digits (0-9), Alphabets (A-Z), Space , Special characters How do you create a member in a dataset? Type in 3.4 in the primary command line Enter the Dataset name

Type E against the Dataset name. Enclose the member name next to the Dataset name Shown below. Press Enter 2 times. Save.

Enter again.

Type SAVE. Press Enter. Insert I in the line command. See below PIC.

COBOL Coding Sheet


Col # 1-6 7 8-11 Purpose Page/Line number Continuity (-), Comment (*), Starting a new page (/), Debugging lines Margin A Division, Section ,paragraph, 01,77 Level numbers Margin B All other declarations/statements begin here Identification field. It will be ignored by the compiler but visible in the source listing.

12-72
73-80

Cobol coding Sheet contains 72 columns.

IDENTIFICATION DIVISION

PARAGRAPH -> SECTION -> DIVISION ( Should start in Margin A, ideally in 8th column) IDENTIFICATION Division contains Paragraphs only. Here in the above example, it contains the following paragraphs Program-id. Author. Installation. Date-written. Date-compiled. Security.

Of all these Paragraph, Program-Id is mandatory paragraph.

ENVIRONMENT DIVISION
Environment Contains 2 sections. Configuration Section Input-Output section Configuration section contains the following paragraphs. SOURCE-COMPUTER OBJECT-COMPUTER SPECIAL-NAMES (Optional from COBOL 85) Input-Output section contains the following paragraphs. FILE-CONTROL I-O CONTROL

ENVIRONMENT DIVISION
Machine dependant division of COBOL program. This division gives information about the source computers on which programs are executed and the results on which results are viewed. When the programs are moved from 3270 terminal to another terminal, the only division that is affected is environment division. Input-Output section: This section contains information about the files to be used in the program (FILE-CONTROL).

10

DATA DIVISION
It contains 3 sections (Important sections) FILE SECTION WORKING-STORAGE SECTION LINKAGE SECTION FILE SECTION: Describes the record structure of the files.. WORKING-STORAGE SECTION. Declare temporary (working) variables. They will extinct as the program execution gets completed. LINKAGE SECTION. Receive data from the JCL OR from another program

11

PROCEDURE DIVISION
Program execution starts from this division. Last statement in the COBOL program is STOP RUN. STOP RUN returns the control to the operating system.

12

1. 2. 3. 4.

Literal: It is a constant and it can be numeric or Non-numeric Numeric literal can hold 18 digits and non-numeric literal can hold 160 characters. Literal stored in a named memory location is called as a variable or Identifier Figurative constant is a COBOL reserved word representing frequently used constants ZERO/ZEROES QUOTE/QUOTES HIGH-VALUE/HIGH-VALUES LOW-VALUE/LOW-VALUES

Example for Literal. 01 WS-DATE PIC X(10) VALUE 2010-10-22 . WS-DATE is a variable ( Named memory location) 2010-10-22 is a literal.

13

Declaration of Variable. Level # Variable Example 01 WS-NAME PIC X(30) VALUE IBM MAINFRAME . PIC clause Value Clause Usage Clause Sync Clause

Level Number: 01 Variable: WS-NAME PIC Clause: X(10) Value Clause: IBM MAINFRAME (Literal Data). What is LEVEL Number? It specifies the hierarchy of data within a record. It can take a value from the set of integers between 01-49 OR from the special level numbers from 66, 77, 88.

14

LEVEL # Meaning 01 02-49 66 It may be either group OR an elementary item. Group OR elementary items within a record. Group items must not have PIC clause. RENAMES clause.

77 88
Examples: 01

Independent data item. Condition names.

WS-DATE. 05 WS-CCYY PIC X(04). 05 FILLER PIC X(01). 05 WS-MM PIC X(02). 05 FILLER PIC X(01). 05 WS-DD PIC X(02). WS-DATE is group item. Doesnt have PIC clause as the elementary items under it have PIC clause.
WS-CCYY, WS-MM & WS-DD are elementary data items dependent on 01 level.
15

Example 2: 01 WS-ARRAY. 02 WS-STD-ID PIC 9(3). 02 WS-STD-MARKS. 05 WS-MATHS PIC 9(3) . 05 WS-CHEM PIC 9(3) . WS-ARRAY is Group item. ( NO PIC clause). Rules for the Variable name: Length = 30 chars; First letter should be alphabet. Hyphen is the only special character allowed and it cannot be first or last letter of the name. Examples #1: WS-STD-MARKS COBOL Data types: Numeric 9 Alphanumeric X Alphabetic A 01 C1 PIC X(10). 01 C2 PIC 9(10) 77 C3 PIC A(10)
16

Memory units:
Bit Nibble: 4 bits Byte: 8 Bits Half Word: 2 Bytes Full Word: 4 Bytes Double word: 8 Bytes A,X,9 will take one Byte.

X(10) How many bytes? : 10 Bytes. 9(10) How many bytes? : 10 Bytes. A How many bytes? : 1 Byte.

17

DAY 2
COMPILE & EXECUTION

18

EDIT SHRDV04.SOURCE(PGM01) - 01.02 Command ===> ****** ***************************** Top of Data ********* 000001 IDENTIFICATION DIVISION. 000002 PROGRAM-ID. PGM01. 000003 PROCEDURE DIVISION. 000004 DISPLAY 'WELCOME TO COBOL' 000005 STOP RUN. ****** **************************** Bottom of Data *******

19

EDIT SHRDV04.SOURCE(COBCOMP) - 01.04 Columns 00001 00072 Command ===> Scroll ===> CSR ****** ***************************** Top of Data ****************************** 000310 //SHRDV04C JOB (ACCINFO),('PROGRAMMER NM'),MSGCLASS=X, 000320 // CLASS=A,MSGLEVEL=(1,1),NOTIFY=&SYSUID 000400 //JOBPROC JCLLIB ORDER=IBMUSER.ALL1 000500 //COBCL EXEC IGYWCL, 000600 // PGMLIB=SHRDV04.LOADLIB, --> LOADLIB NAME 000610 // COPYLIB=SHRDV04.COPYLIB, --> COPYLIB NAME 000700 // GOPGM=PGM01 --> MEMBER NAME 000800 //COBOL.SYSIN DD DSN=SHRDV04.SOURCE(PGM01),DISP=SHR ****** **************************** Bottom of Data ****************************

20

COMPILE JCL
//SHRDV04C JOB (ACCINFO),('PROGRAMMER NM'),MSGCLASS=X, // CLASS=A,MSGLEVEL=(1,1),NOTIFY=&SYSUID The first two lines are known as JOBCARD statements. What is a JCL: JCL: JOB CONTROL LANGUAGE. JCL statements are recognized by // in the first two columns. JCL Coding Sheet: 1-2: // 3-10: Name 11-15: Operation 16: Operands Continuation character: 16th column 3rd column: * indicates that JCL statement is comment. Syntax. //JOBNAME JOB (ACCOUNTING INFO), (PROGRAMMER NAME), Key word parameters Two types of parameters. 1. Positional parameter 2. Keyword parameter Positional Parameters: JOBNAME, ACCOUTING INFO, PROGRAMMER NAME Key word Parameters: MSGCLASS=X, CLASS=A, MSGLEVEL=(1,1),NOTIFY=&SYSUID These parameters have equal symbol in them.

21

COMPILE JCL contd..


//SHRDV04C JOB (ACCINFO),('PROGRAMMER NM'),MSGCLASS=X, // CLASS=A,MSGLEVEL=(1,1),NOTIFY=&SYSUID

MSGCLASS=? (? Can be 0-9 OR A-Z) eg: MSGCLASS=X MSGCLASS=0 MSGCLASS is coded with single alphanumeric character. Each message class is mapped to device OR location where the messages are routed.
In general: MSGCLASS=X (Routes all the messages to SDSF) (Spool Display Screen Facility) MSGCLASS=7 (Routes all the messages to SAR) (Sysout Archival and Retrieval)

CLASS=? (? Can be 0-9 OR A-Z) Every class is assigned one ore more initiators. The jobs are run in initiator address space. One initiator can process one job at a time.

22

COMPILE JCL contd..


//SHRDV04C JOB (ACCINFO),('PROGRAMMER NM'),MSGCLASS=X, // CLASS=A,MSGLEVEL=(1,1),NOTIFY=&SYSUID

MSGLEVEL=(X,Y) (X Can be 0-2 & Y can be 0-1) It is used to control the lists of information appear in the job log. To get maximum information in the listing, code MSGLEVEL=(1,1)
X: Controls the statements 0: Only Job statements 1: JCL, JES statements with expanded procedures 2:Only JCL, JES statements Y: Controls the messages. 0: only step execution messages 1: All JCL, JES, Operator and allocation messages. NOTIFY TSO user id to whom the JOB status should be notified. NOTIFY=&SYSUID will send the notification to the user who submitted the job.
23

COMPILE JCL contd..


//JOBPROC JCLLIB ORDER=IBMUSER.ALL1 //COBCL EXEC IGYWCL, // PGMLIB=SHRDV04.LOADLIB, // COPYLIB=SHRDV04.COPYLIB, // GOPGM=PGM01 JCLLIB ORDER: This statement follows JOB statement. Catalogued procedures in the JOB are searched in the PDS(s) mentioned against JCLLIB ORDER. If they are not found here, they will be checked in the system procedure libraries. Syntax of PROC: //DDNAME EXEC PROC=proc-name OR //DDNAME EXEC proc-name Eg: //COBCL EXEC IGYWCL, Here PROC Name= IGYWCL.
24

COMPILE JCL contd..


//JOBPROC JCLLIB ORDER=IBMUSER.ALL1 //COBCL EXEC IGYWCL, // PGMLIB=SHRDV04.LOADLIB, // COPYLIB=SHRDV04.COPYLIB, // GOPGM=PGM01 Eg: //COBCL EXEC IGYWCL, Here PROC Name= IGYWCL. IGYWCL should be searched in the PDS mentioned against JCLLIB ORDER. IGYWCL should be looked in IBMUSER.ALL1. If IGYWCL is not found in IBMUSER.ALL1 and SYSTEM proc libraries then there will be JCL ERROR with PROC NOT FOUND message.

Symbolic parameters: // PGMLIB=SHRDV04.LOADLIB, // COPYLIB=SHRDV04.COPYLIB, // GOPGM=PGM01 Symbolic parameter values are supplied to the PROC from the JCL otherwise the values 25 will be picked up from the PROC.

COMPILE JCL contd..


Enter the Dataset name.

Type m against the dataset name. ( m: To list members in the PDS). Then Press Enter.

Type L member-name (L: Locate). L IGYWCL will locates the member=IGYWCL. (Press Enter)

26

COMPILE JCL contd..


Type in V or E or B V: View the member E: Edit the member B: Browse the member. Press Enter

//SHRDV04C JOB (ACCINFO),('PROGRAMMER NM'),MSGCLASS=X, // CLASS=A,MSGLEVEL=(1,1),NOTIFY=&SYSUID //JOBPROC JCLLIB ORDER=IBMUSER.ALL1 //COBCL EXEC IGYWCL, // PGMLIB=SHRDV04.LOADLIB, --> LOADLIB NAME // COPYLIB=SHRDV04.COPYLIB, --> COPYLIB NAME // GOPGM=PGM01 --> MEMBER NAME //COBOL.SYSIN DD DSN=SHRDV04.SOURCE(PGM01),DISP=SHR **************************** Bottom of Data **************************** SYSIN: Input program.

27

COMPILE JCL contd..


COBOL Compiler: IGYCRCTL Input: Source Program Output: Object Module COBOL Link Editor: IEWL Input: Object Module Output: Load Module Load module is executable module which will be supplied to RUNJCL to get the results. Machine can understand load modules but not source program (High level Language). How to compile programs.

28

COMPILE JCL contd..


How to compile programs. Mention correct program name, Source PDS name. Type SUB on the primary command line. Press Enter.

Below message will appear, which contains Job ID: Here it is JOB05617. Then press enter.

29

COMPILE JCL contd..


Below message will appear. JOBID: JOB05617 ended at MAXCC=4. MAXCC: Maximum Condition Code. Now go to SPOOL. Type in S;ST. Press Enter.

30

COMPILE JCL contd..


Go to the Latest JOBNAME. OR by looking at the JOB ID. (Use TAB). Type ? Against the JOBNAME which you want to browse through. Press enter.

Type S (Show the details of the DDName). Press enter.

31

To read all the messages page by page, use PF8 PF11 GO to RIGHT PF10 GO TO LEFT M PF8 GO TO the LAST line. M PF7 go to the TOP Page PF3 exit from the current panel.

32

Columns 00001 00072 ===> Scroll ===> CSR ***************************** Top of Data ****************************** //SHRDV04R JOB ,,MSGCLASS=X,CLASS=A,MSGLEVEL=(1,1),NOTIFY=&SYSUID //RUN EXEC PGM=PGM01 --> MEMBER NAME //STEPLIB DD DSN=SHRDV04.LOADLIB,DISP=SHR --> LOADLIB NAME //SYSPRINT DD SYSOUT=* //SYSOUT DD SYSOUT=* //*DD1 DD DSN=IBMUSER.VSAM.RRDS,DISP=SHR //*DD2 DD DSN=IBMUSER.SEQ.FILE1,DISP=SHR //SYSIN DD DUMMY **************************** Bottom of Data ****************************

SHRDV04.SOURCE(COBRUN) - 01.02

33

Similarly SUB the COBRUN (RUN JCL).

34

This program is used to display sum of Two numbers.

35

***************************** Top of Data ********** IDENTIFICATION DIVISION. PROGRAM-ID. PGM02. DATA DIVISION. WORKING-STORAGE SECTION. 01 WS-A PIC 9(2) VALUE 20. 01 WS-B PIC 9(2) VALUE 80. 01 WS-C PIC 9(3) VALUE 0. PROCEDURE DIVISION. COMPUTE WS-C = WS-A + WS-B DISPLAY 'WS-A:' WS-A 'WS-B:' WS-B DISPLAY 'WS-C:' WS-C STOP RUN. **************************** Bottom of Data ******** This program is used to display sum of Two numbers. Result: WS-A: 20 WS-B: 80 WS-C: 100

36

IDENTIFICATION DIVISION. PROGRAM-ID. PGM03. DATA DIVISION. WORKING-STORAGE SECTION. 01 WS-A PIC 9(2) VALUE 20. 01 WS-B PIC 9(2) VALUE 80. 01 WS-C PIC 9(2) VALUE 0. PROCEDURE DIVISION. COMPUTE WS-C = WS-A + WS-B ON SIZE ERROR DISPLAY 'SIZE ERROR'. DISPLAY 'WS-A:' WS-A 'WS-B:' WS-B DISPLAY 'WS-C:' WS-C STOP RUN. **************************** Bottom of Data ******************* Result looks like below:

37

PGM04 is attached here with. To find the biggest of the given three numbers.

C ALL PGM03 PGM04 Change ALL command is used to replace all PGM03 strings to PGM04.

38

PGM04 is attached here with. To find the biggest of the given three numbers.

See the result below.

39

What is LIST PF9 OR SWAP BAR command? LIST PF9 is used to list and swap between the active screens. Type LIST on primary command then press F9 function key.

Two active panels are available. They are ID# 2 & ID # 1. Here 2* says that it is the active 40 panel. To swap among the active screens/panels. Choose S against the active panel.

Here S is chosen against ID# 1. Alternatively I can swap among the active screens by using the following command. Screen Number PF9 Eg: 1 PF9 ( will show the Screen #1) 8 PF9 ( will show the Screen #8)

41

SAREA ( Screen AREA is used to displays this information). It shows the Screen Number: 1

42

You might also like