EXTERNAL-FORM CLAUSE

Let's assume the following situation.

On a web page on site A a cgi-script is started on server B which starts a cobol program named P1 passing parameters; program P1 calls a second program P2.

The program P1, which has been two parameters "field1" and "field2", use a CGI form to have available "field1":

01 Cgi-Form-P1 Is External-Form.
       05 Field1 Pic X(10) Is Identified By "field1".

and the statement: Accept Cgi-Form-P1

Now, "field2" parameter should be used only by the P2 program.

To achieve this I declare a structure as follows:

01 Cgi-Form-P2 Is External-Form.
       05 Field2 Pic X(10) Is Identified By "field2."

and the statement: Accept Cgi-Form-P2

I did some testing and it seems to work but I'm not sure.
I would like to know if this configuration is correct or if it has limitations, and it may cause problems.

Thank you all.

 

P.S. Sorry for my English...

  • Is 01 Cgi-Form-P2 in Program P2? I would think not, but wanted to check. If not, you do not need a separate 01 level, but no harm in having one. The values for field1 and field2 are sent at the same time. You shouldn't need a second ACCEPT statement.
    01 Cgi-Form-P1 Is External-Form.
    05 Field1 Pic X(10) Is Identified By "field1".
    05 Field2 Pic X(10) Is Identified By "field2."

    Accept Cgi-Form-P1

    I would think that Program P1 is the receiver, and receives values for field1 and field2, then P1 call P2 using field2
  • Yes, CGI-Form-P2 is declared in Program P2. I try to explain.
    P1 master program calls a series of subcall P2 P3 P4 .... and each subcall only uses a portion of the parameters that are in Cgi-Form-P1.
    Now, the exchange area CGI EXTERNAL-FORM in P1, that is Cgi-Form-P1, has become very wide; it would be convenient to be able to declare in each subcall strictly necessary CGI parameters in order to remove them from the master program P1.
    So also there would be the advantage of no longer having to pass these parameters in linkage to subcall P2 P3 P4 ...
    Many thanks for the answer.
  • Yes, CGI-Form-P2 is declared in Program P2. I try to explain.
    P1 master program calls a series of subcall P2 P3 P4 .... and each subcall only uses a portion of the parameters that are in Cgi-Form-P1.
    Now, the exchange area CGI EXTERNAL-FORM in P1, that is Cgi-Form-P1, has become very wide; it would be convenient to be able to declare in each subcall strictly necessary CGI parameters in order to remove them from the master program P1.
    So also there would be the advantage of no longer having to pass these parameters in linkage to subcall P2 P3 P4 ...
    Many thanks for the answer.
  • Verified Answer

    Yes, what you are describing will work as you expect.

    • ACCEPT CGI-Form-P1 <-- in program P1
    • program P1 CALLS program P2
    • ACCEPT CGI-Form-P2 <-- in program P2

    The ACCEPT'ing of external-form items can be done from any program in the same run unit. For that matter, you could DISPLAY external-form items as well from different programs (again, within the same run unit) and the output would all be channeled by the runtime back to the web server via STDOUT.