skip to main content

Procedure Division Statements : WRITE

WRITE
General Format
Format 1
WRITE { Record-Name-1    } [ FROM {Identifier-1}  ]
      { FILE File-Name-1 }        {Literal-1   }
  [ {BEFORE} ADVANCING { Identifier-2    [LINE ] } ]
    {AFTER }           { Integer-1       [LINES] }
                       { PAGE                    }
  [ AT {END-OF-PAGE} Imperative-Statement-1 ]
       {EOP        }
  [ NOT AT {END-OF-PAGE} Imperative-Statement-2 ]
           {EOP        }
  [END-WRITE]
Format 2
WRITE { Record-Name-1    } [ FROM {Identifier-1}  ]
      { FILE File-Name-1 }        {Literal-1   }
  [ INVALID KEY Imperative-Statement-1 ]
  [ NOT INVALID KEY Imperative-Statement-2 ]
  [END-WRITE]
Format 3
WRITE { Record-Name-1    } [ FROM {Identifier-1}  ] WITH NO {CONTROL   } [ SIZE Identifier-3 ]
      { FILE File-Name-1 }        {Literal-1   }            {CONVERSION}
Syntax rules
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
General rules
All Files
1.
2.
A.
 
MOVE identifier-1 TO record-name-1
 
or
 
MOVE literal-1 TO record-name-1
 
according to the rules specified for the MOVE statement.
B.
3.
4.
 
— The statement:
 
MOVE identifier-1 TO implicit-record-1
 
or
 
MOVE literal-1 TO implicit-record-1
 
— The statement:
 
WRITE implicit-record-1
 
where implicit-record-1 refers to the record area for file-name-1 and is treated:
A.
B.
C.
5.
6.
7.
8.
9.
 
NOTE - Logical records in relative and sequential files may have a length of zero. Logical records in an indexed file shall always be long enough to contain the record keys.
10.
11.
Sequential and Print Files
12.
13.
14.
15.
16.
A.
B.
C.
D.
E.
F.
G.
17.
18.
A.
B.
19.
A.
20.
21.
22.
23.
24.
Relative Files
25.
A.
B.
26.
27.
28.
29.
A.
B.
Indexed Files
30.
31.
32.
33.
34.
35.
36.
37.
A.
B.
C.
D.
Examples
Format 1 - Print last lines to a page and advance 1 page
write report-line from page-subtotal-1-line after advancing 2 lines
write report-line from page-subtotal-2-line after advancing 2 lines
write report-line from page-total-line before advancing page
Format 2 - Write record validating invalid key
move 1234 to cust-code
move "Adam Smith" to cust-name
write cust-rec
      invalid key display message "Invalid Customer Key : " cust-code
      not invalid key display message "Customer saved!"

Copyright (c) 2017 Veryant
Contact us
Please share your comments on this manual or on any
Veryant product documentation with the email button at the top left