PreviousConverting DG COBOL Data Files Using the File Conversion ProgramNext"

Chapter 16: Running Convert5

The first step in converting your DG Interactive COBOL data files is to produce a file conversion program. This program reads DG Interactive COBOL data files and converts them to Micro Focus COBOL data file format.

You use the Convert5 utility to produce a file conversion program. The input to Convert5 is the name of an existing DG Interactive COBOL source program, which must be syntactically correct. This source program must contain the FD and SELECT ... ASSIGN entries, together with any associated record definitions, for the DG Interactive COBOL data files you want to convert. The output from Convert5 is the file conversion program.

You can use Convert5 in either of two modes: interactive or batch mode.

If you run Convert5 in interactive mode, prompts are output to your screen for you to enter various parameters that control the production of the file conversion program.

If you run Convert5 in batch mode, you must supply the necessary control parameters in a file.

16.1 Running Convert5 in Interactive Mode

The Convert5 utility is entirely menu driven when run in the interactive mode. It has an on-line help facility for each menu, which you can access by pressing the key configured as the help key on your machine. This displays a screen of information on the facilities available on each menu.

To invoke Convert5 enter the command:

convert5

Once you have invoked Convert5 the main menu is displayed. From this menu you can select any of the following functions:

To select the function of your choice, press the associated function or character key, as indicated in the menu.

The following sections describe these functions.

16.1.1 Help

This function is available to you when the main menu is displayed, and when you select either the File Details function, the Printfile Name function or the Record Type Specification function.

When you select this function, a help screen is displayed for either the main menu or the function you have selected.

16.1.2 File Details

Selecting this function on the main menu displays a screen which prompts you to identify which data files produced by the DG Interactive COBOL source program are to be converted.

You must enter all of the following information on the screen:

  1. The FD name of the file to be converted, as it appears in the DG Interactive COBOL source program.

  2. The name of a DG Interactive COBOL source program which contains the FD and SELECT ... ASSIGN entries, as well as any record definitions, for the file to be converted.

  3. The name of the file conversion program which Convert5 is to generate. This name cannot be the same as that of the DG Interactive COBOL source program.

Press Enter to enter the data on this screen and return to the main menu. If you specify an invalid parameter, the screen is redisplayed for you to re-enter a valid one.

If you wish to return to the main menu without saving your entries, press Escape.

16.1.3 Printfile-name

Selecting this function on the main menu displays a screen which prompts you to enter the name of a file to which Convert5 will write all status or error messages. If you choose not to enter this parameter, all messages are output to the screen.

When an error message is written to the printfile-name you have entered, the error message number is also displayed on your screen.

16.1.4 Record Type Specification

Selecting this function on the main menu displays a screen which allows you to specify the information needed by Convert5 to process data files that contain more than one record type. That is, you can provide the information that Convert5 requires for data files that have more than one 01 level entry in their File Descriptions. You can uniquely determine the type of each record in such multiple-record type files by entering one of the following parameters:

You cannot enter both of these parameters.

Press Enter to enter the data on this screen and return to the main menu. If you specify an invalid parameter, the screen is redisplayed for you to re-enter a valid one.

Press Escape to return to the main menu without saving your entries.

16.1.4.1 Identifying Record Types by Subroutine

You can write a COBOL subroutine to determine each record type in a data file with multiple types of records. The file conversion program calls this subroutine each time it reads a record from the DG Interactive COBOL data file. The conversion program passes the contents of the record to the subroutine which must use some method to determine the type of record. The subroutine then returns a value to the file conversion program indicating the record type. This value is an index to the 01 level entries in the file's FD entry. For example, if a record corresponds to the first 01 level entry in the FD, the subroutine should return the value 1. If a record corresponds to the third 01 level entry in the FD, the subroutine should return the value 3.

The format of the CALL statement in the file conversion program is:

call "name" using record-name, record-number, 
                  record-length 

where:

name is the subroutine-name that you have supplied on this screen
record-name is an alphanumeric data item referring to the record that has just been read from the DG Interactive COBOL data file
record-number is a PIC 99 field into which your subroutine will return the number identifying the record type
record-length is a PIC 9(6) COMP item containing the length of the record. This is supplied only if you are converting a binary sequential file.

Below is an example of a subroutine that you could write to identify a type of record.

 linkage section. 
 01 record-name.
     02 filler            pic x(6). 
     02 rec-id-field      pic 9(6). 
 01 record-type           pic 99. 
 01 record-length         pic 9(6) COMP. 
 procedure division using record-name,
                        record-type, record-length. 
 main-para. 
     if rec-id-field < 10 
          move 1 to record-type 
     else 
          if rec-id-field < 80 
               move 2 to record-type 
          else 
               move 3 to record-type. 
     exit program. 

16.1.4.2 Identifying Record Types by Unique Record Item

The file conversion program may be able to determine a type of record in a file with multiple types of records by examining the value of a particular data item. However, it can do this only if this value uniquely determines the record type.

If this is true, enter the name of the record item on this screen as it appears in the FD entry in the DG Interactive COBOL source program. Now you must enter a list of level 88 conditions and the record numbers that each of these conditions identify. The record number, as with the value returned by a subroutine, indexes the appropriate 01 level entry in the FD.

For example, you might make the following entries on this screen:

Identifying Data Item OR User Subprogram-name 
[REC-TYPE-ITEM                    ]
record                    value(s) 
number

[1]         [1 thru 15                          ] 
[2]         [16                                 ] 
[3]         [17 19 21 24 thru 30                ] 
[4]         [18 20                              ] 
[5]         [22 23                              ] 
[6]         [OTHERWISE                          ] 
[ ]         [                                   ] 
[ ]         [                                   ] 
[ ]         [                                   ] 
[ ]         [                                   ]

The sequence in which these entries appear is significant. See the section Example Parameter List later in this chapter for details.

16.1.4.3 Binary Sequential Files

In a binary sequential file with multiple record types, the file conversion program can identify a record type by its length as long as no two record types have the same length. However, if they do, you will have to use either the subroutine or unique identifier method described in the previous sections to identify the record type.

16.1.5 Generate Program

Selecting this function from the main menu generates the file conversion program. You must have previously supplied Convert5 with all of the necessary parameters to enable it to generate this program.

The message:

Creating Source 

is displayed while Convert5 generates the file conversion program.

If any errors occur during generation, relevant error messages are displayed on the screen. If you have specified the name of a printfile these messages are also written to that file.

When a file conversion program has been successfully generated you are returned to the main menu.

16.1.6 Escape

Leaves the Convert5 utility and returns you to your main system prompt. You are asked to confirm that this is what you want to do.

16.2 Running Convert5 in Batch Mode

If you wish to run Convert5 in batch mode, you must first write a parameter file containing the parameters required by Convert5. When you then run Convert5, it first validates all of the parameters you have entered, and if these are all valid, each invocation of Convert5 extracts a full set of parameters from this file. If the parameters are not valid, no conversion takes place.

16.2.1 The Parameter File

This is a free format line sequential file which contains a parameter on each line. If you enter any lines of space characters, these are ignored by Convert5.

The first word on each line of the parameter file identifies the type of parameter you are specifying. This can be any of the following (in upper- or lower-case characters):

listfile
sourcefile
fd
program
subroutine
identifier
run

If you enter an asterisk (*) as the first non-space character on any line, this line is treated as a comment line.

In addition a line may start with a record number (see the section Record Number Parameters later in this chapter) followed by a valid 88-level condition.

16.2.1.1 The Listfile Parameter

This parameter specifies the name of a file where any error messages or status values reported from Convert5 are recorded. When you specify this parameter, it remains valid until you specify the parameter again, so ensuring that all the information reported during a run can be placed in the same listing file. If you specify the parameter again with another file-name, subsequent messages are sent to this second file, while if you specify the parameter with following spaces, these messages are sent to your screen.

The parameter has the following format:

listfile file-name 

If you specify neither a listfile parameter nor a file-name after listfile, messages are written to the screen.

16.2.1.2 The Sourcefile Parameter

This mandatory parameter gives the name of the DG Interactive COBOL source program which Convert5 is to scan for information on the files to be converted. The parameter has the following format:

sourcefile file-name 

16.2.1.3 The FD Parameter

This mandatory parameter gives the internal name of the file as it is appears in the FD entry of the DG Interactive COBOL source program you specified in the sourcefile parameter. The parameter has the following format:

fd file-name 

16.2.1.4 The Program Parameter

This mandatory parameter gives the name of the source program which Convert5 creates. The parameter has the following format:

program file-name 

The program-name must not be the same as the name used in the sourcefile or listfile parameter.

16.2.1.5 The Subroutine Parameter

This parameter gives the name of a COBOL subroutine that you supply as it will appear in a CALL statement in the file conversion program. For files which contain multiple records this subroutine will identify the correct record definition, allowing you to convert files of any logical complexity. The parameter has the following format:

subroutine program-name

16.2.1.6 The Identifier Parameter

The identifier parameter specifies the name of an item in the file record whose value can be used to uniquely determine a type of record in a file with more than one record type. The parameter has the following format:

identifier file-name 

16.2.1.7 Record Number Parameters

If you have specified an identifier parameter, you must specify a number of parameters that indicate which values of the item named in the identifier parameter correspond to which record types. Each parameter has the following format:

record-number condition 

where:

record-number indicates a record type (1 means the first 01 level entry in the FD, 2 means the second 01 level entry, and so on). Record identification is carried out in the order in which the record-numbers are specified.
condition is an 88-level record-type which, if true, indicates that the associated record-number gives the correct record type. The OTHERWISE condition indicates the correct record type for those values of the item named in the identifier parameter which you have not previously specified in the Record Number parameter. All record number parameters must immediately follow the identifier parameter, and must be in the order you want record identification to be carried out.

See the section Example Parameter List later in this chapter for an example of the use of these parameters.

16.2.1.8 The Run Parameter

The mandatory run parameter invokes Convert5 with those parameters that have already been read. The parameter has the following format:

run 

16.2.1.9 Example Parameter List

The parameter list shown below is an example of a parameter file that you could supply to Convert5. This file generates file conversion programs for three DG Interactive COBOL data files.

********************************** 
*  Parameters for first run      * 
********************************** 
listfile          history.lst 
sourcefile        payroll1.cbl 
fd                employee-file 
program           progemp 
identifier        employee-status 
2                 99 103 200 201 
1                 1 thru 2000 
3                 6786 9999 
2                 0 thru 9999 
4                 otherwise
run 
********************************** 
*  parameters for second run     * 
********************************** 
sourcefile        payroll2.cbl 
* listing will go to history.lst 
fd                branch-file 
program           progbran.cbl 
subroutine        branchek 
run 
********************************** 
*  last run                      * 
********************************** 
listfile          logfile 
sourcefile        payroll2.cbl 
fd                history-file 
program           history.abc 
run 

In the above example, the parameters for the first run are designed to provide for a file comprising four record types. These records are identified by a data item in one of the records. If this item has the value 6786 or 9999, it is record type 3. If the values lie within the range 1 to 2000 excluding 99, 103, 200 and 201, it is record type 1. Any other values within the range 0 to 9999 are record type 2, while any values lying outside this range are record type 4.

The second file which is to be converted during the run of this parameter file also contains multiple records. However, record identification in this case is carried out via the user-supplied subroutine named "branchek".

The third file converted on the final run comprises only one record type, and so record identification is not necessary.

The above example illustrates that record identification via level 88 data items is carried out in the order in which the parameters are presented.


Note: You can identify the same record type more than once. You may find this useful if more than one parameter is required to cover all possible combinations of data value.


16.2.2 Running Convert5 with a Parameter File

To invoke Convert5 in batch mode enter the command:

convert5 parameter-filename 

where parameter-filename is the name of your parameter file.

Convert5 now runs in batch mode, extracting a full set of parameters from the parameter file with each invocation.

The parameters supplied in the file are always validated completely. If any errors are detected during this validation, no conversion takes place.

You can validate the entries in a parameter file by entering:

convert5 parameter-filename validate 

If you enter this command, the contents of the parameter file are validated, but no conversion takes place, even if all of the parameters are valid.


Copyright © 1999 MERANT International Limited. All rights reserved.
This document and the proprietary marks and names used herein are protected by international law.

PreviousConverting DG COBOL Data Files Using the File Conversion ProgramNext"