Data transfer

Format 1 transfers data from an input source into the data item referenced by identifier-1 (the receiving area). When the FROM phrase is omitted, the system input device is assumed.

Format 1: data transfer

Read syntax diagramSkip visual syntax diagramACCEPTidentifier-1FROMmnemonic-name-1environment-nameEND-ACCEPT

Format 1 is useful for exceptional situations in a program when operator intervention (to supply a given message, code, or exception indicator) is required. The operator must of course be supplied with the appropriate messages with which to reply.

The input file must be a byte stream file (for example, a file consisting of text data with records delimited by a record terminator). You can create a byte stream file in your COBOL program using line-sequential file I-O or with the DISPLAY statement. (Most text editors can be used to create a byte stream file also.)

The input file cannot be a SdU, SFS, or STL file (including sequential, relative, or indexed files).

If the source of the ACCEPT statement is a file, and the receiving area is filled without using the full record delimited by the record terminator, the remainder of the input record is used in the next ACCEPT statement for the file. The record delimiter characters are removed from the input data before the input records are moved into the receiving area.

If the source for the ACCEPT statement is a keyboard, the data entered at the keyboard followed by the Enter key is treated as the input data. If the input data is shorter than the receiving area, the area is padded with spaces of the appropriate representation for the receiving area.

identifier-1
The receiving area. Can be:
  • An alphanumeric group item
  • A national group item
  • An elementary data item of usage DISPLAY, DISPLAY-1, or NATIONAL

A national group item is processed as an elementary data item of category national.

If the description of identifier-1 contains a TYPE clause, the type-name referenced in that clause must be elementary.

If identifier-1 is of usage NATIONAL and the source of the input data is a keyboard, the input is converted from the native code page (the code page indicated by the runtime locale) to national character representation.

mnemonic-name-1
Specifies the input device. mnemonic-name-1 must be associated in the SPECIAL-NAMES paragraph with an environment-name. See SPECIAL-NAMES paragraph.
environment-name
Identifies the source of input data. An environment-name from the names given in Table 1 can be specified.

ACCEPT with an environment-name uses the source associated with that environment-name by environment variable assignment in the operating environment. If the environment variable that corresponds to the COBOL environment name is not set, ACCEPT from SYSIN or SYSIPT is from the system logical input device; ACCEPT from CONSOLE is from the user's keyboard. For more information about environment variables, see Example: Setting and accessing environment variables in the COBOL for Linux® on x86 Programming Guide.

If the device is the same as that used for READ statements for a LINE SEQUENTIAL file, results are unpredictable.