社員一覧表を出力するプログラムです。
元のソースコード
******************************************************************
* Author:
* Date:
* Purpose:
* Tectonics: cobc
******************************************************************
IDENTIFICATION DIVISION.
PROGRAM-ID. TESTCOBOL6.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT EMPF ASSIGN TO 'EMPFILE'
ORGANIZATION INDEXED
ACCESS MODE IS SEQUENTIAL
RECORD KEY IS EMPKEY.
SELECT PRINTF ASSIGN TO 'EMPDATA.TXT'.
DATA DIVISION.
FILE SECTION.
FD EMPF.
01 EMPF-REC.
03 EMPKEY PIC X(3).
03 EMPNO REDEFINES EMPKEY
PIC 9(3).
03 EMPNAME PIC X(10).
FD PRINTF.
01 PRINT-REC PIC X(22).
WORKING-STORAGE SECTION.
01 PRINT-H.
03 FILLER PIC X(10) VALUE "社員番号".
03 FILLER PIC X(10) VALUE "社員名".
03 FILLER PIC XX VALUE X"0D0A".
01 PRINT-D.
03 FILLER PIC X(2) VALUE SPACE.
03 EMPKEY-P PIC X(3).
03 FILLER PIC X(5) VALUE SPACE.
03 EMPNAME-P PIC X(10).
03 FILLER PIC XX VALUE X"0D0A".
77 END-F PIC X.
77 人数 PIC ZZZ.
77 NIN PIC 999.
PROCEDURE DIVISION.
MAIN-PROCEDURE.
DISPLAY "社員一覧表出力中"
OPEN INPUT EMPF
OUTPUT PRINTF.
WRITE PRINT-REC FROM PRINT-H.
PERFORM UNTIL END-F = "E"
READ EMPF AT END
MOVE "E" TO END-F
NOT AT END
DISPLAY NIN
ADD 1 TO NIN
MOVE EMPKEY TO EMPKEY-P
MOVE EMPNAME TO EMPNAME-P
WRITE PRINT-REC FROM PRINT-D
END-READ
END-PERFORM.
MOVE NIN TO 人数.
DISPLAY "社員は" 人数 "人".
CLOSE EMPF PRINTF.
STOP RUN.
END PROGRAM TESTCOBOL6.
フローチャート図で表現したもの
%%{init: {'theme':'base','themeVariables':{
'primaryColor':'white',
'primaryTextColor':'#000000',
'primaryBorderColor':'#000000',
'lineColor':'#000000',
'textColor':'#6A7FABCC',
'fontSize':'15px'}}}%%
%%{ init: { 'flowchart': { 'curve': 'basis' } } }%%
graph TD;
classDef default fill:#FFFFE0,stroke:#333,stroke-width:2px;
classDef clrPattern1 fill:#FFFF00,stroke:#333,stroke-width:2px;
classDef clrPattern2 fill:#FFA500,stroke:#333,stroke-width:2px;
classDef clrPattern3 fill:#ADFF2F,stroke:#333,stroke-width:2px;
classDef clrPattern4 fill:#FFC0CB,stroke:#333,stroke-width:2px;
classDef clrPattern5 fill:#FFC0CB,stroke:#333,stroke-width:2px;
linkStyle default stroke:#000000,stroke-width:2px;
s(処理開始)-->
%%データ定義
22[/" 【出力】
46: DISPLAY ゛社員一覧表出力中゛"/]:::clrPattern3
23[/" 【入力】
47: OPEN INPUT EMPF
OUTPUT PRINTF
"/]:::clrPattern4
24[/" 【出力】
48: WRITE PRINT-REC
FROM PRINT-H
"/]:::clrPattern3
25[/" 【繰返し文開始】
49: PERFORM UNTIL EN
D-F = ゛E゛
"\]:::clrPattern2
28{"50:
READ文開始"}:::clrPattern1
30["51: MOVE ゛E゛ TO END-F"]
31["52: NOT AT END"]
32["53: ADD 1 TO NIN"]
33["54: MOVE EMPKEY TO
EMPKEY-P
"]
34["55: MOVE EMPNAME TO
EMPNAME-P
"]
35[/" 【出力】
56: WRITE PRINT-REC
FROM PRINT-D
"/]:::clrPattern3
36(("【READ文終了】
57: END-READ"))
37[\"58:繰返文終了"/]:::clrPattern2
38["59: MOVE NIN TO 人数"]
39[/" 【出力】
60: DISPLAY ゛社員は゛ 人数 ゛人゛"/]:::clrPattern3
40[/" 【CLOSE文】
61: CLOSE EMPF PRINTF"/]:::clrPattern3
%%ルート
22-->23
23-->24
24-->25
25-->|ループ開始|28
28-->|読み込み終了時の処理|30
28-->|読み込み実行時の処理|31
30-->36
31-->32
32-->33
33-->34
34-->35
35-->36
36-->37
37-->|ループ終了|25
37-->|ループ継続|38
38-->39
39-->40
style sg1 color:red,fill-opacity:0, stroke-opacity:0;
subgraph sg1["READ EMPF AT END"]
28
end