Previous Topic: Defining Working DataNext Topic: Defining the Environment for SQL Access


Defining Parameters Used as Input

Parameter data consists of the names and descriptions of data items to pass to this program from a calling program or to this program using a RUN command. Parameter data is specified for the called subprogram on the parameter definition fill-in, shown in the following screen.

=> ------------------------------------------------------------------------------- IDEAL: PARAMETER DEFINITION PGM ADRMRPT (001) TEST         SYS: DOC FILL-IN Command Level Field Name          T I Ch/Dg Occur U M Comments/Dep on/Copy ====== ===== ====== T O P ====== = = ===== ===== = = ======================= ...... ...... ...... ...... ...... ...... ...... ====== ===== === B O T T O M === = = ===== ===== ============================

The following pages describe the components of the parameter definition fill-in. Parameter data is specified in much the same way as working data, as you can see from the similarities between the fill-ins. However, the specification of parameter data differs in several ways from the definition of working data:

Level

Specifies the number that hierarchically ranks fields. Elementary field names must be unique to the highest level (level-1) group name. Elementary fields not in a group (level-1 names by themselves) must be unique to the program. All level-1 names must be unique to the program.

Field Name

A valid field name for a parameter that corresponds to the data item in the CALL statement. This name in the called program can be the same as or a different from the name of the data item in the calling program.

You can continue the field name on a second line by including a semicolon (;) as the last character on the first line. You can break the field name at any character. Leading blank characters on a continued line are stripped.

You can specify the level number and the attributes T, I, Ch/Dg, and Occur on the first line only.

T (Type)

Specifies the parameter type.

Note: For non-Ideal subprograms, you must specify type X, N, or U. For a detailed explanation of each field type and its characteristics, see the Programming Reference Guide.

The types are as follows:

X

Specifies an alphanumeric field. The value of the field can be any alphabetic, numeric, or special character, or the null value.

V

Specifies a variable length alphanumeric field. The value of the field can be any alphabetic, numeric, or special character or the null value.

N

Specifies a signed numeric field. The value of the field can be 0-9, a minus sign, or decimal symbol, or the null value.

U

Specifies a unsigned numeric field. The value of the field can be 0-9 or decimal symbol, or the null value.

D

Specifies a date field. This type is a numeric field containing an integer number, reflecting the number of days, plus or minus, from December 31, 1900 (day zero), or the null value.

C

Specifies a condition name assigned to a specific value of a field.

F

Specifies a flag that signifies a condition. The only valid values for a flag are TRUE and FALSE.

I (Internal Representation)

Specifies the internal representation of numeric (signed and unsigned) and date type fields:

P

Specifies a packed decimal field.

Z

Specifies a zoned decimal field.

B

Specifies a binary field.

Note: Internal representation must be blank unless the type is N, U, or D. P is the default.

For CA Ideal subprograms, use the following:

For non-Ideal subprograms, the internal representation is required for N and U type fields.

Ch/Dg (Characters/Digits)

Specifies the length of the field value. Either the number of alphanumeric characters or the number of integers, a period, and the number of decimal places in a numeric or date field value For a variable length alphanumeric field, the maximum number of alphanumeric characters. Date fields cannot have decimal places.

You must specify the characters and digits for all elementary field types except dates and flags. The default for date fields is 7. The minimum length for date fields is 5. For numeric and date fields, the maximum is 31 for packed and zoned, and 9 for binary.

A non-date entry with no type or length information is assumed to be a group name and must have subordinate fields following it.

For example, in the following table, 42 in the Ch/Dg column for the first alphanumeric field (Type X) indicates a length of 42 characters. The value 16 for the variable length field indicates a maximum length of 16 characters. A numeric field (Type N) with 7 specified in the Ch/Dg column indicates a seven-digit field with 7 integer positions. The next numeric field, with 10.3 specified in the Ch/Dg column, indicates a 13-digit field with 10 integer positions and 3 decimal places. A date field (Type D) with 5 in the Ch/Dg column can hold an internal five-integer date value of up to 273 years from the base year.

Type

Ch/Dg

X

42

V

16

N

7

N

10.3

D

5

For CA Ideal subprograms with dynamic parameter matching, this specification is required for type X and V parameters and optional for types N, U, and D.

For type X parameters and for type V parameters passed with dynamic parameter matching and Input update intent, the length of the Characters/Digits of the subprogram parameter must be greater than or equal to the Characters/Digits specified in the calling program.

For type V parameters passed with dynamic parameter matching and Update intent, the characters/digits must match the specification in the calling program.

Numeric and date parameters do not require a characters/digits specification, because they are automatically assigned the same logical attributes as the corresponding data item in the calling program.

If you specify characters/digits, it must match the characters/digits of the corresponding data item in the calling program.

With identical parameter matching, the character/digits specification is required for all types. The characters/digits must match the characters/digits of the corresponding data item in the calling program.

For non-Ideal subprograms, the characters/digits attribute is required for all types.

Also see the rules for calling subprograms described in Executing Nested Programs.

Occur (Number of Occurrences)

Specifies the number of times a group or field occurs (or the maximum for dynamic parameters).

When a group or field occur a fixed number of times, the number of occurrences is entered in this column.

A group or field also occur a variable number of times, depending on the count in another field known as the Depending on field. In this case, the Occur column contains the maximum number of occurrences. The Depending on field name is specified in the Comments/Dep on/Copy column by using the phrase DEP ON field name. Only one such variably repeating group is permitted in any structure. It must be at the end of the structure. For dynamic parameters, this is the maximum number of occurrences that you can specify for the corresponding field in the calling program.

Note: You cannot specify initial values for repeating fields in parameter data. You cannot specify an Occur value for a level-1 parameter.

U (Update Intent)

Specifies the kind of parameter. This attribute is specified only for a level-1 item, never for subordinate fields of a group.

U

Specifies an update parameter, that is, one that the program can modify.

I

Specifies an input parameter, that is, one that the program cannot modify.

M (Parameter Matching)

(For CA Ideal subprograms only.) Specifies whether attributes are dynamically copied into the parameter from the corresponding data item in the calling program and only match the general type or must be completely specified and match exactly the corresponding data item in the calling program. Specify this attribute only for level-1 parameters. It applies only to that field or group.

D (Default)

Specifies dynamic matching. Attributes for this data item are copied from the calling program.

I

Specifies identical matching. Attributes must be completely specified and match those of the calling program data item. Identical parameter matching generates more efficient code since all attributes are known at compile time.

Comments/Dep on/Copy (Comment, Redefinition, Depending on field name, COPY dataview or SQLCA, or WITH INDICATOR)

The case of the text entered in this column as CA Ideal retains it is determined by default or with a SET EDIT CASE command. You can specify a descriptive comment about the field alone or with any of the others. The keywords and field names must be uppercase.

Comments

Specifies useful information about the field. A comment is indicated in this column by a preceding colon (:).

To continue a comment over multiple lines, start each line of the column with a colon. The other columns can be blank or the continuation of a field name.

REDEF

Indicates with the keyword REDEFINITION (or REDEF) in this column that this parameter item is another view of the closest previously defined item at the same level that is not itself a redefinition.

This item cannot be larger than the item that defined it. The two items can be different types (such as alphanumeric and numeric), but neither item can be a variable length field or a nullable field. None of the items can be a group containing neither a variable length field nor a nullable field.

If a parameter field with a REDEF is a subordinate field, its Type does not affect whether the group is alpha or non-alpha, nor types of the subordinate fields in the group. CA Ideal uses the type of the item that defined it. For an example, refer to the definition of alpha groups in the Programming Reference Guide.

Redefinitions are not allowed for level-1 parameters and are not allowed for non-Ideal subprograms.

DEP ON

Specifies a DEP ON field-name clause. This clause designates a field as a counter to limit the number of occurrences of a field that was defined as occurring a variable number of times. Field name must be an elementary numeric field that appears previously in the same level-1 structure. The field-name field must be defined with zero decimal places and cannot be specified with an Occur value. It cannot be a date field. You can specify an initial value for the field-name field.

You can split the keywords DEP and ON over two consecutive lines without a continuation character. To continue a field name onto a second line, specify a semicolon (;) as the last character of the first line. You can break the field name at any character. The other columns can be blank or the continuation of a field name.

COPY DATAVIEW

Specifies to automatically copy the entire structure of a dataview into a parameter definition. To use this clause:

  • Enter a level-1 name in the Field Name column.
  • Enter COPY DATAVIEW dvwname in the Comments/Dep On/Copy column.
  • To continue a dataview name onto a second line, specify a semicolon (;) as the last character of the first line. You can break the name at any character.

The dataview being copied must be a cataloged dataview and must be specified as a resource of the program.

CA Ideal performs the copy when the program is compiled. To see the dataview structure, enter the DISPLAY DATAVIEW command. The structure is not shown in the parameter data. This is included in the compile listing if the EXD compiler option is on.

Note: You must include the dataview in the resources of the program even though there might not be any FOR construct in the procedure.

COPY SQLCA (SQL only)

Automatically copies the entire structure of the SQLCA work area into the parameter definition. The SQLCA contains information about the last SQL statement this program processed. COPY SQLCA is not needed if you use $SQL functions. To use this clause:

  • Enter a level-1 data name in the Field Name column.
  • Enter COPY SQLCA in the Comments/Dep On/Copy column. You can split the keywords COPY and SQLCA over consecutive lines without a continuation character.

You can define only one SQLCA group in parameter data for each database management system that SQL can access. The level-1 data name cannot be DB-SQLCA, the name CA Ideal uses. The subordinate fields of each group are the SQLCA fields.

For a list of the SQLCA fields, refer to the $SQL functions in the Programming Reference Guide and to the SQL reference guide for the appropriate database management system.

If the resource table includes an SQL dataview, the SQLCA structure is listed following the WOR/PAR sections in the compiler listing.

If the EXD compiler listing option is turned on, the SQLCA structure is listed following the WOR/PAR sections.

CA Ideal performs the copy when the program is compiled.

If you have both CA Datacom SQL and DB2 SQL, you can define two SQLCA groups, one for each type of database.

You can specify which SQLCA to copy by indicating the type of database with the COPY clause. That is COPY DB SQLCA or COPY DB2 SQLCA.

If you do not specify a database type, the COPY defaults to the current primary DBMS defined in the program environment fill-in.

WITH INDICATOR

Specifies with the clause WITH INDICATOR (or WITH IND, or IND) in this column that this field is nullable; that is, it can receive null values. You can specify this clause with alphanumeric, variable length, numeric, date fields, and with condition names.

You must define a parameter field as nullable if the corresponding field in the calling program is nullable, regardless of its value or matching selection.

The following screen shows how you can use these parameters:

The following screen also shows these forms of parameter definition:

=> ------------------------------------------------------------------------------- IDEAL: PARAMETER DEFINITION PGM JEUPPER (001) TEST         SYS: DOC DISPLAY Command Level Field Name          T I Ch/Dg Occur U M Comments/Dep on/Copy ------ ----- ------------------- - - ----- ----- - - ----------------------- ====== ===== ====== T O P ====== = = ===== ===== = = ======================= 000100 1 HIRE-DATE           D P     6        I I 000200 1 NAME                V      20        I I 000300 1 NUMBER              N P     7        I I 000400 1 WAGES               N Z 4.2         U I 000500 1 YTD-WAGES N                U D 000600 1 ADDRESS                              I I 000700 2 STREET              X      20 000800 2 CITY                X      20 000900 2 STATE               X       2 001000 2 ZIP                 U Z     9 001100 2 ZIP-ALPHA           X       9 REDEF ====== ===== === B O T T O M === = = ===== ===== = = =======================

In addition to the parameter definition fill-in, CA Ideal subprograms permit dynamic and identical parameter matching, while enforcing certain linkage conventions. See Calling a Subprogram section for an explanation of these processes.