![]() |
VOOZH | about |
Cobol is a high-level language, which has its own compiler. The COBOL compiler translates the COBOL program into an object program, which is finally executed. A Syntax refers to the rules and regulations for writing any statement in a programming language. It is related to the grammar and structure of the language.
Cobol is based on an EBCDIC character set which has the following:
The below table describes the code layout, for writing working executable COBOL code.
Columns Number with a record length of 80 bytes:
| S.No | Column specification | Short Description | Description |
|---|---|---|---|
| 1. | 1-6 | Sequence Number | it is used to identify each line of the source program, can contain any character in the system character set |
| 2. | 7 | Reserved for special character |
it is an indicator area used for specifying.
|
| 3. | 8-11 | Area A | Cobol divisions, sections, paragraphs being written in columns 8-11 |
| 4. | 12-72 | Area B | Space for Writing Cobol Statements |
| 5. | 73-80 | System generated Number | For programmer use |
Let's take an example and understand how to COBOL syntax and program works:
Example:
Output:
👁 ImageCOBOL Code Explanation:
JCL for compiling the COBOL:
//JOBNAME JOB ACCTNO,NAME,MSGCLASS=1 //S001 EXEC IGYWCL //COBOL.SYSIN DD DSN = LOCATION_OF_CODE,DISP= SHR //COBOL.SYSLIB DD DSN = COPYBOOK_LOCATION,DISP = SHR //LKED.SYSMOD DD DSN = LOADLIB_PATH(YOUR-PROGRAM-NAME),DISP=SHR
RUN JCL - For running program:
//JOBNAME JOB ACCTNO,NAME,MSGCLASS=1 //* JCL TO RUN COBOL PROGRAM* //STEP01 EXEC PGM= YOUR-PROGRAM-NAME //STPLIB DD DSN = LOADLIB_PATH,DISP=SHR //SYSOUT DD SYSOUT = *