COBOL Manual for TNS/E Programs (H06.08+, J06.03+)
response or a response containing only spaces is invalid for a numeric or a numeric edited
accept-name.
If the response to the read operation is not in numeric literal format, the ACCEPT statement
reprompts with:
** Improper numeric value. Resupply input **
If the response is in numeric literal format, the ACCEPT statement converts it to a numeric literal
in an intermediate data item and then moves the value of the intermediate data item to
accept-name. If accept-name has no fractional part, any necessary truncation of the
intermediate data item value deletes the rightmost digits of the value; otherwise, the transfer
of the data from the intermediate item to accept-name follows the rules for the MOVE
statement.
Example 72 ACCEPT Statement Reading From a Terminal
WORKING-STORAGE SECTION.
01 COMMAND-IN PICTURE X(7) VALUE SPACES.
88 ADD-C VALUE "ADD".
88 UPDATE-C VALUE "UPDATE".
88 DELETE-C VALUE "DELETE".
88 EXIT-C VALUE "EXIT".
...
PROCEDURE DIVISION.
...
DISPLAY "ENTER COMMAND"
ACCEPT COMMAND-IN
IF ADD-C ...
In Example 73, the ACCEPT statement reads an alphanumeric value into an accept-name whose
length (60 characters) exceeds the record size of the terminal (40 characters).
Example 73 ACCEPT Statement Reading Alphanumeric Data
WORKING-STORAGE SECTION.
01 HEADING-IN PICTURE X(60) VALUE SPACES.
...
PROCEDURE DIVISION.
...
DISPLAY "Enter heading (up to 60 characters)"
ACCEPT HEADING-IN
DISPLAY HEADING-IN
MOVE HEADING-IN TO HEADING-OUT
...
Figure 12 shows the run-time interactions at the terminal. The user’s responses to the ACCEPT
statement’s prompts are in bold font. When the user enters the fortieth character with no carriage
return, the ACCEPT statement prompts again.
280 Procedure Division Verbs










