Structure d'un programme COBOL

Comprendre l'organisation hiérarchique

Un programme COBOL se décompose en divisions qui contiennent plusieurs sections, qui elles-mêmes sont formées de paragraphes.

Et comme dans la langue française, un paragraphe est composé d'une étiquette et de phrases ! Et cette fois-ci, comme en français, chaque phrase finit par un point.

Voici un schéma qui vous récapitule cela de manière très simpliste :

Hiérarchie COBOL

Division
Section
Paragraphe
Phrase

Exemple en code

IDENTIFICATION DIVISION.
PROGRAM-ID. MON-PROGRAMME.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 VARIABLE-1 PIC X(10).
PROCEDURE DIVISION.
DEBUT-PROGRAMME.
DISPLAY "BONJOUR LE MONDE".

Légende

Division
Section
Paragraphe
Phrase

Analogie avec la langue française

Français

  • • Chapitre (Division)
  • • Section (Section)
  • • Paragraphe (Paragraphe)
  • • Phrase (Instruction)

COBOL

  • • Division (Chapitre)
  • • Section (Section)
  • • Paragraphe (Paragraphe)
  • • Instruction (Phrase)

Comme en français, chaque instruction COBOL se termine par un point, tout comme une phrase se termine par un point.

COBOL suit une structure hiérarchique claire, similaire à l'organisation d'un document écrit