Rational Developer for System z
COBOL for Windows, Version 7.5, 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

Format 1: data transfer
Read syntax diagramSkip visual syntax diagram>>-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.

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 Btrieve 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:

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

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 run-time 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 Meanings of environment names (Table 5) 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 the COBOL for Windows Programming Guide.

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.

Format 2: system information transfer
Read syntax diagramSkip visual syntax diagram>>-ACCEPT--identifier-2--FROM--+-DATE--+----------+-+----------><
                               |       '-YYYYMMDD-' |  
                               +-DAY--+---------+---+  
                               |      '-YYYYDDD-'   |  
                               +-DAY-OF-WEEK--------+  
                               '-TIME---------------'  
 
identifier-2
The receiving area. Can be:

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 Intrinsic functions).

 

 

 

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.


Terms of use | Feedback

Copyright IBM Corporation 1996, 2008.
This information center is powered by Eclipse technology. (http://www.eclipse.org)