Mastering IBM COBOL Language – Part 1 – FREE TRAINING

This article follows my introduction to the COBOL language. I advise you to reread the first part that deals with the general principles of COBOL. Here: http://128mots.com/index.php/2020/10/07/ibm-cobol/ and English http://128mots.com/index.php/en/2020/10/07/ibm-cobol-3/ (IBM COBOL FREE TRAINING)

Here we discuss the general concepts of the structure of a COBOL program.

DATA DIVISION

All the data that will be used by the program is located in the Data Division. This is where all the memory allowances required by the program are taken care of. This division is optional.

FILE MANAGEMENT:

IBM COBOL TRAINING FREE

FILE SECTION describes data sent or from the system, especially files.

The SYNtax in COBOL is the following

DATA DIVISION.
FILE SECTION.
 FD/SD NameOfFile[RECORD CONTAINS intgr CHARACTERS] 
	[BLOCK CONTAINS intgr RECORDS] 
[DATA RECORD IS NameOfRecord].
	[RECORDING MODE IS {F/V/U/S}]

FD describes the files and SD the sorting files.

FILE IN INPUT

In FILE-CONTROL the statement will be:

           SELECT FMASTER ASSIGN FMASTER
                  FILE STATUS W-STATUS-FMASTER.

If the input file is indexed:
           SELECT FMASTER ASSIGN FMASTER
                  ORGANIZATION IS INDEXED
                  RECORD KEY IS FMASTER-KEY
                  FILE STATUS W-STATUS-FMASTER.

In this case at the file-SECTION level we will have:

      FMAITRE as an appetizer  
       FD FMAITRE.
       01 ENR-FMAITRE.
      Statements from the registration areas

At the JCL level the statement will be of the form:
ENTREE DD DSN-SAMPLE. INPUTF,DISP-SHR
IBM COBOL TRAINING FREE

FILE OUT

The JCL statement will then be:

OUTFILE DD DSN-SAMPLE. OUTPUTF,DISP(,CATLG,DELETE),
LRECL-150,RECFM-FB

RECFM specifies the characteristics of records with fixed length (F), variable length (V), variable length ASCII (D) or indefinite length (U). Records that are said to be blocked are described as FB, VB or DB.

OPENING AND CLOSING FILE IN PROCEDURE DIVISION

COBOL uses PROCEDURE DIVISION mechanisms to perform writing, closing and file openings.

Entry file opening:

OPEN INPUT FICENT

Opening the output file:

OPEN OUTPUT FICSOR

File closure:

CLOSE FICENT
CLOSE FICSOR

File playback:

READ ACTENR
AT END MOVE 'O' TO LAST-RECORD
END-READ

File writing

WRITE SOR-ENR
IBM COBOL TRAINING FREE

EXTERNAL LINKS TO RESOURCES (IBM COBOL FREE TRAINING)

Below are some links that I found interesting that also deal with file management with COBOL.

Example of IBM file management: https://www.ibm.com/support/knowledgecenter/en/SS6SGM_5.1.0/com.ibm.cobol51.aix.doc/PGandLR/ref/rpfio13e.html

REFM Format: https://www.ibm.com/support/knowledgecenter/en/SSLTBW_2.2.0/com.ibm.zos.v2r2.idad400/d4037.htm

Tutorialspoint an article on file management https://www.tutorialspoint.com/cobol/cobol_file_handling.htm

COURSERA COBOL with VSCODE: https://www.coursera.org/lecture/cobol-programming-vscode/file-handling-YVlcf

MEDIUM an interesting article for COBOL beginners: https://medium.com/@yvanscher/7-cobol-examples-with-explanations-ae1784b4d576

Also on his blog: http://yvanscher.com/2018-08-01_7-cobol-examples-with-explanations–ae1784b4d576.html

Many example COBOL free tutorials and sample code: http://www.csis.ul.ie/cobol/examples/default.htm

GITHUB Awesome-cobol https://github.com/mickaelandrieu/awesome-cobol you

IBM COBOL FREE TRAINING

Leave a Reply

Your email address will not be published. Required fields are marked *