[This chapter] [TOC] [Tutorial]
(a) 01 A-RECORD. (b) 03 FIELD-1 PIC XXX. (c) 03 SUB-RECORD. (d) 05 FIELD-2 PIC 999. (e) 05 FIELD-3 PIC X(20). (f) 03 FIELD-4 PIC 9(4).
(a)Level number 01, signals the start of a field and a structure. As this is not a PICTURE description it can only be a structure which is then described in detail in the subsequent lines. A MOVE instruction to and from such an 01 level is considered by the compiler as being an alphanumeric move with length equal to the sum of the length of the subjacent fields. If you use this kind of group level moving, you must be sure that the sending and the receiving structure is subdivided exactly the same way. There is done no conversion between data formats, when moving on the group level.(b)FIELD-1 is an alphanumeric field containing three characters, and is physically placed at the start of the record.(c)As this is not a PICTURE description it can only be a structure which is then described in detail in the subsequent lines. Same ruling applies to rule as for the 01 level above.(d)FIELD-2 is a numeric field containing three characters, without a sign. The field is placed immediately after FIELD-1.(e)FIELD-3 is an alphanumeric field containing 20 characters. The field is placed immediately after FIELD-2.Length of SUB-RECORD is 3 + 20 characters.(f)FIELD-4 is placed outside SUB-RECORD, but inside A-RECORD. A-RECORD is 31 characters long. If one of the numeric fields has had a further type definition (e.g. COMP), this will make calculating the length considerably more difficult as the size of a COMP field is machine-dependent.
[This chapter] [TOC] [Tutorial]
MOVE ZERO TO FIELD-2 IN A-RECORD.This corresponds to the period notation in Pascal. See also MOVE ... CORR ... below.
[This chapter] [TOC] [Tutorial]
77 num-ed pic ---.-9.99. ... move zero to num-ed. display num-ed. result : 0.00 move 125 to num-ed. result : 125.00 move 1.25 to num-ed. result : 1.25 move 1250 to num-ed. result : 1,250.00 move -1250 to num-ed. result : -1,250.00 77 num-ed pic ---.--9Vbb99 blank when zero. ... move zero to num-ed. display num-ed. result : move 125 to num-ed. result : 125 00 77 num-ed pic ***.**9Vbb99 blank when zero. ... move zero to num-ed. display num-ed. result : move 125 to num-ed. result : ****125 00
[This chapter] [TOC] [Tutorial]
01 DETAIL-LINE. 03 FILLER PIC XXX VALUE SPACE. 03 ACCOUNT PIC 99B/B9999 BLANK WHEN ZERO. 03 FILLER PIC XXX VALUE " | ". 03 ACCT-NAME PIC X(20). 03 FILLER PIC X(5) VALUE SPACE. 03 AMOUNT PIC --,---,-9.99.As can be seen from this example the name FILLER appears three times within the same record structure. This is possible because the name FILLER is not "referenceable" in COBOL. In this example the three FILLER fields are used to create space between the printed information.
[This chapter] [TOC] [Tutorial]
01 DETAIL-LINE. 03 FILLER PIC XXX VALUE SPACE. 03 ACCOUNT PIC 99B/B9999 BLANK WHEN ZERO. 03 FILLER PIC XXX VALUE " | ". 03 ACCT-NAME PIC X(20). 03 FILLER PIC X(5) VALUE SPACE. 03 AMOUNT PIC --,---,-9.99.
01 DATA-RECORD. 03 ACCOUNT PIC 9(6) COMP. 03 ACCT-NAME PIC X(20). 03 AMOUNT PIC 9(8)V99.Then it is possible in COBOL to write:
MOVE CORRESPONDING DATA-RECORD TO DETAIL-LINE.This creates a MOVE during the compilation process for all fields with the same name and level number in DATA-RECORD and DETAIL-LINE. The normal rules for automatic data conversion is applied to each field.
[This chapter] [TOC] [Tutorial]