ILE COBOL Language Reference

Format 1 - Data Transfer

ACCEPT Statement - Format 1 - Data Transfer
 
>>-ACCEPT--identifier-1--+---------------------------------+---->
                         '-FROM--+-mnemonic-name---------+-'
                                 |                  (1)  |
                                 '-environment-name------'
 
>--+-----------------+-----------------------------------------><
   |            (1)  |
   '-END-ACCEPT------'
 
 

Notes:

  1. IBM Extension

Format 1 transfers data from an input device into identifier-1. Incoming data is transferred as a character string aligned on the leftmost character position. No data conversion will occur. If the size of identifier-1 is greater than the record length of the input device, then additional data will be requested after the transfer of one record has been completed. The additional data will be transferred into identifier-1 starting at the position immediately to the right of the last character previously transferred from the device. This process will continue until identifier-1 has been filled. If on any transfer the device record holds more characters than are needed to fill identifer-1, then the excess data will be truncated.

Since all data is transferred as a character string, identifier-1 will normally be defined, explicitly or implicitly, with usage DISPLAY. The ACCEPT statement will, however, handle data in other formats, provided it is possible to enter the data on the input device in a format that corresponds to the internal representation of identifier-1.

Format 1 is useful for exception 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 data item.

+-------------------------------IBM Extension--------------------------------+

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

Identifier-1 may be defined with usage DISPLAY-1, that is, it may be a DBCS or DBCS-edited item. The data on the input device must then be delimited by a shift-out and a shift-in character; these will be removed when the data is transferred.

Identifier-1 may also be defined as a NATIONAL item. The data accepted will be converted from the code set specified by the job's current CCSID.

Identifier-1 may not be a date, time, or timestamp item.

+----------------------------End of IBM Extension----------------------------+

mnemonic-name
Must be specified in the SPECIAL-NAMES paragraph, where it will be associated with an environment-name that refers to an input device. The input device can be the workstation used by an interactive job, the job input stream of a batch job, or the system operator's console.

+-------------------------------IBM Extension--------------------------------+

environment-name
The environment-name CONSOLE or SYSIN may be specified in place of a mnemonic-name.

+----------------------------End of IBM Extension----------------------------+

Related Information:

Source of Input Data

The source of input data is dependent upon the type of program initiation as follows:

Method of Program Initiation Data Source (Input Device)
When Associated with Environment-Name When FROM Phrase Omitted
CONSOLE or SYSTEM-CONSOLE SYSIN or REQUESTOR
BATCH System operator's message queue Job input stream Job input stream
INTERACTIVE System operator's message queue Workstation Workstation

The job input stream consists of data that accompanies a CL command. If there is no data in the input stream, or if there is insuffient data to fill identifier-1, an exception occurs.

When the input is from the job input stream, the following rules apply:

When the device is the workstation, the input record size is 100. When the device is the system operator's message queue, the input record size is 58. The following steps occur:

  1. A system-generated inquiry message containing the program-name, the text "AWAITING REPLY FOR POSITION(S)", and the beginning and ending positions is automatically sent to the system operator's message queue or workstation operator. Previous DISPLAYs can also appear on the ACCEPT screen.
  2. Processing is suspended.
  3. The reply is moved into identifier-1, and processing is resumed after a reply is made by the operator to the inquiry in step 1. The reply value is made available to the program as it was typed, in uppercase or lowercase.
  4. If identifier-1 is longer than the input record size, succeeding input records are read (steps 1-3) until identifier-1 is filled.

If the incoming reply is longer than identifier-1, the character positions beyond the length of identifier-1 are truncated.

Note:
If the device is the same as that used for READ statements, results are unpredictable.

Coding Example

The following is an example of a batch job file member that contains a job input stream:

      //BCHJOB   JOB(ADD021) JOBD(QUSER/ACCTEST)
      CALL       PGM(QSYS/ACCPT1X)
      123456789012345
      //ENDBCHJOB

The following is an example of a COBOL program that uses a Format 1 ACCEPT statement to read the job input stream:

        IDENTIFICATION DIVISION.
        PROGRAM-ID. ACCPT1X.
        ENVIRONMENT DIVISION.
        CONFIGURATION SECTION.
        SOURCE-COMPUTER. IBM-ISERIES.
        OBJECT-COMPUTER. IBM-ISERIES.
        DATA DIVISION.
        WORKING-STORAGE SECTION.
        77  TRANS-DATA   PIC X(15).
        PROCEDURE DIVISION.
        BEGIN.
            ACCEPT TRANS-DATA.
            DISPLAY TRANS-DATA.
            STOP RUN.

When the batch job file member is used to call ACCPT1X, the ACCEPT statement reads the batch job file member from the line that immediately follows the CALL command. This causes "123456789012345" to be accepted into TRANS-DATA.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]