PreviousRunning the Screenset ProgrammingNext

Chapter 11: Generating the Copyfile

The seventh step in developing your Dialog System application is to generate a COBOL copyfile. This copyfile, which is simply a file referenced in a COBOL COPY statement, is based on the Data Block you created for your screenset during data definition (see the chapter Data Definition for details).

This chapter explains how to generate the COBOL copyfile that your application program can use.

To use the Dialog System Run-time System from an application program, you need a Data Block and a control block. There are two versions of the control block provided with the Dialog System Run-time System software; see the section Control Blocks in the chapter Running the Screenset. There is a facility to generate the Data Block provided with the definition software.

The program that uses the screenset must have a copy of the Data Block information that matches the screenset. For example, the field order and field sizes created in data definition must correspond exactly with those in the Data Block used in the call interface. Therefore, if you make any changes to your screenset data, you must generate another copyfile. The names of the fields in the Data Block and the copyfile do not have to match, although it can be useful to use the same names.

11.1 Generate Prompt Menu (F5)

Pressing F5=generate from the Main menu invokes the Generate Prompt menu shown in Figure 11-1. This prompt defaults to the name of the current screenset, with a file extension of .cpb. This menu provides the standard help option, the directory option, and a Control menu.


Figure 11-1: Generate Prompt Menu

To generate a copyfile with a different name than the one displayed at the prompt, type the name you want, with a .cpb extension.

You can use the F2=directory option to view the list of existing screenset names and ensure that you do not replicate a name. For more information about using the directory option, see the section Load Screenset (F3) in the chapter Using Dialog System. When you use this option, a message asks whether you wish to overwrite the existing Data Block copyfile.

To select a screenset from a different drive (Windows only) or directory, you can use the facilities available from the Control menu, described in the next section.

11.2 Generate Prompt Control Menu (Ctrl)

Pressing Ctrl from the Generate Prompt menu invokes the Control menu shown in Figure 11-2, which enables you to view the current default drive or directory and either to select the default to use in the file prompt, or change the drive or directory.


Note: References to the drive in this, and the following, sections are relevant only in the Windows environment and do not apply if you are using UNIX.



Figure 11-2: Generate Prompt Control Menu

11.2.1 Show Default Directory (F2)

Pressing F2=show-def-dir from the Generate Prompt Ctrl menu displays the current default drive or directory on the prompt line at the bottom of the menu.

11.2.2 Use Default Directory (F3)

Pressing F3=use-def-dir from the Generate Prompt Ctrl menu replaces the drive or directory in the file string with the current default.

11.2.3 Set Default Directory (F4)

Pressing F4=set-def-dir from the Generate Prompt Ctrl menu changes the current default to the drive or directory displayed in the file prompt. To change the default, overtype the current entry with the desired drive or directory and press F4. If concurrency is in operation, a message asks you to confirm before the default is changed, because the new default takes effect for all run units.

11.2.4 Call Library (F5)

Pressing F5=call-lbr from the Generate Prompt Ctrl menu enables you to call a specified library and make the files in that library temporarily available to the system. To load a library (.lbr) catalog, type in the name of the library catalog file on the prompt line.

11.2.5 Cancel Library (F6)

Pressing F6=cancel-lbr from the Generate Prompt Ctrl menu cancels the specified library catalog file and makes the files in that library unavailable to the system.

11.2.6 Browse File (F8)

Pressing F8=brs from the Generate Prompt Ctrl menu enables you to view the specified file's copyfile, as long as copyfile is in readable text format. To browse a file in a library, specify path\library-name.lbr\filename. Use the PgDn, <down-arrow>, or Enter keys to move forward through the file. Press Escape to return to the Generate Prompt menu.

11.2.7 Rename File (F9)

Pressing F9=ren from the Generate Prompt Ctrl menu invokes the Rename File menu, shown in Figure 11-3 (this screen is a Windows example).


Figure 11-3: Rename File Menu (Windows)

To rename a file in a library, overtype the current file name on the prompt line with the desired name and press Enter. You must not change the drive from this menu (Windows only) and you cannot use global characters (for example *).

11.2.8 Delete File (F10)

Pressing F10=del from the Generate Prompt Ctrl menu deletes the file specified in the file prompt. You can use global characters; however, a message asks for confirmation before individual files are deleted. If you specify only the drive and path, the filename *.* is assumed.

When you delete files from a library, the files still occupy space in the library catalog file. If you have already loaded the library catalog when you delete a file from a library, the deleted file remains accessible until the catalog is reloaded, for example, if you cancel and then call the library.

11.3 Generate COBOL Menu (Enter)

You use this menu to generate a copyfile for your screenset. Use the menu options described earlier in this chapter to place the filename you require at the prompt on the Generate Prompt menu. Press Enter, which invokes the Generate COBOL menu. If you have previously generated a copybook with this file name, the following prompt first appears:

File already exists. Overwrite? Y/N

Your program requires the most up-to-date version of your data definition, so press "Y" to generate a new copyfile for this screenset. The Generate COBOL menu shown in Figure 11-4 is displayed.


Figure 11-4: Generate COBOL Menu

11.3.1 Data Descriptions (F2)

Pressing F2=data-descriptions from the Generate COBOL menu generates the Data Block. A message is displayed at the bottom of the screen:

Generating COPY-file - Please wait...............

When this message is removed from the screen, the Data Block has been generated. Press Escape to return to the Main menu. You can use an editor to view the generated copyfile, which is called screenset.cbp. The copyfile contains two sections; screenset-DATA-BLOCK and screenset-FIELD-NUMBERS.

Data Block The first field in this section contains the Data Block version number. When you write your application program, you must move this number to Ds-Data-Block-Version-No in the control block. At run time, the value in Ds-Data-Block-Version-No is matched against a value stored in the screenset.

The second field is the screenset-VERSION-NO and is provided for information.

The third field is the screenset-BUILD-NO and is provided for information.

The remainder of the Data Block contains the data fields you defined.

The Data Block also contains level 88 constants for any single-digit numeric data items. These data items are often used as program flags, so these level 88 constants can be useful in EVALUATE statements. You do not have to include these 88s if they are not required and can be configured out of the defaults file dsdef.cfg (see the chapter Setting Up the Configuration File for details).

Field Numbers This section is a set of constants that contain the internal field numbers of all of the fields in the Data Block. Fields are numbered sequentially according to their order in data definition.

You might need to refer to these constants, for example, if you use a function that requires a field number as a parameter.

Your application program uses this generated copyfile in conjunction with one of the control blocks provided with Dialog System. The following example shows the Data Block and field numbers generated for a screenset named CUSTOMER using the default options in the configuration file:

****************************************
* Data Block for Set CUSTOMER
****************************************

 01 CUSTOMER-DATA-BLOCK-VERSION-NO  PIC 9(4) VALUE 36.
 01 CUSTOMER-VERSION-NO             PIC 9    VALUE 1.
 01 CUSTOMER-SET-BUILD-NO           PIC 9(4) VALUE 50.

 01 CUSTOMER-DATA-BLOCK.
    03 CUSTOMER-C-CODE              PIC X(5).
    03 CUSTOMER-C-NAME              PIC X(15).
    03 CUSTOMER-C-ADDR1             PIC X(15).
    03 CUSTOMER-C-ADDR2             PIC X(15).
    03 CUSTOMER-C-ADDR3             PIC X(15).
    03 CUSTOMER-C-ADDR4             PIC X(15).
    03 CUSTOMER-C-LIMIT             PIC S9(4).
    03 CUSTOMER-C-AREA              PIC X.
    03 CUSTOMER-GROUP-001.
      04 CUSTOMER-GROUP-ITEM-001 OCCURS 10.
       05 CUSTOMER-ORD-NO           PIC S9(6).
       05 CUSTOMER-ORD-DATE         PIC 9(6).
       05 CUSTOMER-ORD-VAL         PIC 9(4)V9(2).
       05 CUSTOMER-PAY-VAL         PIC S9(4)V9(2).
       05 CUSTOMER-ORD-BAL         PIC S9(4)V9(2).
    03 CUSTOMER-C-BAL              PIC S9(5)V9(2).
    03 CUSTOMER-GROUP-002.
       05 CUSTOMER-DEL-FLG          PIC 9.
         88 CUSTOMER-DEL-FLG-TRUE     VALUE 1.
       05 CUSTOMER-LOAD-FLG         PIC 9.
         88 CUSTOMER-LOAD-FLG-TRUE    VALUE 1.
       05 CUSTOMER-SAVE-FLG         PIC 9.
         88 CUSTOMER-SAVE-FLG-TRUE    VALUE 1.
       05 CUSTOMER-CLR-FLG          PIC 9.
         88 CUSTOMER-CLR-FLG-TRUE     VALUE 1.
       05 CUSTOMER-EXIT-FLG         PIC 9.
         88 CUSTOMER-EXIT-FLG-TRUE    VALUE 1.
    03 CUSTOMER-ERR-MSG             PIC X(20).
****************************************
* End of Data Block for Set CUSTOMER
****************************************
****************************************
* Field Numbers for Set CUSTOMER
****************************************

 01 CUSTOMER-FIELD-NUMBERS.
   03 CUSTOMER-FLD-NO-C-CODE   PIC 9(4) COMP VALUE 1.
   03 CUSTOMER-FLD-NO-C-NAME   PIC 9(4) COMP VALUE 2.
   03 CUSTOMER-FLD-NO-C-ADDR1  PIC 9(4) COMP VALUE 3.
   03 CUSTOMER-FLD-NO-C-ADDR2  PIC 9(4) COMP VALUE 4.
   03 CUSTOMER-FLD-NO-C-ADDR3  PIC 9(4) COMP VALUE 5.
   03 CUSTOMER-FLD-NO-C-ADDR4  PIC 9(4) COMP VALUE 6.
   03 CUSTOMER-FLD-NO-C-LIMIT  PIC 9(4) COMP VALUE 7.
   03 CUSTOMER-FLD-NO-C-AREA   PIC 9(4) COMP VALUE 8.
   03 CUSTOMER-FLD-NO-ORD-NO   PIC 9(4) COMP VALUE 9.
   03 CUSTOMER-FLD-NO-ORD-DATE PIC 9(4) COMP VALUE 10.
   03 CUSTOMER-FLD-NO-ORD-VAL  PIC 9(4) COMP VALUE 11.
   03 CUSTOMER-FLD-NO-PAY-VAL  PIC 9(4) COMP VALUE 12.
   03 CUSTOMER-FLD-NO-ORD-BAL  PIC 9(4) COMP VALUE 13.
   03 CUSTOMER-FLD-NO-C-BAL    PIC 9(4) COMP VALUE 14.
   03 CUSTOMER-FLD-NO-DEL-FLG  PIC 9(4) COMP VALUE 15.
   03 CUSTOMER-FLD-NO-LOAD-FLG PIC 9(4) COMP VALUE 16.
   03 CUSTOMER-FLD-NO-SAVE-FLG PIC 9(4) COMP VALUE 17.
   03 CUSTOMER-FLD-NO-CLR-FLG  PIC 9(4) COMP VALUE 18.
   03 CUSTOMER-FLD-NO-EXIT-FLG PIC 9(4) COMP VALUE 19.
   03 CUSTOMER-FLD-NO-ERR-MSG  PIC 9(4) COMP VALUE 20.

*****************************************
* End of Field Numbers for Set CUSTOMER
****************************************

The chapter Running the Screenset shows how the information contained in the Data Block is used in the call interface to the COBOL application program.

11.3.2 Prefix On/Off (F3)

Pressing F3=prefix on/off from the Generate menu enables you to specify whether or not data item names in the generated copyfile are prefixed with the screenset name.

Pressing F3 toggles the setting between the following values:

ON Data item names have the screenset name as prefix.
OFF Data item names do not have the screenset name as prefix.


Copyright © 1998 Micro Focus Limited. All rights reserved.
This document and the proprietary marks and names used herein are protected by international law.
PreviousRunning the Screenset ProgrammingNext