ACCEPT Statement - Format 1 - Data Transfer
>>-ACCEPT--identifier-1--+---------------------------------+---->
'-FROM--+-mnemonic-name---------+-'
| (1) |
'-environment-name------'
>--+-----------------+-----------------------------------------><
| (1) |
'-END-ACCEPT------'
Notes:
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.
+-------------------------------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----------------------------+
+-------------------------------IBM Extension--------------------------------+
+----------------------------End of IBM Extension----------------------------+
Related Information:
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:
If the incoming reply is longer than identifier-1, the character positions beyond the length of identifier-1 are truncated.
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.
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.