ACCEPT . . . FROM Statement COBOL

The ACCEPT . . . FROM statement causes low volume data to be made available to the specified data item.

Format 1: Accept From System-Name

Accept From System-Name

Data is transferred from the standard input device into the data item referred to by identifier-1 . The FROM phrase may affect which input device is used. If mnemonic-name-3 is used in the FROM phrase, it must have been defined in the SPECIAL-NAMES paragraph of the Environment Division with the low-volume-I-O-name-1 IS mnemonic-name-3 clause. The associated low-volume-I-O-name-1 must be CONSOLE or SYSIN.

Note:If identifier-1 is numeric or justified right and the FROM phrase is not specified, the Format 1 ACCEPT statement is treated as if it were a Format 3 ACCEPT statement with the CONVERT phrase. A compiler option suppresses this modification.

If the size of the receiving data item—or the portion of the receiving data item not yet occupied by transferred data—exceeds the size of the transferred data, the transferred data is stored aligned to the left in the receiving data item (or that portion not yet occupied), and additional data is accepted from the keyboard.

If the size of the transferred data exceeds the size of the receiving data item—or the portion of the receiving data item not yet occupied by transferred data—only the leftmost characters of the transferred data are stored in the receiving data item (or the remaining portion). The remaining characters of the data that do not fit into the receiving data item are discarded.

ACCEPT . . . FROM CONSOLE is treated as if CONSOLE IS CONSOLE was specified in the SPECIAL-NAMES paragraph if CONSOLE has not been otherwise defined.

ACCEPT . . . FROM SYSIN is treated as if SYSIN IS SYSIN was specified in the SPECIAL-NAMES paragraph if SYSIN has not been otherwise defined.

Format 2:Accept From Implicit Definition

Accept From Implicit Definition

For any single Format 2 ACCEPT statement execution, the runtime ensures the consistency of the data returned for cases when the result might be affected by a boundary condition. For example, the runtime guarantees for the DATE-AND-TIME option that the time and date agree when the time is just before or just after midnight. On the other hand, when the DATE and TIME options are used in separate ACCEPT statements near midnight, the program will obtain an inconsistent set of values that is nearly 24 hours off when considered as a pair if midnight occurs between the two ACCEPT statements.

The information requested is transferred according to the rules of the MOVE statement. CENTURY-DATE, CENTURY-DAY, DATE, DATE-AND-TIME, DATE-COMPILED, DAY, DAY-AND-TIME, DAY-OF-WEEK, ESCAPE KEY, EXCEPTION STATUS, and TIME are implicitly defined data items and, therefore, are not described in the program.

CENTURY-DATE is made up of the data elements year, month, and day. The sequence is YYYYMMDD; thus, a current date of July 1, 2003 would be expressed as 20030701. CENTURY-DATE, when accessed by a program, behaves as if it had been described as an unsigned elementary numeric integer data item eight digits in length.

CENTURY-DAY is made up of the data elements year and day.The sequence is YYYYDDD; thus, a current date of July 1, 2003 would be expressed as 2003182. CENTURY-DAY, when accessed by a program, behaves as if it had been described as an unsigned elementary numeric integer data item seven digits in length.

DATE without the YYYYMMDD phrase is made up of the data elements year, month, and day. The sequence is YYMMDD; July 1, 1988 would be expressed as 880701. DATE, when accessed by a program, behaves as if it had been described as an unsigned elementary numeric integer data item six digits in length.

DATE with the YYYYMMDD phrase is made up of the same data elements and behaves in the same manner as described for CENTURY-DATE.

DATE-AND-TIME is made up of the data elements year, month, day, hours, minutes, seconds, and hundredths of seconds. The sequence is YYYYMMDDHHMMSShh; thus, a current date and time of July 1, 2003 at 2:41 p.m. would be expressed as 2003070114410000. DATE-AND-TIME, when accessed by a program, behaves as if it had been described as an unsigned elementary numeric integer data item sixteen digits in length.

DATE-COMPILED is made up of the data elements year, month, and day for the date the program compilation started (that is, it is a constant for any particular compilation). The sequence is YYYYMMDD; thus, if the program were compiled on July 1, 2003, this would be expressed as 20030701.DATE-COMPILED, when accessed by a program, behaves as if it had been described as an unsigned elementary numeric integer data item eight digits in length.

DAY without the YYYYDDD phrase is made up of the data elements year and day. The sequence is YYDDD; July 1, 1988 would be expressed as 88182. DAY, when accessed by a program, behaves as if it had been described as an unsigned elementary numeric integer data item five digits in length.

DAY with the YYYYDDD phrase is made up of the same data elements and behaves in the same manner as described for CENTURY-DAY.

DAY-AND-TIME is made up of the data elements year, day, hours, minutes, seconds, and hundredths of seconds.The sequence is YYYYDDDHHMMSShh; thus, a current date and time of July 1, 2003 at 2:41 p.m. would be expressed as 200318214410000. DAY-AND-TIME, when accessed by a program, behaves as if it had been described as an unsigned elementary numeric integer data item fifteen digits in length.

DAY-OF-WEEK is composed of a single data element whose contents represent the day of the week. DAY-OF-WEEK behaves as if it had been defined in the Data Division as an unsigned elementary numeric integer data item one digit in length.The value 1 represents Monday, 2 represents Tuesday, . . ., 7 represents Sunday.

ESCAPE KEY provides access to an encoded value that designates the terminator key that terminated the most recent ACCEPT operation.ESCAPE KEY behaves as if defined in the Data Division as an unsigned, two-digit, numeric integer data item. The value of specific keys is determined by the runtime configuration.

EXCEPTION STATUS provides access to an encoded value that identifies the type of exception condition that occurred during the preceding pop-up window operation or CALL PROGRAM statement execution. EXCEPTION STATUS behaves as if it had been described as an unsigned elementary numeric integer data item three digits in length. For a pop-up window operation, the possible values and their meanings are described in the “Pop-Up Window Error Codes” table in Chapter RM/COBOL Features, of the RM/COBOL User’s Guide. For a CALL PROGRAM statement execution, the possible values and their meanings are shown here in Table.

EXCEPTION STATUS Values

EXCEPTION STATUS Values

TIME is made up of the data elements hours, minutes, seconds, and hundredths of a second. TIME is based on elapsed time after midnight on a 24-hour clock basis. The sequence is HHMMSShh; thus, 2:41 p.m. would be expressed 14410000. TIME, when accessed by a program, behaves as if it had been described as an unsigned elementary numeric integer data item eight digits in length. The minimum value of TIME is 00000000; the maximum value is 23595999.

ACCEPT . . . FROM Statement Examples



Face Book Twitter Google Plus Instagram Youtube Linkedin Myspace Pinterest Soundcloud Wikipedia

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

COBOL Topics