4.3.1 Adding Records to a File (One at a Time)
Construct a function to add records to one file.
Physical file CUSMST (customer master file)
GROUP_BY NAME(#CUSTOMER) FIELDS(#CUSTNO #NAME #ADDL1
CHANGE FIELD(#CUSTOMER) TO(*DEFAULT)
REQUEST FIELDS(#CUSTOMER) EXIT_KEY(*YES *EXIT)
INSERT FIELDS(#CUSTOMER) TO_FILE(CUSMST)
Points to Note:
- Program keeps adding records until the EXIT or MENU function key is used (BEGIN_LOOP and END_LOOP commands).
- The EXIT and MENU function keys are enabled on the REQUEST screen. If either key is used the function will end. The values shown are defaults and would not normally be shown.
- The VAL_ERROR parameter of the INSERT command is a default and would not normally be shown. If a validation error (file or dictionary level) is detected by the INSERT command the last display (the REQUEST command) will receive control to display the error details for correction.