Академический Документы
Профессиональный Документы
Культура Документы
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
*CBL TRUNC(BIN)
IDENTIFICATION DIVISION.
PROGRAM-ID. XXXXXXXX. (Program Name - 8 Characters are identified by
compiler. Rest ignored)
* AUTHOR. <Comment Entry>.
* INSTALLATION. <Comment Entry>.
* DATE-WRITTEN. <Comment Entry>.
* DATE-COMPILED. <Comment Entry>.
* SECURITY. <Comment Entry>.
PROCEDURE DIVISION.
IDENTIFICATION DIVISION.
PROGRAM-ID. XXXXXXXX.
AUTHOR.
DATE-WRITTEN.
DATE-COMPILED.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER.
OBJECT-COMPUTER.
SPECIAL-NAMES.
CURRENCY SIGN IS ..
DECIMAL-POINT IS ..
CLASS XYZ IS ..
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT FILE-NAME1 ASSIGN TO DDNAME1
ORGANIZATION IS SEQUENTIAL/INDEXED/RELATIVE
ACCESS MODE IS SEQUENTIAL/RANDOM/DYNAMIC RELATIVE KEY IS <>
FILE STATUS IS FILE-STATUS
RECORD KEY IS FILE-KEY
ALTERNATE RECORD KEY IS <> WITH DUPLICATES.
SELECT FILE-NAME2 ASSIGN TO DDNAME2
ORGANIZATION IS INDEXED
ACCESS MODE IS SEQUENTIAL
FILE STATUS IS FILE-STATUS
RECORD KEY IS FILE-KEY.
I-O-CONTROL.
DATA DIVISION.
FILE SECTION.
FD/SD FILE-NAME1
RECORDING MODE IS F/V/U/S
LABEL RECORDS ARE STANDARD
RECORD CONTAINS 10 CHARACTERS
BLOCK CONTAINS 0 RECORDS
DATA RECORD IS DATA-RECORD1.
01 DATA-RECORD1.
05 DATA-RECORD1-ID PIC X(01).
05 DATA-RECORD1-DATA PIC X(99).
FD FILE-NAME2
RECORDING MODE IS F
LABEL RECORDS ARE STANDARD
BLOCK CONTAINS 0 RECORDS
DATA RECORD IS DATA-RECORD2.
01 DATA-RECORD2 PIC X(100).
WORKING-STORAGE SECTION.
LINKAGE SECTION.
Identification Division.
Program-id.
Author.
Date-written.
Date-compiled.
Environment Division.
Configuration Section.
Source-computer.
object-computer.
special-names.
class
decimal-point is
currency sign is
input-output section.
file-control.
select file-name assign to ddname
organization is indexed
access mode is sequential
file status is file-status
record key is file-key.
i-o-control.
Data Division.
File Section.
Working-Storage Section.
Linkage Section.
Procedure Division.
Literal - Constant that can be numberic (18 digits) or non-numeric (160 characters)
Identifier/Variable - Named Memory Location which stores the Literal
Figurative Constants - Sub-set of Reserved Words in Cobol that are used frequently
- Literals as well
ZERO/ZEROS/ZEROES/QUOTE/QUOTES/SPACE/SPACES/ALL/HIGH-VALUE/HIGH-VALUES/LOW-
VALUE/LOW-VALUES
Identifier/Variable - WS-VARIABLE
Constant
Literal - ABCD (Non-Numeric)
VARIABLE
Name can have upto 30 characters with atleast 1 alphabet and may have hyphen
special char (not first or last).
It should be unique within a record (Level# 01). "OF" qualifier to be used for
same names in different records.
FILLER
Items cannot be initialized or used in any operation of the Procedure division.
PICTURE-CLAUSE:
NUMERIC:
9 - Digit
V - Implied Decimal Point
S - Sign
P - Assumed Decimal Point when point lies outside the data item
NUMERIC EDITS:
+ - Plus Sign
- - Minus Sign
CR - Credit Sign
DB - Debit Sign
. - Period
b - Blank
, - Comma
0 - Zero
/ - Slash
BLANK WHEN ZERO - Insert blank when data value is 0
Z - Zero Suppression
* - Asterisk
$ - Currency Sign
NON NUMERIC:
A - Alphabet
B - Blank Insertion Char
X - Alpha Numeric
G - DBCS (Double Byte Character Set)
EXCLUSIVE SETS:
+ - CR DB
V .
$ + - Z * ($***.**)
VALUE-CLAUSE: initializing data-items in w-s-section. Value of items must not
exceed Picture size. Not defined for Variable size.
VALUE IS literal.
VALUE IS literal-1 THRU/THROUGH literal-2.
VALUE IS literal-1, literal-2.
literals - Numeric without quotes, Non-Numeric with quotes, Figurative Constants.
USAGE CLAUSE:
DISPLAY Default. No of Bytes required equals to size of data item.
COMP Binary representation of data item.
PIC can contain S and 9 only.
S9(01) - S9(04) - Half Word
S9(05) - S9(09) - Full Word
S9(10) - S9(18) - Double Word
COMP-1 Single Word floating point item.
PIC clause should not be specified.
Sign is First Bit of left most Byte.
Exponent is remaining 7 Bits of First Byte.
Mantissa is last 3 Bytes.
COMP-2 Double Word floating point item.
PIC clause should not be specified.
Sign is First Bit of left most Byte.
Exponent is remaining 7 Bits of First Byte.
Mantissa is last 7 Bytes.
COMP-3 Packed Decimal representation of data item.
Each digit takes half byte.
"PIC 9(N) COMP-3" would take (N+1)/2 bytes.
Sign is stored separately in rightmost half-byte regardless of whether "S" is
specified or not.
C - Signed +ve
D - Signed -ve
F - Unsigned +ve
INDEX Used to preserve Index value of an array.
4 Bytes. PIC Clause should not be specified.
When specified for a Group item, it applies to all elementary items but not
the Group item itself.
POINTER 4 Byte Elementary item.
Can be used in SET stmnt, Relation condt, USING phrase of CALL stmnt, ENTRY
stmnt or Procedure Div stmnt.
Value Clause can contain only NULL/NULLS.
SET pointer-1 TO ADDRESS OF pointer-2
SET ADDRESS OF pointer-2 TO pointer-1
pointer-1 is POINTER data item
pointer-2 is Linkage Section item
SYNC CLAUSE:
Specified with COMP, COMP-1, COMP-2 items.
Start at half/full/double word boundaries for faster address resolution.
Starting address of Full-Word should end with 0,4,8,C
Starting address of Half-Word should end with 0,2,4,8,A,C,E
may introduce slack bytes (unused bytes) before Binary Items
CONDITION: (88 Level) - Set to TRUE will allocate first value to the variable.
JUSTIFIED RIGHT:
Specified with X/A itesm for right justification. Cannot be used with 66 & 88
level items.
OCCURS CLAUSE:
User to define an array / allocate physically contiguous memory locations to store
table values and access them with subscript/index.
LINKAGE SECTION:
Access data that is external to the program
100 chars thru Parm of JCL
32K characters from another Program
Lenght field defined as HALF WORD BINARY is needed as first field.
05 WS-DATE-TIME.
10 WS-ABSTIME PIC S9(15) COMP-3.
10 WS-TIME.
15 WS-TIME-HM.
20 WS-TIME-HM-HH PIC 99.
20 FILLER PIC X.
20 WS-TIME-HM-MM PIC 99.
15 FILLER PIC X.
15 WS-TIME-SS PIC 99.
10 WS-MDY.
15 WS-MDY-MM PIC 9(02).
15 FILLER PIC X(01).
15 WS-MDY-DD PIC 9(02).
15 FILLER PIC X(01).
15 WS-MDY-YY PIC 9(02).
01 WS-TIME.
05 WS-TIME-HH PIC 99.
05 WS-TIME-MM PIC 99.
05 WS-TIME-SS PIC 99.
05 FILLER PIC XX.
01 WS-DATE.
05 WS-DATE-YY PIC 99.
05 WS-DATE-MM PIC 99.
05 WS-DATE-DD PIC 99.
DATE - YYMMDD
DAY - YYDDD
TIME - HHMMSSTT
DAY-OF-WEEK - 1-7 (Mon-Sun)
STOP RUN - Last executable stmnt of Main Program - Returns control back to OS
EXIT PROGRAM - Last executable stmnt of Sub Program - Returns control back to Main
Program
GOBACK - can be coded in Main program as well as Sub program - Returns control back
to wehere it received from