3. Embedded SQL for COBOL : COBOL Data Items and Data Types : Data Types : How to Assemble and Declare External Compiled Forms--VMS
 
Share this page                  
How to Assemble and Declare External Compiled Forms--VMS
You can precompile your forms in VIFRED. This saves the time otherwise required at runtime to extract the form's definition from the database forms catalogs. When you compile a form in VIFRED, VIFRED creates a file in your directory describing the form in the VAX11 MACRO language. VIFRED prompts you for the name of the file with the MACRO description. When the MACRO file is created, you can use the following VMS command to assemble it into a linkable object module:
macro filename
This command produces an object file containing a global symbol with the same name as your form. Before the embedded SQL/FORMS statement addform can refer to this global object, it must be declared in an embedded SQL declaration section, with the following syntax:
01 formid PIC S9(9) [USAGE [IS]] COMP VALUE [IS] EXTERNAL formname.
Note:   
The formid is a COBOL data item. It is used with the addform statement to declare the form to the Forms Runtime System (FRS).
The formname is the actual name of the form. VIFRED gives this name to the global object. The formname is used to refer to the form in embedded SQL statements after the form has been made known to the FRS via the addform statement.
The EXTERNAL clause causes the VAX linker to associate the formid data item with the external formname symbol.
The following example shows a typical form declaration and illustrates the difference between using the form's object definition (the formid) and the form's name (the formname).
Example: Form declaration
DATA DIVISION.
WORKING-STORAGE SECTION.
EXEC SQL BEGIN DECLARE SECTION END-EXEC.
01 EMPFORM-ID PIC S9(9) USAGE COMP VALUE IS EXTERNAL
   empform.
* Other embedded SQL data declarations.
EXEC SQL END DECLARE SECTION END-EXEC.
PROCEDURE DIVISION.
* Program initialization.
* Making the form known to the FRS via the global form object.
EXEC FRS ADDFORM :EMPFORM-ID END-EXEC.
* Displaying the form via the name of the form.
EXEC FRS DISPLAY empform END-EXEC.
* The program continues.
For information on linking your embedded SQL program with external compiled forms, see How to Include External Compiled Forms in the RTS in this chapter.