COBOL Accept Statement

COBOL Sequence Programming Construction COBOL Call Statement

Advertisements


ACCEPT statement accepts the data from the outside of the program which may be from input device or system defined data items.

ACCEPT transfers the accepted data to the specified identifier along with ACCEPT.

ACCEPT statement used to receive the data during the program execution.

Syntax:
	ACCEPT variable/identifier [FROM TIME/DATE/SYSTEM DEFINES ITEMS]

In the above syntax,

Variable/identifier may be an elementary or group item.

Variable/identifier can be of any data type in COBOL.

FROM clause is optional for the ACCEPT statement.

If FROM clause not coded in program, the program expects the data from in-stream data of JCL.

If ACCEPT statement coded in the program, both FROM clause or in-stream data not available program will ABEND.

ACCEPT statement is restricted to batch programs.

It is not advisable to code ACCEPT in Online programs. Because during the program execution, it stops at ACCEPT statement and waiting for user to enter the data.

If ACCEPT is receiving the data from SYSTEM DEFINED ITEMS, the actual declaration length and type of the identifier/variable should be the same as SYSTEM DEFINED ITEMS returning length.

For example, DAY keyword returns YYDDD of length 5 bytes. So the variable/identifier receiving the DAY should have the declaration length 5 bytes.



If any questions on the above, post your queries on Cobol Discussion forum


COBOL Sequence Programming Construction COBOL Call Statement

Advertisements