Loading Fixed Format Sequential Files Using MODIFY

How to:

Reference:

You can use the MODIFY command to load data into a single segment fixed format sequential data source. This enables you to created fixed format files with specific data types that are difficult to create using the HOLD FORMAT INTERNAL command.

The data is loaded in the order in which it is input. Update and delete operations are not supported.


Top of page

x
Syntax: How to Load Data Into Fixed Format Sequential Files Using MODIFY
MODIFY FILE filename
readcmd 
[COMPUTE field[/format1] = expression1;]
[VALIDATE testfld[/format2] = expression2;] 
modify_select_and_load_cmds 
DATA [ON ddname] [VIA CRTFORM]
END

where:

filename

Is the name of the fixed format sequential file to be loaded.

readcmd

Can be any supported MODIFY command for describing and reading incoming data such as CRTFORM, PROMPT, FREEFORM, or FIXFORM.

field

Can be an existing field in the data source, a temporary field, or an input field that requires calculations in order to be used in your MODIFY processing.

format1

Is the format you assign to a temporary field. Omit the format for existing fields.

testfld

Is a temporary field that will be used to accept or reject a transaction based on a calculation. If the value of the field is zero, the transaction will be rejected.

format2

Is the format you assign to the field. The format type must be numeric (I, F, D, or P. Specify the format only if you will use the field elsewhere in the request.

expression1, expression2

Are expressions supported in MODIFY.

modify_select_and_load_cmds

Can be any sequence of MODIFY commands that select transactions, such as MATCH and NEXT, as well as INCLUDE commands that load records into the data source.

ddname

Specifies the logical name of a data source that contains the transaction records.

For complete information about MODIFY facilities and commands, see your MODIFY documentation.


Top of page

x
Reference: Usage Notes for MODIFY of Fixed Format Sequential Data Sources


Example: Loading a Fixed Format Sequential Data Source Using MODIFY

The following Master File describes a fixed format data source called CENTFIX. This Master File is based on the Master File for the FOCUS data source named CENTINV, with the SUFFIX changed to FIX, the SEGTYPE changed to S0, and the DEFINE fields removed:

FILE=CENTFIX, SUFFIX=FIX, FDFC=19, FYRT=00
 SEGNAME=INVINFO, SEGTYPE=S0, $
  FIELD=PROD_NUM, ALIAS=PNUM, FORMAT=A4, INDEX=I,
   TITLE='Product,Number:',
   DESCRIPTION='Product Number', $
  FIELD=PRODNAME, ALIAS=PNAME, FORMAT=A30,
   WITHIN=PRODCAT,
   TITLE='Product,Name:',
   DESCRIPTION='Product Name', $
  FIELD=QTY_IN_STOCK, ALIAS=QIS, FORMAT=I7,
   TITLE='Quantity,In Stock:',
   DESCRIPTION='Quantity In Stock', $
  FIELD=PRICE, ALIAS=RETAIL, FORMAT=D10.2,
   TITLE='Price:',
   DESCRIPTION=Price, $
  FIELD=COST, ALIAS=OUR_COST, FORMAT=D10.2,
   TITLE='Our,Cost:',
   DESCRIPTION='Our Cost:', $

The following procedure loads the fixed format sequential file named CENTFIX. The input data is the same as the data used to load the FOCUS data source CENTINV. However, the record for PROD_NUM '1022' has been moved out of sequence, in front of the record for PROD_NUM '1020':

CMS FILEDEF CENTFIX DISK CENTFIX DATA A
CREATE FILE CENTFIX
MODIFY FILE CENTFIX
FIXFORM PROD_NUM/4 PRODNAME/30 QTY_IN_STOCK/7 PRICE/12 COST/12
CHECK OFF
MATCH PROD_NUM
ON MATCH REJECT
ON NOMATCH INCLUDE
DATA
10042 Hd VCR LCD Menu               43068      179.00      129.00
1006Combo Player - 4 Hd VCR + DVD   13527      399.00      289.00
1008DVD Upgrade Unit for Cent. VCR    199      199.00      139.00
1010750SL Digital Camcorder 300 X   10758      999.00      750.00
1012650DL Digital Camcorder 150 X    2972      899.00      710.00
1014340SX Digital Camera 65K P        990      249.00      199.00
1016330DX Digital Camera 1024K P    12707      279.00      199.00
1018250 8MM Camcorder 40 X          60073      399.00      320.00
1022120 VHS-C Camcorder 40 X         2300      399.00      259.00
1020150 8MM Camcorder 20 X           5961      319.00      240.00
1024110 VHS-C Camcorder 20 X         4000      349.00      249.00
1026AR3 35MM Camera 10 X            12444      129.00       95.00
1028AR2 35MM Camera 8 X             11499      109.00       79.00
1030QX Portable CD Player           22000      169.00       99.00
1032R5 Micro Digital Tape Recorder   1990       89.00       69.00
1034ZT Digital PDA - Commercial     21000      499.00      349.00
1036ZC Digital PDA - Standard       33000      299.00      249.00
END

The following messages indicate that the data was loaded:

 CENTFIX FIX       ON 07/14/2006 AT 10.17.05
(FOC1291) RECORDS AFFECTED DURING CURRENT REQUEST  : 17/INSERT
 TRANSACTIONS:         TOTAL =    17  ACCEPTED=    17  REJECTED=     0
 SEGMENTS:             INPUT =    17  UPDATED =     0  DELETED =     0

The following request reports from the CENTFIX fixed format file:

CMS FILEDEF CENTFIX DISK c:\ibi\apps\baseapp\centfix.ftm CENTFIX DATA A
TABLE FILE CENTFIX
SUM PRODNAME PRICE COST
BY PROD_NUM
END

The output is:

Product  Product                                              Our  
Number:  Name:                                 Price:         Cost:
-------  -------                               ------         -----
1004     2 Hd VCR LCD Menu                     179.00        129.00
1006     Combo Player - 4 Hd VCR + DVD         399.00        289.00
1008     DVD Upgrade Unit for Cent. VCR        199.00        139.00
1010     750SL Digital Camcorder 300 X         999.00        750.00
1012     650DL Digital Camcorder 150 X         899.00        710.00
1014     340SX Digital Camera 65K P            249.00        199.00
1016     330DX Digital Camera 1024K P          279.00        199.00
1018     250 8MM Camcorder 40 X                399.00        320.00
1020     150 8MM Camcorder 20 X                319.00        240.00
1022     120 VHS-C Camcorder 40 X              399.00        259.00
1024     110 VHS-C Camcorder 20 X              349.00        249.00
1026     AR3 35MM Camera 10 X                  129.00         95.00
1028     AR2 35MM Camera 8 X                   109.00         79.00
1030     QX Portable CD Player                 169.00         99.00
1032     R5 Micro Digital Tape Recorder         89.00         69.00
1034     ZT Digital PDA - Commercial           499.00        349.00
1036     ZC Digital PDA - Standard             299.00        249.00


Example: Reporting on a Fixed Format File That Is Out of Sequence

The CENTFIX data source was loaded with the record for PROD_NUM '1022' before the record for PROD_NUM '1020'. This does not cause a problem for reporting if the SEGTYPE is S0.

However, if the SEGTYPE for CENTFIX is S1, PROD_NUM is considered the key field, and is a candidate for keyed retrieval. Keyed retrieval assumes that the records are in order of the key field. If a value higher than the requested value is found in the data source, it is assumed that no record exists with the requested value, and retrieval halts.

Note: The SEGTYPE would be S1 if CENTFIX had been created as a HOLD file based on the CENTINV data source, and if the Master File had not been manually edited to change the SEGTYPE value.

Consider the following request that prints the record in which PROD_NUM equals '1020' and in which FIXRETRIEVE is ON (the default value):

TABLE FILE CENTFIX
PRINT PROD_NUM PRODNAME PRICE COST
WHERE PROD_NUM EQ '1020'
ON TABLE SET FIXRETRIEVE ON
END

The equality test does not retrieve the record with PROD_NUM='1020' because the keyed retrieval assumes the records are in order of the key field and stops searching when the record for PROD_NUM '1022' is found:

NUMBER OF RECORDS IN TABLE=        0  LINES=      0

Running the request with FIXRETRIEVE OFF retrieves the requested record even though it is out of sequence:

TABLE FILE CENTFIX
PRINT PROD_NUM PRODNAME PRICE COST
WHERE PROD_NUM EQ '1020'
ON TABLE SET FIXRETRIEVE OFF
END

The output is:

Product  Product                                              Our
Number:  Name:                                 Price:         Cost:
-------  -------                               ------         -----
1020     150 8MM Camcorder 20 X                319.00        240.00

Information Builders