• No se han encontrado resultados

CAPÍTULO III. ASPECTOS METODOLÓGICOS

3.8. Plan de tabulación y análisis de datos

The following special processing statements can be used to define unique relationships between fields:

„ Special validation conditions: In the first example, a certain model of picture frame (the 1900 Deluxe) comes with a blue, wooden frame and includes the glass. We want the validation routine to enter this

information automatically when processing records for the 1900 series.

When any other model number is entered, we want normal validity table processing to occur.

„ Modified processing order: In the second example, we will alter the default processing order (alphabetical) and have the fields validated in the order in which they appear in the form.

Special Validation Conditions

The processing statements that establish the default values for the 1900 Deluxe picture frame must be defined as value details in the validity table.

To establish the value detail specifications

1 Open a blank Validity Table Specifications record.

2 Enter the following values:

Field Value

Field Name model

Files/Formats frames

Field Type character

5 Add the following value specifications:

Field Value

Value 1900

Cond true

Desc 1900 (Deluxe)

Stmts color in $val="blue"

date.sold in $val=tod() type in $val="wood"

glass in $val=true

6 Click Back to return to the validity record.

Figure 2-39: Validity table specifications for special processing

Fields named in value statements do not have to be defined in the validity table. For example, the frames file might have a field called shipped.by that is not validated by the system. If you want to have all your Model 1900 picture frames shipped by UPS, set the value in this field to UPS for by adding the following condition statement to the Stmts array:

shipped.by in $val=“UPS”

Modified Processing Order

To change the processing order of the validation routine, you must create an initialization expression in the Format Control record that invokes validity for the frames file. The new order is defined by a variable that is passed to the validation routine (validate.fields) in the Subroutines process. For

information on editing Format Control records, refer to Format Control in System Tailoring.

To redefine the validity routine processing order using Format Control 1 Open the frames Format Control record.

2 Enter the following statement in the Initialization Expressions field:

$fieldlist={"model", "color", "type", "glass", "quantity", "date.sold", "options"}

The variable $fieldlist defines the new validation processing order of the fields in the frame file.

Note: Alternately, you could use sequence numbers to control the processing order for the fields in the frames file.

Important: Be sure to use curly braces {} in this expression.

3 Click Save.

4 Click Subroutines.

The Subroutines process is displayed.

Figure 2-40: Format Control record containing an initialization expression

5 Pass the variable you have defined ($fieldlist) to validate.fields by adding the following parameter and value to the subroutine call:

6 Click Save.

Testing your Modifications

To test the changes you have made to the validity processing of the frame file 1 Open a blank record in the frames file.

Parameter Value

names $fieldlist

Figure 2-41: Format Control subroutine call—passing a new variable

The Validity Table Correction Screen for the Quantity field is displayed. The value in this field was not predefined in the Format Control initialization expression and cannot be NULL.

4 Enter a quantity in the Corrected Value field.

5 Click OK or press Enter.

Figure 2-42: Validity Table Correction Screen for the Quantity field

The picture frame record for the Model 1900 is displayed with the predefined values entered in the appropriate fields. The following message is displayed in the status bar: frames record added.

6 Place the cursor in the Options field and select Options > Validity Lookup to display a list of valid options.

7 Select the options that apply to the Model 1900 Deluxe frame.

8 Click Save.

Run-Time Evaluation

The following steps are a summary of the sequence of events and the options available to a user when validity table processing is invoked against a file.

Figure 2-43: Automatically validated picture frame record

2 Are any Values or Ranges defined for the field? If no, proceed to step 11. If yes, proceed to the next step.

3 Is the Cond field equal to true? If no, proceed to step 11. If yes, proceed to the next step.

4 Is any one of the Values equal to the value of the field and does the Cond field for that Value evaluate to true.? If yes, then the field is valid—proceed to step 11. If not, proceed to the next step.

5 Is the field value within any of the defined Ranges and does the Cond field for that Range evaluate to true? If yes, then the field is valid—proceed to step 11.

If not, proceed to the next step.

6 Do any Value or Range conditions evaluate to true? If yes, then stop and display all of the Values and Ranges that evaluate to true. This is the Validity Table Correction Screen. Click Exit (F3) to return to the original record.

Click Bypass (F4) to bypass the validity process for that field (proceed to step 11). Click OK (F2) or press Enter to cause the result of the

cursor.field.contents() function to be re-evaluated (proceed to Step 4).

7 Evaluate the Secondary File Query condition. If it is true, proceed to the next step. If it is false, proceed to step 11 if the value in the No Recs Option field is proceed. Return to the original record if the value in the No Recs Option field is return.

8 Execute the Secondary File Query against the indicated file. If one record is found, the value is valid (proceed to step 11). If no records are found, the value is not valid (proceed to step 9). If more than one record is found, display that list of records to the user. From here, the user can select a record (proceed to step 10), or select Bypass (F4) to return to the record.

9 Execute the Select Query against the secondary file. If no records are found, proceed to step 10. If one or more records is found, then display that list.

Click End (F3) to return to step 6. Press Enter to proceed to step 10.

Validating Arrays

The validity table processor can validate scalar and array data fields. The valid scalar data types are number (1), character (2), date/time (3), and logical (4).

You can validate arrays (8) of these data types. Other data types are not supported. When you validate an array you can either:

„ Validate all elements of the array against one validity definition, or

„ Validate each element of the array against a different validity definition.

When you create a Validity Table definition for an array, keep the following items in mind.

„ Each element of the array must validate against the same data type. In other words, you cannot validate one element against a character field and then validate another against a number.

„ Is each element of the array validated against the same or different tables?

„ If validating against one table, what is the minimum number of elements in the array that must contain valid data?

„ If validating against multiple tables, which elements must validate against which table?

Documento similar