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.
| Format 1: 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 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.
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.
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 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.
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).
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.
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.
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.
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.
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.
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.
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.