COBOL program format

Source: Internet
Author: User
The format of the COBOL source program is as follows:
Each line starts with a sequence number with six characters. You can enter limit 10 or limit 20 to indicate the rows.
The sequence number area is followed by an indicator area of a character (7th characters), as shown in the first line. You can use "*" and "/" to represent comments, "_" to represent continued rows, and "D" to represent debugging.
The indicator area is followed by four characters (8 ~ Area. You can add the part, section, segment title, segment name, layer indicator, and layer numbers 01 and 77,
Keyword declaratives and end declaratives, program end title.
Area A (after 12 digits) is the statement body, which is called area B. The process statement must start in Area B. Area B is usually 72 or 80 characters in width.
In this example, It is 70 characters long.
Each partition of a blank line is a space.

Id Department (2 ~ (4 rows), the program-ID segment contains the program name, which is required by each program. Other segments such as author are dispensable.

Ministry of Environment (5 ~ 15 rows) to provide external project related to the program. Specifically, it is to list the files used by the program. This parameter can be omitted if not required.
The Ministry of Environment has a configuration section (6 ~ 10 rows) and input/output (11 ~ 15 rows ).
The second line indicates the computer that compiled the program. Compile the debugging line if the with debugging mode is specified.
Row 3 indicates the computer on which the program runs.
Lines 9 and 10 contain a set of specified output styles. Here is the standard output, which can be customized.
The input and output sections are only used for files.
Lines 13th to 15 indicate that if the program uses a file, this section contains a project for each file.
The format of the file control project depends on the description type of the file.

Data Department (16 ~ 22 rows), provide the location where program variables are stored, and divide different data types into different sections: file section ),
Static Data (working-storage section), parameters (Linkage Section), Communication Section ),
Report section ).
FILE Section (18 ~ 21 rows), each file description contains the definition of the file's records, the data in the file section or read from the file,
Or generated by the program that writes the file.
Row 22nd represents the work Storage section, which contains the temporary results required by the program and the data that initializes static data.
A parameter (Linkage Section) contains the data transmitted by the caller (called a parameter in other languages ).
Communication Section, which processes messages between the COBOL program and the communication device.
Report section (report Section) is used to compile the data required by the COBOL reporting tool system.
The PIC in line 20 and 21 is the abbreviation of picture, which indicates defining the data format.
X (12) represents a 12-character string, and 9 (09) represents a 9-digit integer.
A basic project can be a hierarchical structure called a group data item or a group.
The definition of data items in the COBOL program starts from the layer number. layer 01 is the highest level, and layer 49 is the lowest layer.
A 77-tier project is used for data items in a group, such as temporary variables in a program.
Layer 66 is reserved for special descriptor items. You can rename existing data items or groups, or combine them in a way that is not allowed by the original definition.
Layer 88 is reserved for special data project condition names
For example:
03 state PIC xx.
88 new-England values are "1", "2", "3", "4", "5 ".
If new-England... then do something

Process (23 ~ 30 rows), including procedural statements that constitute the program.
Declaratives process. Some programs use special use statements to indicate the process to be executed when special conditions are met,
In the event of an I/O error.
Use statements are combined and placed at the beginning of the process. They are limited by the keywords declaratives and end declaratives.
The 24th rows define a function called ACAB030100-PROC.
Lines 25 and 29 define a flag. You can use the go to statement to jump to this place and execute the following statement.
26th rows print on the screen, equivalent to printf ("ACAB030100-START ");
Row 27th is the call to the ACAB030100-PROC () function.

Requirements of the COBOL program: it must end with an English ending title, Section title, segment name, project, and statement.
When the period is the decimal point, there must be numbers on both sides.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.