EXTFILE キーワードは、どのライブラリーのどのファイルがオープンされるかを指定します。
ファイル名
ライブラリー名/ファイル名
*LIBL/ファイル名
特殊値 *EXTDESC を使用すると、EXTDESC キーワードのパラメーターが EXTFILE キーワードに対しても使用されることを指定できます。 Finput if f 10 disk extfile(filename)
ファイル名 フィールドの値が実行時に MYLIB/MYFILE
であれば、RPG はファイル MYLIB/MYFILE をオープンすることになります。コマンド
OVRDBF MYFILE OTHERLIB/OTHERFILE が使用された場合は、オープンされる実際のファイルは
OTHERLIB/OTHERFILE になります。INPUT はこの RPG
ソース・メンバーの中で使用されている唯一の名前であるため、名前 INPUT に対してはいかなる一時変更も無視されることに注意してください。 * The name of the file is known at compile time
Ffile1 IF F 10 DISK EXTFILE('MYLIB/FILE1')
Ffile2 IF F 10 DISK EXTFILE('FILE2')
* The name of the file is in a variable which is
* in the correct form when the program starts.
* Variable "filename3" must have a value such as
* 'MYLIB/MYFILE' or 'MYFILE' when the file is
* opened during the initialization phase of the
* RPG program.
Ffile3 IF F 10 DISK EXTFILE(filename3)
* The library and file names are in two separate variables
* The USROPN keyword must be used, so that the "filename4"
* variable can be set correctly before the file is opened.
Ffile4 IF F 10 DISK EXTFILE(filename4)
F USROPN
D filename4 S 21A
* EXTFILE variable "filename4" is set to the concatenated
* values of the "libnam" and "filnam" variables, to form
* a value in the form "LIBRARY/FILE".
C EVAL filename4 = %trim(libnam) + '/' + filnam
C OPEN file4
* At compile time, file MYLIB/MYFILE5 will be used to
* get the external definition for the file "file5",
* due to the EXTDESC keyword.
* At runtime, the file MYLIB/MYFILE5 will be opened,
* due to the EXTFILE(*EXTDESC) keyword.
Ffile5 if e DISK
F EXTFILE(*EXTDESC)
F EXTDESC('MYLIB/MYFILE5')