User Functions

Older Stories

Welcome to Friday, 23 June 2017, 07:16 @ CEST

Accept statement

cgi for cobol
  • Friday, 17 June 2016, 15:52 @ CEST
  • Contributed by:
  • Views:

ACCEPT Statement

General Rules (ACCEPT external-form-item)


(1) The external form is called an output form if the IDENTIFIED BY clause is used to associate it with an HTML template file. If the IDENTIFIED BY clause is omitted, it is called an input form. For example, the following is an input form:

        03  CGI-VAR1  PIC X(10).
        03  CGI-VAR2  PIC X(10).


and this is an output form:

        03  HTML-VAR1  PIC X(10).
        03  HTML-VAR2  PIC X(10).

(2) The ACCEPT verb treats input and output forms the same. ACCEPT sets the value of each elementary item, in order, to the value of its associated CGI variable, padding with trailing spaces. ACCEPT automatically decodes and translates the CGI input data before moving it to the elementary items of external-form-item. The value of each CGI variable is converted to the appropriate COBOL data type when it is moved to the external form. CGI variable names are case-sensitive. 

(3) If the CGI variable is empty or does not exist, ACCEPT sets the value of numeric data items to zero and nonnumeric data items to spaces. This behaviour is configurable. If you do not want ACCEPT to clear the value of the data item when its CGI variable does not exist in the CGI input data, set the CGI_CLEAR_MISSING_VALUES configuration variable to 0 (off, false, no).

(4) If the CGI variable is repeated in the CGI input data (as it would be in the case where multiple items have been selected from a choose-many list), the external form item that is identified with the CGI variable must be in a table. Otherwise, only the first CGI value is moved to the external form item. For example:

        03  CGI-TABLE    OCCURS 10 TIMES.
         05 CGI-VAR1     PIC X(10).
         05 CGI-VAR2     PIC X(10).


        03  CGI-VAR1  PIC X(10) OCCURS 10 TIMES.
        03  CGI-VAR2  PIC X(10) OCCURS 10 TIMES.

ACCEPT moves the values of the CGI variable to the items in the table. After all of the CGI values have been moved to items in the COBOL table, the remaining items in the table are set to 0 if they are numeric items, and set to spaces otherwise.

The following comments are owned by whomever posted them. This site is not responsible for what they say.