In this section: |
This section describes the statements that read and describe transactions. These are the FIXFORM, FREEFORM, PROMPT, and CRTFORM statements. The last part of the section discusses the DATA, START, and STOP statements.
To modify a data source, the MODIFY request first reads incoming data. It then uses this data to select the segment instances that must be changed or deleted, or to confirm that the instances have not been entered yet and to add them. The data may be in fixed or comma-delimited format, it may be stored in sequential data sources or within the request itself, and it may be entered directly by users on terminals.
There are four MODIFY statements that read and describe incoming data. Some read data from sequential data sources and the request itself; some prompt users on terminals for data. They are:
FIXFORM |
Reads data in fixed format. That is, the fields occupy fixed positions in each record. |
FREEFORM |
Reads data in comma-delimited format. That is, the fields in each record are separated by a comma (,). Each record is terminated by a comma and a dollar sign (,$). |
PROMPT |
Prompts users on terminals for data values one field at a time. This statement works on all terminals. |
CRTFORM |
Displays formatted screens (called CRTFORMs) on terminals and allows users to enter multiple data values at one time. |
Note: PROMPT, FREEFORM, FIXFORM, and CRTFORM statements accept data that includes numbers expressed in scientific notation. For more information on the use of scientific notation in expressions, refer to the Creating Reports manual.
If a request does not have one of these statements, it defaults to FREEFORM and reads data from a comma-delimited list.
These statements can be placed in requests in two ways:
A request may have an unlimited number of statements of one type (for example, 10 PROMPT statements), except for CRTFORM where up to 255 such statements are allowed. You may also mix the following statements in one request:
If you are reading data from a data source or user program, you must allocate the source of the data to a ddname.
Note: Do not begin any field used in a CRTFORM or FIXFORM statement with Xn, where n is any numeric value. This applies to fields in the Master File and computed fields.
FOCUS allows the use of up to 3,072 fields in each MODIFY request. This total includes both data source fields and temporary fields.
The last part of the section discusses several other features related to reading transactions. They are:
In this section: How to: |
The FIXFORM statement reads data in fixed format. That is, each field has a fixed position in each record. The FIXFORM statement can read data from sequential data sources, including HOLD, SAVE, and SAVB files generated by TABLE requests.
The FIXFORM statement reads in one logical record at a time starting from column one and divides the record into transaction fields. Subsequent FIXFORM statements may redefine the record, dividing it into different sets of fields.
Note: Multiple FIXFORM statements in a request can function as a single statement.
For example, you are adding the names of five new employees to the EMPLOYEE data source. The data is stored in a sequential data source called NEWEMP.
This is how the data source appears on a text editor such as TED:
|....+....1....+....2....+....3....+....4 * * * TOP OF FILE * * * 222333444BLACK SUSAN 27500.00 456456456NEWMAN JERRY 24800.75 999888777HUNTINGTON LAWRENCE 26950.00 246246246LINDQUIST DEBRA 19300.40 666888222MCINTYRE GEORGE 31900.60 * * * END OF FILE * * *
Each record in the data source consists of four fields, each field in a fixed position on the record:
You can describe the record format with this FIXFORM statement:
FIXFORM EMP_ID/9 LAST_NAME/10 FIRST_NAME/10 CURR_SAL/8
To add the records to the FOCUS data source, include the preceding statement in this MODIFY request:
MODIFY FILE EMPLOYEE FIXFORM EMP_ID/9 LAST_NAME/10 FIRST_NAME/10 CURR_SAL/8 MATCH EMP_ID ON MATCH REJECT ON NOMATCH INCLUDE DATA ON NEWEMP END
The syntax of the FIXFORM statement is
FIXFORM [ON ddname] fld-1/form-1 ... fld-n/form-n
or
FIXFORM FROM master [ALIAS]
where:
Are the names of the incoming data fields that the FIXFORM statement is reading or redefining. If the name has an embedded blank, enclose it within single quotation marks.
Any field being read by the FIXFORM statement that does not appear in the Master File of the data source being modified must be predefined in a COMPUTE field/format=; statement. This COMPUTE must appear in the MODIFY before the FIXFORM.
The list of fields must fit on one line. If the list is too long to fit on one line, use a FIXFORM statement for each line. For example:
FIXFORM EMP_ID/9 LAST_NAME/15 FIXFORM CURR_SAL/8 ED_HRS/4
The two FIXFORM statements act as one statement and read one record into the buffer.
Are the formats of the incoming data fields, as described in How to Specify Field Formats With FIXFORM. The formats specify the format type (alphanumeric, integer, floating point, and so on) and the length of the field in bytes.
Note: No length is specified for the text field format that is variable in length. A FIXFORM statement can describe up to 12,288 bytes, exclusive of repeating values.
To specify an alphanumeric format, type the length of the field in bytes. For example, a record contains two alphanumeric fields:
The EMP_ID field, nine bytes long.
The DEPARTMENT field, ten bytes long.
The FIXFORM statement that describes this record is:
FIXFORM EMP_ID/9 DEPARTMENT/10
Note that alphanumeric transaction fields can modify any data source field regardless of internal format. Specifying the formats of binary, packed, and zoned transaction fields is discussed in How to Specify Field Formats With FIXFORM.
Remember that a transaction field can contain numbers and still be alphanumeric. If you display a transaction data source on a system editor, alphanumeric data appears normally; numeric data appears as unprintable hexadecimal characters.
Is an option that specifies the ddname of the transaction data source containing the incoming data. You use this option most often when the request is reading data from two different sources: one source is specified by the DATA statement, the other by the ON ddname option.
Note that if there is more than one FIXFORM statement without the ON ddname option, the request keeps track of the last column of the physical record read by the last FIXFORM statement. If the last column is in the middle of the record, the next FIXFORM statement begins to read from the next column. If the last column is at the end of the record, the next FIXFORM statement begins to read from column 1 of the next record.
To break a FIXFORM statement having the ON ddname option into smaller statements, specify the ON ddname option only in the first statement. All the statements must be together in one block. For example:
FIXFORM ON EMPFILE EMP_ID/9 LAST_NAME/15 FIXFORM FIRST_NAME/10 DEPARTMENT/10 FIXFORM CURR_SAL/8 ED_HRS/4
Indicates that the incoming data fields have the same names and formats as the Master File (named master). If you use this option, do not specify the field names and formats in the FIXFORM statement itself. Use this option only if the Master File specifies a single segment SUFFIX=FIX data source. All the fields in the Master File specified by the FROM phrase must also appear in the Master File specified by the MODIFY command, or an error will result.
You use this option most often to load data from a HOLD file. For example:
TABLE FILE EMPLOYEE PRINT CURR_SAL BY EMP_ID ON TABLE HOLD END MODIFY FILE SALARY FIXFORM FROM HOLD DATA ON HOLD END
The TABLE request stores employee IDs and salaries in a HOLD file. The MODIFY request loads the IDs and salaries into a new FOCUS data source called SALARY. Note that all the fields in the HOLD Master File must also appear in the SALARY Master File.
Text fields are supported with FIXFORM from HOLD; only one text field can be read from a HOLD file and it must be the last field on the HOLD FIXFORM. The representation of missing text depends on whether MISSING=ON in the Master File or the FIXFORM format is C for conditional, or a combination of the two.
When duplicate field names exist in a HOLD file, a MODIFY request that includes FIXFORM FROM HOLD should specify an AS name.
Note: FIXFORM FROM Master File automatically assumes that all fields on the FIXFORM are conditional fields. Because of this a value of blank does not update the database to a value of blank. If blank (or spaces) is a valid value, and the update should take place, you must issue an ACTIVATE RETAIN fieldname fieldname fieldname... or ACTIVATE RETAIN SEG.fieldname.
Indicates that the alias names from the Master File are to be used to build the FIXFORM statements.
Often, an incoming transaction contains filler or data you do not need. To skip over characters or information in the incoming record, type
Xn
where:
Is the number of columns you want to skip.
This does not cause the statement to ignore the skipped columns. The statement reads the entire record; it just does not place the skipped data in any transaction field. Later in the request, you can place this data into transaction fields by adding a second FIXFORM statement (see the following section, How to Move Backward Through a Record).
For example, a transaction record consists of two fields: EMP_ID and CURR_SAL. Two "A"s separate the fields:
071382660AA23540.35
You describe this record with this FIXFORM statement:
FIXFORM EMP_ID/9 X2 CURR_SAL/8
The X2 notation prevents the two "A"s from being placed in the transaction fields.
Note: Do not begin any field used in a CRTFORM or FIXFORM statement with Xn, where n is any numeric value. This applies to fields in the Master File and computed fields.
After a FIXFORM statement reads a record into the buffer, it places the data into transaction fields, starting from the beginning of the record and moving toward the end. You can specify that FIXFORM back up a number of columns to process the data more than once. This enables you to place the same data into two fields simultaneously. To do this, use the notation
X-n
where n is the number of columns that the statement is to move backward. For example, the first three digits of employee IDs are a special code that you wish to use later in the request. Each employee ID is nine digits long. You type this FIXFORM statement:
FIXFORM EMP_ID/9 X-9 EMP_CODE/3 X6 CURR_SAL/8
A record in the transaction data source is:
07138266023500.35
The statement interprets the record this way:
EMP_ID/9 | Reads the first nine bytes as the employee ID (071382660). |
X-9 | Goes back nine bytes to the beginning of the record. |
EMP_CODE/3 | Reads the first three bytes as the employee code (071). |
X6 | Moves forward six bytes. |
CURR_SAL/8 | Reads the next eight bytes as the employee salary (23500.35). |
This defines three incoming fields, all of which you can use later in the request.
Note: Since the EMP_CODE field is not defined in the Master File, you must define the field with the COMPUTE statement before the FIXFORM statement (see Computing Values: The COMPUTE Statement).
You may replace any FIXFORM statement with two smaller statements so that the second statement redefines all or part of the record read by the first statement. For example, you may replace this FIXFORM statement
FIXFORM EMP_ID/9 X-9 EMP_CODE/3 X6 CURR_SAL/8
with these two smaller FIXFORM statements:
FIXFORM EMP_ID/9 CURR_SAL/8 FIXFORM X-17 EMP_CODE/3 X14
The first FIXFORM statement reads one record and divides the record into the EMP_ID field (nine bytes) and the CURR_SAL field (eight bytes).
The second FIXFORM statement moves 17 bytes back to the beginning of the record and declares the first three bytes to be the EMP_CODE field. It then skips over the last 14 bytes.
Note that you cannot place the X-n notation at the end of a FIXFORM statement. The following statement is an error:
FIXFORM EMP_ID/9 CURR_SAL/8 X-17
FIXFORM statements that redefine records in the buffer are especially useful in Case Logic requests (see Case Logic Applications).
This section lists the data formats that may be specified in FIXFORM statements. In addition to alphanumeric format, there are date (DATE), text field (TX), and conditional text field (CTX) formats, and numeric formats of fields in HOLD and SAVB files and of fields generated by user-written programs. The formats are
[A]n[YQMDWV] In[YQMD] F4 D8 Pn[.m][YQMD] DATE /TX /CTX Zn[.m]
where:
Specifies an alphanumeric character string n bytes long, where n is an integer.
Date component options (YY, Y, Q, M, D) are included as necessary for a date field.
The V and W options are for AnV fields that were propagated to a HOLD file.
Specifies a binary integer n bytes long, where n is 1, 2, or 4. Date component options (YY, Y, Q, M, D) are included as necessary for a date field.
Specifies a 4-byte binary floating point number.
Specifies an 8-byte binary double precision number.
Specifies a packed number n bytes long with m digits after an implied decimal point. n is an integer between 1 and 16 and m is an integer between 0 and 33. Date component options (YY, Y, Q, M, D) are included as necessary for a date field.
Specifies a date field in 4-byte integer format, to be copied to the data source without date translation or validation. Date format fields can also be read without these restrictions by specifying alphanumeric, integer, or packed format, as described later in this section.
Specifies a text field format for transaction and conditional transaction fields. Each FIXFORM statement can include multiple text fields. However, they must appear as the last fields in the statement, they may not be conditional, and, in the data file, each text field must be terminated with the %$ character combination on a line by itself. Note that you do not specify the length when using FIXFORM to read text fields; the length is for display purposes only (see the Describing Data manual).
See Entering Text Data Using TED for general rules.
Note:
Specifies a zoned decimal number n bytes long with m digits after an implied decimal point. n is an integer between 1 and 16 and m is an integer between 0 and 9.
For example, this FIXFORM statement
FIXFORM EMP_ID/9 HIRE_DATE/I4 CURR_SAL/D8 ED_HRS/P4.2
defines each record as the following:
The FIXFORM statement specifies the field formats of transaction data sources, not the data source being updated. A transaction field can modify a data source field if the transaction field has one of the following format types (the format type is the type of field, such as alphanumeric or floating point):
If you specify any other format type for the transaction field (for example, an integer transaction field to modify a floating point data source field), the request may terminate and generate an error message. To read such a transaction value into a data source field, do the following:
Note: If the incoming field is numeric and the data source field is alphanumeric, use the EDIT function to do this. The EDIT function is described in the Creating Reports manual.
The following request reads a floating point field called FLOATSAL into the data source double-precision field CURR_SAL:
MODIFY FILE EMPLOYEE COMPUTE FLOATSAL/F8=; FIXFORM EMP_ID/12 FLOATSAL/F4 COMPUTE CURR_SAL = FLOATSAL; MATCH EMP_ID ON NOMATCH REJECT ON MATCH UPDATE CURR_SAL DATA ON FLOAFILE END
Notice that the FLOATSAL field is defined with a format of F8 in the first COMPUTE statement and a format of F4 in the FIXFORM statement. FLOATSAL is an eight-digit field that takes up four bytes in the transaction data source.
In MODIFY, by default, FIXFORM FROM mastername treats all transaction data as conditional, meaning that space-filled fields are considered not present, and as such cannot be updated or used in updates.
The SET FIXFRMINPUT command enables you to specify how to handle FIXFORM input fields as either conditional (field/format C) or non-conditional fields. Thus, spaces in a transaction field can be used for updating database fields.
SET FIXFRMINPUT = {COND|NONCOND}
where:
Treats all transaction fields generated by FIXFORM FROM mastername as conditional (format C) fields. COND is the default value.
Treats all transaction fields as present in the transaction, and their contents are treated as real values.
Note that if you have not changed the value of the FIXFRMINPUT parameter and you query its value, the value displays as DEFAULT.
The following procedure establishes a transaction file, defining LN1 in HOLD file TRANS to be blank for PIN 000000040.
SET ASNAMES = ON DEFINE FILE EMPDATA LN1/A15 = IF PIN EQ '000000040' THEN '' ELSE LN; END TABLE FILE EMPDATA PRINT PIN LN1 AS LN IF PIN FROM '000000010' TO '000000100' ON TABLE HOLD AS TRANS END
The following procedure, sets the FIXFORM FROM input fields as conditional (the default) and reports on the output from the MODIFY:
SET FIXFRMINPUT = COND -? SET FIXFRMINPUT &FIXF MODIFY FILE EMPDATA FIXFORM FROM TRANS MATCH PIN ON MATCH UPDATE LN ON NOMATCH REJECT DATA ON TRANS END
TABLE FILE EMPDATA HEADING " " "VALUE OF FIXFRMINPUT IS &FIXF " " " PRINT PIN LN IF PIN FROM '000000010' TO '000000100' END
The output shows that the blank in the tranaction file was not used to update the last name in the data source:
VALUE OF FIXFRMINPUT IS COND PIN LASTNAME --- -------- 000000010 VALINO 000000020 BELLA 000000030 CASSANOVA 000000040 ADAMS 000000050 ADDAMS 000000060 PATEL 000000070 SANCHEZ 000000080 SO 000000090 PULASKI 000000100 ANDERSON
The following procedure sets the FIXFORM FROM input fields as non-conditional and reports on the output from the MODIFY:
SET FIXFRMINPUT = NONCOND -? SET FIXFRMINPUT &FIXF MODIFY FILE EMPDATA FIXFORM FROM TRANS MATCH PIN ON MATCH UPDATE LN ON NOMATCH REJECT DATA ON TRANS END TABLE FILE EMPDATA HEADING " " "VALUE OF FIXFRMINPUT IS &FIXF " " " PRINT PIN LN IF PIN FROM '000000010' TO '000000100' END
The output shows that the last name for PIN 000000040 has been updated to contain blanks:
VALUE OF FIXFRMINPUT IS NONCOND PIN LASTNAME --- -------- 000000010 VALINO 000000020 BELLA 000000030 CASSANOVA 000000040 000000050 ADDAMS 000000060 PATEL 000000070 SANCHEZ 000000080 SO 000000090 PULASKI 000000100 ANDERSON
How to: |
This section discusses using date format fields in FIXFORM statements. Alphanumeric and integer format fields with date edit options are not discussed here; they are treated by FIXFORM like standard alphanumeric and integer fields.
When you use a FIXFORM statement to modify a data source date field, the corresponding data in the transaction data source can be one of the following three types:
Note that all names of days and months in the transaction data source must be in uppercase, even if the translation option is t or tr. All abbreviated names of days and months in the transaction data source must consist of the first three letters of the name. Commas cannot be included in the date.
For example, assume that you have changed the format of the HIRE_DATE field in the EMPLOYEE Master File from I6YMD to YMDT. You then write a request that creates a new EMPLOYEE data source. The request begins with this FIXFORM statement:
FIXFORM EMP_ID/11 FIRST_NAME/10 LAST_NAME/10 HIRE_DATE/9
Both of these records are valid input:
444555666 DOROTHY TAILOR 860613 444555666 DOROTHY TAILOR 86 JUN 13
To describe date fields in FIXFORM statements, you can use the following transaction field formats.
For example:
FIXFORM SALEDATE/DATE
For example, if a data source contains the date field NEWSDATE, and USAGE=MDYY, the following FIXFORM statements can be used to update NEWSDATE:
FIXFORM NEWSDATE/A8YYMD FIXFORM NEWSDATE/A6DMY FIXFORM NEWSDATE/I4MDY FIXFORM NEWSDATE/I2YMD FIXFORM NEWSDATE/P3DMY FIXFORM NEWSDATE/A8
Note that the last FIXFORM statement does not specify any date components. Because it is alphanumeric and has the same length specified by the data source field's USAGE attribute, it defaults to the USAGE format (which in this case is MDYY).
For all date transaction field formats, the date components (year, quarter, month, day) do not need to be in the order specified in the USAGE attribute in the Master File; they can be in any order.
Note, however, that you cannot extract date components from a date field (for example, you cannot write a YMD transaction field to a YM data source field), and you cannot convert one component to another (for example, you cannot convert a YM transaction field to a YQ data source field). The only exceptions are the YY and Y date components, which can be substituted for each other.
You may use a fixed-format transaction record to modify multiple segment instances. The set of transaction fields that modify the instances is called a repeating group because the fields repeat for each instance. Instead of explicitly specifying each field, you specify the repeating group once with a multiplying factor in front.
The syntax is
FIXFORM factor (group)
where:
Is the number of times that the group repeats.
Is the repeating group consisting of a list of fields and formats.
For example, assume you design a request that records the last 12 months of employees' monthly pay in the EMPLOYEE data source. Each transaction record contains the employee's ID and 12 pairs of fields: the first field in each pair is the pay date, the second is the monthly pay (GROSS). The request is:
MODIFY FILE EMPLOYEE FIXFORM EMP_ID/9 X1 12 (PAY_DATE/6 GROSS/7) MATCH EMP_ID ON NOMATCH REJECT ON MATCH CONTINUE MATCH PAY_DATE ON MATCH REJECT ON NOMATCH INCLUDE DATA ON EMPGROSS END
Each incoming record that the request reads contains one EMP_ID field and 12 groups of fields, each group consisting of a pay date field and a monthly pay field. The request reads a record, then splits the record into 12 smaller logical records, each consisting of the employee ID of the original record and one group. FOCUS then executes the request for each logical record, processing each group separately.
You may specify more than one group in a FIXFORM statement, but they cannot be nested.
Note: To process repeating groups in a Case Logic request, place each repeating group in a FIXFORM statement in a separate case. The case should include the following:
The following request adds and updates information on employees' monthly pay. Note the ON INVALID phrase that branches back to the beginning of the case if a monthly pay entry is greater than $2500. The request is:
MODIFY FILE EMPLOYEE COMPUTE COUNTER/I3 = 0; FIXFORM EMP_ID/9 MATCH EMP_ID ON NOMATCH REJECT ON MATCH GOTO NEWPAY GOTO NEWPAY
CASE NEWPAY COMPUTE COUNTER/I1 = COUNTER + 1; IF COUNTER GT 3 GOTO TOP; FIXFORM 3 (PAY_DATE/6 GROSS/7) VALIDATE PAYTEST = IF GROSS GT 2500 THEN 0 ELSE 1; ON INVALID GOTO NEWPAY MATCH PAY_DATE ON NOMATCH INCLUDE ON NOMATCH GOTO NEWPAY ON MATCH UPDATE GROSS ON MATCH GOTO NEWPAY ENDCASE DATA ON PAYFILE END
The following examples show how to use date format fields.
MODIFY requests can process records in which alphanumeric field values may be present in one input record but absent in another. Such fields are called conditional fields. When the value of a conditional field is blank, the request does not use the field to modify the data source and the field remains inactive (active and inactive fields are discussed in Active and Inactive Fields).
To indicate to FOCUS that a field is conditional, precede the field format with the letter C. For example:
FIXFORM FIRST_NAME/C10 LAST_NAME/C15
Another example: You design a MODIFY request that updates employees' departments and job codes. If an employee's department or job code has not changed, the corresponding field in the transaction data source is blank.
The request is:
MODIFY FILE EMPLOYEE FIXFORM EMP_ID/9 X1 DEPARTMENT/C10 X1 CURR_JOBCODE/C3 MATCH EMP_ID ON NOMATCH REJECT ON MATCH UPDATE DEPARTMENT CURR_JOBCODE DATA 071382660 SALES B13 112847612 A08 117593129 MARKETING END
The request contains three incoming records after the DATA statement:
If you did not describe the DEPARTMENT and CURR_JOBCODE fields as conditional, the request would change an employee's department or job code to blank whenever these fields in the incoming records were blank.
If you are adding segment instances, and several fields are conditional, values that are blank go into the new instances as:
You may use FIXFORM statements as phrases in MATCH and NEXT statements. These phrases are useful if you want to read records selectively only if a particular segment instance exists in the data source (or is confirmed not to be in the data source).
For example, you design a MODIFY request that adds records of employees' monthly pay to the data source:
MODIFY FILE EMPLOYEE FIXFORM EMP_ID/9 X1 PAY_DATE/6 MATCH EMP_ID ON NOMATCH REJECT ON MATCH CONTINUE MATCH PAY_DATE ON MATCH REJECT ON NOMATCH FIXFORM ON MONTHPAY GROSS/7 ON NOMATCH INCLUDE DATA ON EMPPAY END
The data is kept in two transaction data sources: EMPPAY and MONTHPAY. The EMPPAY data source contains the employee IDs and the date each employee was paid. The MONTHPAY data source contains the amount each employee was paid (GROSS). The request must confirm for every EMPPAY transaction that:
Once the request has confirmed this, it can read the monthly pay from the MONTHPAY data source
ON NOMATCH FIXFORM ON MONTHPAY GROSS/7
and record it in the data source:
ON NOMATCH INCLUDE
How to: |
The FREEFORM statement reads comma-delimited data, where field values in each record are separated by commas, and records are terminated by comma-dollar signs (,$). The data may be stored in the request itself or in separate sequential data sources.
If the MODIFY request does not provide a statement reading transactions (FIXFORM, FREEFORM, PROMPT, or CRTFORM), FREEFORM is the default.
The following request updates employee salaries by reading employee IDs and new salaries from comma-delimited records. The records follow the DATA statement:
MODIFY FILE EMPLOYEE FREEFORM EMP_ID CURR_SAL MATCH EMP_ID ON NOMATCH REJECT ON MATCH UPDATE CURR_SAL DATA EMP_ID=071382660, CURR_SAL=21400.50, $ EMP_ID=112847612, CURR_SAL=20350.00, $ EMP_ID=117593129, CURR_SAL=22600.34, $ END
The syntax of the FREEFORM statement is
FREEFORM [ON ddname] [field-1field-2 ... field-n]
where:
Is an option that specifies the ddname of the transaction data source containing the incoming data. Use this option only when the DATA statement does not specify a ddname or specifies a ddname of a different data source.
Are the names of the fields in the order that they appear in the record.
Note: FREEFORM follows the same rules as FIXFORM when dealing with TEXT fields. For more information see Reading Fixed-Format Data: The FIXFORM Statement.
If the order of fields is specified in the data, you do not need it in the syntax and if the order of fields is specified in the syntax, you do not need it in the data.
The list of fields must fit on one line. If the list is too long for a single line, use a FREEFORM statement for each line. For example:
FREEFORM EMP_ID LAST_NAME FIRST_NAME FREEFORM DEPARTMENT CURR_SAL
These two FREEFORM statements act as one statement and read one record into the buffer.
Each time a FREEFORM statement is executed, it reads one record up to the comma-dollar sign (,$). It does not read beyond that. If the FREEFORM command is used with incoming data having embedded commas, the data must be enclosed in single quotation marks in the input data source.
If a MODIFY request has a FREEFORM statement, the statement must specify all the fields in the transaction data source. If the transaction data source has fields not specified in the FREEFORM statement, the request terminates and generates an error message.
If you do not include a transaction statement in your MODIFY request, the request assumes the default FREEFORM and expects to read comma-delimited data. The request reads one record every time it executes the first statement in the request. Nevertheless, you should include a FREEFORM statement to make clear that the request is reading comma-delimited data, to show when the request reads the data, and to allow greater flexibility in entering data into comma-delimited data sources.
If the Master File lists a date format with a translation option (see the Describing Data manual), you can type the date values in the transaction data source as they appear in reports generated by TABLE requests (but do not type the commas in the dates). Note the following conditions:
For example, assume you change the format of the HIRE_DATE field in the EMPLOYEE Master File from I6YMD to YMDT. You then write a request that creates a new EMPLOYEE data source. The request begins with this FREEFORM statement:
FREEFORM EMP_ID FIRST_NAME LAST_NAME HIRE_DATE/9
Both these records are valid input:
444555666, DOROTHY, TAILOR, 860613, $ 444555666, DOROTHY, TAILOR, 86 JUN 13, $
This section discusses how MODIFY requests identify the values in comma-delimited data sources and determine what fields they belong to. (For more information on comma-delimited data sources, see the Describing Data manual.) There are two types of values in comma-delimited data sources:
Identified values have the form
identifier = value
where identifier identifies the field to which the value belongs.
Identifiers can be one of two types:
DEPARTMENT=SALES, CURR_SAL=25000, $
DPT=SALES, CSAL=25000, $
If the request has a FREEFORM statement, the statement must specify all identified fields. However, the request identifies the values by their identifiers, not by the order of field names in the FREEFORM list.
Positional values exist by themselves without any identification in the data source. For example:
SALES, 25000, $
The MODIFY request identifies positional values by the order of field names specified in the FREEFORM statement list. If a record consists only of positional values, the request assigns the first field name in the list to the first value, the second field name in the list to the second value, and so on. For example, if a request has the statement:
FREEFORM EMP_ID DEPARTMENT CURR_SAL
Then the record
071382660, SALES, 25000, $
is interpreted this way:
EMP_ID: 071382660 DEPARTMENT: SALES CURR_SAL: 25000
If a record has both identified and positional values, the MODIFY request identifies the positional values in the following way: it notes the last explicitly identified value to precede the positional values in the record. It then identifies the positional values by the order of field names that follow the name of the explicitly identified field in the FREEFORM list.
For example, a MODIFY request has this FREEFORM statement:
FREEFORM EMP_ID FIRST_NAME LAST_NAME CURR_SAL
The transaction data source contains this record:
FIRST_NAME=DAVID, MCHENRY, 21300.45, $
The first value, DAVID, is explicitly identified as the FIRST_NAME field. The request identifies the next value, MCHENRY, as the LAST_NAME field because LAST_NAME follows FIRST_NAME on the FREEFORM list. Similarly, the request identifies 21300.45 as the CURR_SAL field. The EMP_ID field retains the value it was last given.
If the MODIFY request has no FREEFORM statement, it identifies positional values by the order of field names declared in the Master File. If a record consists of only positional values, the request assigns the first field name in the Master File to the first value, the second field name to the second value, and so on. For example, a transaction data source contains this record:
071382660, MCHENRY, DAVID, $
The request identifies the first value, 071382660, as the EMP_ID field because EMP_ID is the first field in the Master File. The next value, MCHENRY, is the LAST_NAME field (the second field in the Master File). DAVID becomes the FIRST_NAME field, the third field in the Master File (the EMPLOYEE Master File is shown in Master Files and Diagrams).
If a record has both identified values and positional values, the MODIFY request identifies the positional values the following way: it notes the last explicitly identified value to precede the positional values in the record. It then identifies the positional values by the order of field names that follow the name of the explicitly identified field in the Master File. For example, the transaction data source contains this record:
FIRST_NAME=DAVID, 820406, PRODUCTION, $
The first value, DAVID, is explicitly identified as the FIRST_NAME field. The request identifies the next value, 820406, as the HIRE_DATE field because HIRE_DATE follows FIRST_NAME in the Master File. Similarly, the request identifies PRODUCTION as the DEPARTMENT field.
If a field value is missing for a particular record, you must explicitly identify the name of the next field in the record. For instance, a FREEFORM statement specifies the following:
FREEFORM EMP_ID CURR_SAL DEPARTMENT
One record lacks a CURR_SAL value. Type the record this way
071382660, DEPARTMENT=PRODUCTION, $
where 071382660 is an EMP_ID value. The CURR_SAL field remains inactive and will not change any CURR_SAL values in the data source.
If you are adding segment instances to the data source, the instance fields not receiving a value become:
An important exception: If you omit fields from the beginning of a record, the fields retain the values last assigned to them from a previous record. For example, a transaction data source contains these two records:
EMP_ID=071382660, PAY_DATE=820831, GROSS=1045.60, $ PAY_DATE=820831, GROSS=1047.20, $
The second record is lacking an EMP_ID value. Nevertheless, since EMP_ID is at the beginning of the record, it retains its value of 071382660 for the second record and remains active.
If you use double commas to mark an absent value, the value becomes a blank character string if alphanumeric, and zero if numeric. Note that the request can use this value to modify the data source. For example, in the record
071382660,, PRODUCTION, $
the two commas mark the position of the absent CURR_SAL field. The CURR_SAL field becomes active and can change an employee salary to $0.00.
You may use FREEFORM statements as phrases in MATCH and NEXT statements. These phrases are useful if you want to read records selectively if a particular segment instance exists in the data source (or is confirmed not to be in the data source).
For example, the following MODIFY request adds records of employees' monthly pay to the data source:
MODIFY FILE EMPLOYEE FREEFORM EMP_ID PAY_DATE MATCH EMP_ID ON NOMATCH REJECT ON MATCH CONTINUE MATCH PAY_DATE ON MATCH REJECT ON NOMATCH FREEFORM ON MONTHPAY GROSS ON NOMATCH INCLUDE DATA ON EMPPAY END
The data is kept in two transaction data sources: EMPPAY and MONTHPAY. The EMPPAY data source contains the employee IDs and the date each employee was paid. The MONTHPAY data source contains the amount each employee was paid (GROSS). The request must confirm for every EMPPAY transaction that:
Once the request has confirmed this, it can read the monthly pay from the MONTHPAY data source
ON NOMATCH FREEFORM ON MONTHPAY GROSS
and record it in the data source:
ON NOMATCH INCLUDE
How to: |
The PROMPT statement prompts the user on a terminal for incoming data one field at a time. Use this statement for requests that may be run on line terminals or by users having no access to the FIDEL facility. If the requests will be run exclusively by users on full-screen terminals with access to FIDEL, use the CRTFORM statement instead. The FIDEL facility and the CRTFORM statement are the subjects of Designing Screens With FIDEL.
The syntax of the PROMPT statement is
PROMPT {field-1[.text.] field-2[.text.] ... field-n[.text.]|*}
where:
Are the names of the fields for which you are prompting. An asterisk * instead of field names prompts for all fields described in the Master File in the order that they are declared.
The list of fields must fit on one line. If the list is too long to fit on one line, use a PROMPT statement for each line. For example:
PROMPT EMP_ID LAST_NAME FIRST_NAME PROMPT DEPARTMENT CURR_SAL
Each field in the Master File with a text field format must appear in a separate PROMPT statement as the last field in the statement. When prompted for text, note that the length of the text entry is limited only by the amount of virtual storage space. The last line of text data that you enter must be followed by the end-of-text mark (%$) on a line by itself. For additional guidelines regarding fields with a text field format, see Entering Text Data Using TED.
Is optional prompting text, up to 38 characters per field.
Do not place an END statement at the end of the request. Conclude the request with the DATA statement.
The following request updates information about employees' department assignments, salaries, and job codes:
MODIFY FILE EMPLOYEE PROMPT EMP_ID DEPARTMENT CURR_SAL CURR_JOBCODE MATCH EMP_ID ON MATCH UPDATE DEPARTMENT CURR_SAL CURR_JOBCODE ON NOMATCH REJECT DATA
When you execute the command, the following appears on your screen
> EMPLOYEE ON 06/19/98 AT 14.38.27 DATA FOR TRANSACTION 1
MP_ID= >
where:
Is the system name of the data source (in this case, the TSO name).
Is the date and time that FOCUS opened the data source: June 19, 1998 at 2:38:27 p.m.
Notifies the user that the request is prompting for the first transaction. Each cycle of prompts constitutes one transaction. When the next transaction begins, the request prompts again for the first field in the cycle. In this request, the EMP_ID, DEPARTMENT, CURR_SAL, and CURR_JOBCODE prompts constitute one transaction. When the next transaction begins, the request prompts for the EMP_ID field again.
Is the default prompt for the EMP_ID field (the field name).
As each prompt appears, enter the value for the field requested. When you finish entering values, end execution by entering End or Quit at any prompt. The following is a sample execution of the request shown above (user input is shown in lowercase; computer responses are in uppercase):
> EMPLOYEE ON 06/19/98 AT 14.38.27 DATA FOR TRANSACTION 1 EMP_ID = > 071382660 DEPARTMENT = > mis CURR_SAL = > 22500.35 CURR_JOBCODE = > b12 DATA FOR TRANSACTION 2 EMP_ID = > end TRANSACTIONS: TOTAL= 1 ACCEPTED= 1 REJECTED= 0 SEGMENTS: INPUT= 0 UPDATED= 1 DELETED= 0
When you design a request that prompts for fields and validates them, we recommend that validating the field values after every prompt is recommended. This saves extra typing if one of the field values proves invalid. Validation tests are discussed in Validating Transaction Values: The VALIDATE Statement.
If the Master File lists a date format with a translation option (see the Describing Data manual), you may type the date as it appears in reports generated by TABLE requests (but do not type the commas in the dates). Note that the date format must have had the translation option before the FOCUS data source was created.
For example, assume you change the format of the HIRE_DATE field in the EMPLOYEE Master File from I6YMD to YMDT. You then write a request that creates a new EMPLOYEE data source. The request begins with this FIXFORM statement:
PROMPT EMP_ID FIRST_NAME LAST_NAME HIRE_DATE
When you execute the request, a sample transaction might appear like this:
DATA FOR TRANSACTION 2 EMP_ID = > 444555666 FIRST_NAME = > dorothy LAST_NAME = > tailor HIRE_DATE (YMDT) = > 98 jun 13
Note that you can also respond to the HIRE_DATE prompt with the value 980613.
You may prompt for the same group of fields repeatedly. This is convenient when you want to modify a child segment chain. You prompt once for the key field of the parent instance and prompt repeatedly for the values of the child instances. Without repeating groups, you must prompt for the key field of the parent instance each time you prompt for a child instance.
For example, a MODIFY request updates employees' monthly pay. It first prompts for an employee ID, then for 12 pairs of fields: the first field in each pair is a pay date, the second field is the updated pay. The pay date and updated pay fields are a repeating group.
To specify a repeating group, use the following syntax
PROMPT factor (group)
where:
Is the number of times the group repeats.
Is the repeating group of fields.
Note that the transaction counter that appears during prompting counts each repeating group cycle of prompts as one transaction.
For example, the following request adds three instances of monthly pay (GROSS) for each employee:
MODIFY FILE EMPLOYEE PROMPT EMP_ID 3 (PAY_DATE GROSS) MATCH EMP_ID ON NOMATCH REJECT ON MATCH CONTINUE MATCH PAY_DATE ON MATCH REJECT ON NOMATCH INCLUDE DATA
This request prompts you for an employee ID, then a pay date, a monthly pay, a pay date, a monthly pay, and so on until it prompts you for three pay dates and three monthly pays. It then prompts you for the next employee ID.
The following is a sample execution of the previous request:
> EMPLOYEE ON 09/19/98 AT 15.01.38 DATA FOR TRANSACTION 1 EMP_ID = > 071382660 PAY_DATE = > 860131 GROSS = > 1360.50 DATA FOR TRANSACTION 2 PAY_DATE = > 860228 GROSS = > 1360.85 DATA FOR TRANSACTION 3 PAY_DATE = > 860331 GROSS = > 1360.50 DATA FOR TRANSACTION 4 EMP_ID = >
You can place multiple repeating groups in the same statement. This PROMPT statement contains two repeating groups:
PROMPT EMP_ID 3 (PAY_DATE GROSS) 2 (DAT_INC SALARY)
The statement prompts for:
You can nest repeating groups. For example, this prompt statement
PROMPT EMP_ID 6 (PAY_DATE 7 (DED_CODE DED_AMT))
prompts for:
When you run a request containing PROMPT statements, the request prompts you for each field by displaying the field name and an equal sign (=). However, you may specify your own prompt. The syntax is
PROMPT fieldname.text.
where:
Is the name of the field you are prompting for.
Is the text you want to appear as the prompt, up to 38 characters. Text must be enclosed within periods.
Note the following rules regarding prompt text:
This request adds new employees to the EMPLOYEE data source:
MODIFY FILE EMPLOYEE PROMPT EMP_ID.ENTER THE EMPLOYEE ID NUMBER:. PROMPT FIRST_NAME.ENTER FIRST NAME:. PROMPT LAST_NAME.ENTER LAST NAME:. PROMPT HIRE_DATE.WHAT DATE WAS EMPLOYEE HIRED?. PROMPT CURR_SAL.WHAT IS THE STARTING SALARY?.
MATCH EMP_ID ON MATCH REJECT ON NOMATCH INCLUDE DATA
Information Builders |