Enterprise COBOL for z/OS, V4.2, Language Reference

ACCEPT statement

The ACCEPT statement transfers data or system date-related information into the data area referenced by the specified identifier. There is no editing or error checking of the incoming data.

Data transfer

Read syntax diagramSkip visual syntax diagram
Format 1: data transfer

>>-ACCEPT--identifier-1--+----------------------------+--------><
                         '-FROM--+-mnemonic-name-1--+-'   
                                 '-environment-name-'     

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 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.

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 an an elementary data item of category national.

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.
  • System input device

    The length of a data transfer is the same as the length of the record on the input device, with a maximum of 32,760 bytes.

    The system input device is read until the receiving area is filled or EOF is encountered. If the length of the receiving area is not an even multiple of the system input device record length, the final record will be truncated as required. If EOF is encountered after data has been moved and before the receiving area has been filled, the receiving area is padded with spaces of the appropriate representation for the receiving area. If EOF is encountered before any data has been moved to the receiving area, padding will not take place and the contents of the receiving area are unchanged. Each input record is concatenated with the previous input record.

    If the input record is of a fixed-length format, the entire input record is used. No editing is performed to remove trailing or leading blanks.

    If the input record is of the variable-length format, the actual record length is used to determine the amount of data received. With variable-format records, the Record Definition Word (RDW) is removed from the beginning of the input record. Only the actual input data is transferred to identifier-1.

    If the data item referenced by identifier-1 is of usage national, data is transferred without conversion and without checking for validity. The input data is assumed to be in UTF-16 format.

  • Console
    1. A system-generated message code is automatically displayed, followed by the literal AWAITING REPLY.

      The maximum length of an input message is 114 characters.

    2. Execution is suspended.
    3. After the message code (the same code as in item 1) is entered from the console and recognized by the system, ACCEPT statement execution is resumed. The message is moved to the receiving area and left-justified regardless of its PICTURE clause.

      If identifier-1 references a data item of usage NATIONAL, the message is converted from the native code page representation to national character representation. The native code page is the one that was specified by the CODEPAGE compiler option when the source code was compiled.

      The ACCEPT statement is terminated if any of the following occurs:

      • No data is received from the console; for example, if the operator hits the Enter key.
      • The receiving data item is filled with data.
      • Fewer than 114 characters of data are entered.

      If 114 bytes of data are entered and the receiving area is still not filled with data, more requests for data are issued to the console.

      If more than 114 characters of data are entered, only the first 114 characters will be recognized by the system.

      If the receiving area is longer than the incoming message, the rightmost characters are padded with spaces of the appropriate representation for the receiving area.

      If the incoming message is longer than the receiving area, the character positions beyond the length of the receiving area are truncated.

    For information about obtaining ACCEPT input from an HFS file or stdin, see Assigning input from a screen or file (ACCEPT) in the Enterprise COBOL Programming Guide.

environment-name
Identifies the source of input data. An environment-name from the names given in Table 1 can be specified.

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

System date-related information transfer

System information contained in the specified conceptual data items DATE, DATE YYYYMMDD, DAY, DAY YYYYDDD, DAY-OF-WEEK, or TIME, can be transferred into the data item referenced by identifier-2. The transfer must follow the rules for the MOVE statement without the CORRESPONDING phrase. See MOVE statement.

Read syntax diagramSkip visual syntax diagram
Format 2: system information transfer

>>-ACCEPT--identifier-2--FROM--+-DATE--+----------+-+----------><
                               |       '-YYYYMMDD-' |   
                               +-DAY--+---------+---+   
                               |      '-YYYYDDD-'   |   
                               +-DAY-OF-WEEK--------+   
                               '-TIME---------------'   

identifier-2
The receiving area. Can be:
  • An alphanumeric group item
  • A national group item
  • An elementary data item of one of the following categories:
    • alphanumeric
    • alphanumeric-edited
    • numeric-edited (with usage DISPLAY or NATIONAL)
    • national
    • national-edited
    • numeric
    • internal floating-point
    • external floating-point (with usage DISPLAY or NATIONAL)

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

Format 2 accesses the current date in two formats: the day of the week or the time of day as carried by the system (which can be useful in identifying when a particular run of an object program was executed). You can also use format 2 to supply the date in headings and footings.

The current date and time can also be accessed with the intrinsic function CURRENT-DATE, which also supports four-digit year values and provides additional information (see CURRENT-DATE).

DATE, DATE YYYYMMDD, DAY, DAY YYYYDDD, DAY-OF-WEEK, and TIME

The conceptual data items DATE, DATE YYYYMMDD, DAY, DAY YYYYDDD, DAY-OF-WEEK, and TIME implicitly have USAGE DISPLAY. Because these are conceptual data items, they cannot be described in the COBOL program.

The content of the conceptual data items is moved to the receiving area using the rules of the MOVE statement. If the receiving area is of usage NATIONAL, the data is converted to national character representation.

DATE
Has the implicit PICTURE 9(6). If the DATEPROC compiler option is in effect, then the returned value has implicit DATE FORMAT YYXXXX, and identifier-2 must be defined with this date format.

The sequence of data elements (from left to right) is:

Two digits for the year
Two digits for the month
Two digits for the day

Thus 27 April 2003 is expressed as 030427.

DATE YYYYMMDD
Has the implicit PICTURE 9(8). If the DATEPROC compiler option is in effect, then the returned value has implicit DATE FORMAT YYYYXXXX, and identifier-2 must be defined with this date format.

The sequence of data elements (from left to right) is:

Four digits for the year
Two digits for the month
Two digits for the day

Thus 27 April 2003 is expressed as 20030427.

DAY
Has the implicit PICTURE 9(5). If the DATEPROC compiler option is in effect, then the returned value has implicit DATE FORMAT YYXXX, and identifier-2 must be defined with this date format.

The sequence of data elements (from left to right) is:

Two digits for the year
Three digits for the day

Thus 27 April 2003 is expressed as 03117.

DAY YYYYDDD
Has the implicit PICTURE 9(7). If the DATEPROC compiler option is in effect, then the returned value has implicit DATE FORMAT YYYYXXX, and identifier-2 must be defined with this date format.

The sequence of data elements (from left to right) is:

Four digits for the year
Three digits for the day

Thus 27 April 2003 is expressed as 2003117.

DAY-OF-WEEK
Has the implicit PICTURE 9(1).

The single data element represents the day of the week according to the following values:

1 represents Monday           5 represents Friday
2 represents Tuesday          6 represents Saturday
3 represents Wednesday        7 represents Sunday
4 represents Thursday

Thus Wednesday is expressed as 3.

TIME
Has the implicit PICTURE 9(8).

The sequence of data elements (from left to right) is:

Two digits for hour of day
Two digits for minute of hour
Two digits for second of minute
Two digits for hundredths of second

Thus 2:41 PM is expressed as 14410000.



Rate this page

[ Index | Table of contents ]