This example shows the use of derived fields and built-in functions.
OVRDBF FILE(FILEA) SHARE(*YES) OPNQRYF FILE(FILEA) MAPFLD((FLDX '%SIN(FLDM)')) CALL PGM(PGMF) /* Created using file FILEA as input */ CLOF OPNID(FILEA) DLTOVR FILE(FILEA)
In this case, you do not need to specify a different record format on the FORMAT parameter. (The default uses the format of the first file on the FILE parameter.) Therefore, the program is created by using FILEA. When using this technique, you must ensure that the field you redefine has attributes that allow the calculated value to process correctly. The least complicated approach is to create a separate file with the specific fields you want to process for each query.
You can also use this technique with a mapped field definition and the %XLATE function to translate a field so that it appears to the program in a different manner than what exists in the database. For example, you can translate a lowercase field so the program only sees uppercase.
The example described uses FILEA as an input file. You can also update data using the Open Query File (OPNQRYF) command. However, if you use a mapped field definition to change a field, updates to the field are ignored.