When this program is executed, the amount of space allocated for the file PARTS depends on the relative record numbers of the records that are written to the file.
For example, a procedure that updates the file PARTS when new stock is ordered might contain the following: ORDER_PARTS: PROCEDURE (ORDERED_AMOUNT, PART_NUMBER); %INCLUDE PARTLIST; /* Declaration of PARTLIST */ DECLARE (ORDERED_AMOUNT, PART_NUMBER) FIXED BIN(15); DECLARE PARTS FILE RECORD DIRECT UPDATE; OPEN FILE(PARTS); READ FILE(PARTS) INTO(PARTLIST) KEY(PART_NUMBER); PARTLIST. ON_ORDER + ORDERED_AMOUNT; REWRITE FILE(PARTS) FROM(PARTLIST); CLOSE FILE(PARTS); END; In this example, the procedure ORDER_PARTS receives as its parameters the order quantity and the part number.
It reads the record associated with the part number from the file, adds the order quantity to the existing quantity, and rewrites the record.
Reading a Relative File Sequentially You can access a relative file sequentially as well as by key.
You can also specify the extension size by using the DCL command SET FILE/EXTENSION=n.
To determine the value to be assigned to the EXTENSION attribute, multiply the record size by the number of records to be added.