สำหรับ COBOL ใน Mainframe จะต้องมีโครงสร้าง column เข้ามาร่วมด้วย ดังนี้
- column 1-6 เป็น sequence number
- column 7 ไว้ใส่ตัวอักษรที่มีความหมายพิเศษ
- * แสดงว่าบรรทัดนั้นเป็น comment
- - แสดงว่าบรรทัดนี้ต่อมาจากบรรทัดข้างบน
- column 8-11 เป็น area A ซึ่งไว้ใส่ division ในโปรแกรม
- column 12-72 เป็น area B ไว้ใส่ code อื่นๆ นอกจาก division
- column 73-80 เป็น optional ที่แสดง program identification or comments
IDENTIFICATION DIVISION.
PROGRAM-ID ProgName.
[AUTHOR Desc.]
[INSTALLATION Desc.]
[DATE-WRITTEN Desc.]
[DATE-COMPILED Desc.]
[SECURITY Desc.]
[ENVIRONMENT DIVISION.
[INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT FileName
[ASSIGN [TO] DISK|PRINTER.]
[ORGANIZATION IS SEQUENTIAL|LINE SEQUENTIAL|RELATIVE|INDEXED.]
[ACCESS MODE IS SEQUENTIAL|RANDOM|DYNAMIC.]]]
DATA DIVISION.
[FILE SECTION.
FD FileName [RECORD MODE [IS] BINARY|DECIMAL LOW|HIGH|HYPER DENSITY]
LABEL RECORD|RECORDS IS|ARE STANDARD|OMITTED
[VALUE OF FILE-ID IS [DataName |Literal ]
[BLOCK CONTAINS Integer CHARACTERS|RECORDS]
[RECORD CONTAINS Integer CHARACTERS]
[DATA RECORD IS|RECORDS ARE DataName1[, DataName2, ...]]
[LevelNo DataName |FILLER
[REDEFINES DataName ]
[PIC|PICTURE [IS] Pattern ]
[OCCURS [Interger TO] Integer TIMES
[DEPEND ON DataName1 ]
[ASCENDING|DESCENDING [KEY] [IS] DataName2 [, DataName3, ...]]
[INDEXED [BY] IndexName1 [, IndexName2, ...]]
[RENAMES DataName [THRU DataName2 ]]
[VALUE [IS|ARE] Literal1 [THRU Literal2 ] [Literal3 [THRU Literal4]] ...
[JUST|JUSTIFIED RIGHT]
[SIZE [IS] Integer CHARACTERS|DIGITS]
[CLASS [IS] NUMERIC|ALPHABETIC|ALPHANUMERIC]
[USAGE [IS] COMP|COMPUTATIONAL 1|COMP-1|COMPUTATION-1|DISPLAY|INDEX]
[BLANK WHEN ZERO]]
WORKING-STORAGE SECTION.
[77 DataName PIC|PICTURE [IS] Pattern.]
...
[LevelNo DataName |FILLER
[REDEFINES DataName ]
[PIC|PICTURE [IS] Pattern ]
[OCCURS [Interger TO] Integer TIMES
[DEPEND ON DataName1 ]
[ASCENDING|DESCENDING [KEY] [IS] DataName2 [, DataName3, ...]]
[INDEXED [BY] IndexName1 [, IndexName2, ...]]
[RENAMES DataName [THRU DataName2 ]]
[VALUE [IS|ARE] Literal1 [THRU Literal2 ] [Literal3 [THRU Literal4]] ...
[JUST|JUSTIFIED RIGHT]
[SIZE [IS] Integer CHARACTERS|DIGITS]
[CLASS [IS] NUMERIC|ALPHABETIC|ALPHANUMERIC]
[USAGE [IS] COMP|COMPUTATIONAL 1|COMP-1|COMPUTATION-1|DISPLAY|INDEX]
[BLANK WHEN ZERO]]
...
[LINKAGE SECTION.
[77 DataName PIC|PICTURE [IS] Pattern.]
...
[LevelNo DataName |FILLER
[REDEFINES DataName ]
[PIC|PICTURE [IS] Pattern ]
[OCCURS [Interger TO] Integer TIMES
[DEPEND ON DataName1 ]
[ASCENDING|DESCENDING [KEY] [IS] DataName2 [, DataName3, ...]]
[INDEXED [BY] IndexName1 [, IndexName2, ...]]
[RENAMES DataName [THRU DataName2 ]]
[VALUE [IS|ARE] Literal1 [THRU Literal2 ] [Literal3 [THRU Literal4]] ...
[JUST|JUSTIFIED RIGHT]
[SIZE [IS] Integer CHARACTERS|DIGITS]
[CLASS [IS] NUMERIC|ALPHABETIC|ALPHANUMERIC]
[USAGE [IS] COMP|COMPUTATIONAL 1|COMP-1|COMPUTATION-1|DISPLAY|INDEX]
[BLANK WHEN ZERO]]
...]
[SCREEN SECTION.
LevelNo [ScreenName] [BLANK-SCREEN]
[LINE [NUMBER] [IS] [PLUS] Integer]
[LINE [NUMBER] [IS] [PLUS] Integer]
[BLANK LINE]
[BELL] [HIGHLIGHT|BLINK]
[VALUE [IS] Literal | PIC|PICTURE [IS] Pattern FROM Literal2 | Identifier1 |TO Identifier2 |USING Identifier3
[BLANK WHEN ZERO]
[JUST|JUSTIFIED RIGHT]
[AUTO]
[SECURE]]
PROCEDURE DIVISION.
ParagraphName1.
Statement.
....
No comments:
Post a Comment