Boost Your Cobol Skills: Learn How To Read Control Cards And Take Your Programming To The Next Level
What To Know
- A control card is a data structure that is used in a COBOL program to control the sequence of execution of program sections.
- The control card is typically created and maintained by the COBOL programmer, and it is used to control the sequencing of program sections in a COBOL program.
- A Control Card in Cobol is a data structure that specifies the format of the data items in the file, such as data name, length, and format.
If you’re just starting out with COBOL programming, one of the first things you’ll need to get a handle on is how to read control cards. These cards provide important information about the program you’re working on, such as the division and file sections, as well as details about the data elements being processed. In this article, we’ll take a look at how to read control cards in a COBOL program, so you can get started on your journey to becoming a COBOL master!
How To Read Control Card In Cobol Program
A control card is a data structure that is used in a COBOL program to control the sequence of execution of program sections. The control card contains information about the sequence of execution of program sections, and it tells the computer which sections to execute and in what order.
The control card is made up of several fields, including:
* Program Section Name: This field contains the name of the program section that is to be executed.
* Condition Code: This field contains a condition that must be met before the program section is executed.
* Next Program Section: This field contains the name of the program section that is to be executed next.
* Final Program Section: This field contains the name of the program section that is to be executed last.
The control card is typically created and maintained by the COBOL programmer, and it is used to control the sequencing of program sections in a COBOL program.
To read a control card in a COBOL program, you can use the READ statement to read the control card fields. For example, to read the Program Section Name field, you could use the following READ statement:
“`
READ Program_Section_Name.
To read the Condition Code field, you could use the following READ statement:
READ Condition_Code.
To read the Next Program Section field, you could use the following READ statement:
READ Next_Program_Section.
To read the Final Program Section field, you could use the following READ statement:
READ Final_Program_Section.
Once you have read the control card fields, you can use the information in those fields to control the sequence of execution of program sections in your COBOL program.
What Are The Components Of A Control Card In Cobol?
- 1. Control card is the section at the beginning of a COBOL program.
- 2. The control card consists of 6 areas.
- 3. Each area provides specific information to the COBOL compiler.
- 4. The areas are: Identification Division, Environment Division, Data Division, Procedure Division, Files Section, and Closing Section.
- 5. The control card provides information for the program’s name, date, time, and data items.
What Is The Purpose Of A Control Card In A Cobol Program?
The Control Card (C) in a COBOL program is an essential piece. It holds the metadata for the programs, including the program name, data division, file section, and other vital attributes. These attributes include program identification, environment division, file division, working-storage section, and so on.
Program Identification
The Program Identification (PI), as specified in the Environment Division, should be unique for each program. The PI value is generally four characters long, and it should match the one in the Job Control Language (JCL) for the COBOL program. If the PI value in the JCL and COBOL program don’t match, the program will not run.
Environment Division
The Environment Division defines the characteristics of the environment the program will run in. The Environment Division itself has two sections:
1. Environment Section
The Environment Section (ENV) specifies the characteristics specific to the operating environment. This includes things like the version of the COBOL compiler, operating system, and other parameters.
2. Linkage Section
The Linkage Section (LINKAGE SECTION) defines the sections in the COBOL program. It contains pointers to the sections, such as the program’s data division, file division, and working-storage section.
File Division
The File Division (FD) specifies the characteristics of the files used in the program. This includes things like the file-name, record format, and file access method.
How Do You Write A Control Card In Cobol?
A Control Card in Cobol is a data structure that specifies the format of the data items in the file, such as data name, length, and format. The Control Card is used to define the format of data items in an input file, and it can also be used to specify the format of the data items in an output file.
To create a Control Card in Cobol, you first need to define the structure of the data items in the file. You can do this by using a Data Division, where you define the data items and their attributes. Once you have defined the data items, you can create a Control Card by using the PICTURE clause in the File Section.
Here is an example of a Control Card in Cobol:
01 WS-REC.
05 WS-NAME PIC X(20).
05 WS-AGE PIC 9(4) COMP-3.
05 WS-SALARY PIC 9(4) COMP-3.
What Is The Difference Between A 01 Level And A 77 Level Control Card?
A 01 level control card is a control card that does not have a specific level of authority. A 01 level control card is used to give the user access to a specific application or system, but it does not have the same level of authority as a 77 level control card.
A 77 level control card is a control card that has a higher level of security than a 01 level control card. A 77 level control card is used to grant the user access to a wider range of applications and systems, and it also has more authority than a 01 level control card.
A 77 level control card is often used by high-level users, such as system administrators or executives, while 01 level control cards are used by lower-level users, such as employees or contractors.
In summary, the main difference between a 01 level control card and a 77 level control card is that a 77 level control card has more authority and is used to grant access to a wider range of applications and systems.
How Do You Read Data From A Control Card In A Cobol Program?
To retrieve data from a control card in a COBOL program, you can use the “ACCEPT” statement. This statement allows you to read data from an external file, such as a control card, and store it in a COBOL variable.
Here is an example of how to use the “ACCEPT” statement to read data from a control card:
“`
IDENTIFICATION DIVISION.
PROGRAM-ID. read-control-card.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT ID
FROM CONTROL-CARD
WHERE EMP-NUMBER = 12345
DATA DIVISION.
FILE SECTION.
01 ID PIC X(10).
WORKING-STORAGE SECTION.
01 emp-number PIC 9(4).
PROCEDURE DIVISION.
PERFORM accept-card-data
UNTIL end-of-file.
Wrap-Up
In conclusion, understanding control cards in Cobol programs is a critical skill for any programmer working with the language. By taking the time to learn how to read and interpret them, you can unlock the full potential of your programs and streamline your development process. So whether you’re a beginner or an experienced programmer, mastering control cards will enable you to write more efficient and maintainable Cobol code. Happy coding!