Function Module FILE_GET_NAME
Application programs use logical file names in connection with the function module FILE_GET_NAME. Based on the definitions stored in Customizing, the function module creates the relevant physical name for a logical file name at runtime.
The following table gives an overview of the import and export parameters as well as the exception conditions of the function module.
Interfaces of the Function Module FILE_GET_NAME
Import Parameter |
Function |
CLIENT |
Logical file names can also be defined as client-specific. The function module uses the definition of the client specified by this parameter. The default value is the current client as specified in system field SY‑MANDT. |
LOGICAL_FILENAME |
Passes the logical file name. (Uppercase) |
OPERATING_SYSTEM |
Specifies the operating system for which the file name is to be determined. The default value is the operating system of the application server, as specified in system field SY OPSYS. |
PARAMETER_1 PARAMETER_2 PARAMETER_3 |
Can pass any values to the placeholders labeled <PARAM_1> to <PARAM_3> in the physical file and path names. |
USE_PRESENTATION |
Specifies that the file name is to be determined based on the operating system of the presentation server. The operating system imported using the parameter OPERATING_SYSTEM is not to be used. |
WITH_FILE_EXTENSION |
Specifies that the file format defined for the logical file name is to be appended to the physical file name as a file name extension. Exception: If the data format of the logical file name is DIR, the system ignores the parameter WITH_FILE_EXTENSION (see parameter INCLUDING_DIR). |
USE_BUFFER |
Specifies that the control tables are to be buffered. |
ELEMINATE_BLANKS |
Specifies whether all spaces are to be removed from the returned file name. |
INCLUDING_DIR |
In most application cases, the application that calls the function module FILE_GET_NAME requires a complete physical file name for additional processing, for example, for use with OPEN DATASET or similar commands. The data format DIR was introduced as part of the validation of user entries. If a logical file name has the data format DIR, the result of FILE_GET_NAME is a physical path name. By default, the indicator INCLUDING_DIR is not set. In this way, the calling program specifies that it requires a physical file name. Since a logical file name with the data format DIR does not fulfill this requirement, the system triggers the exception FILE_NOT_FOUND. If the calling application sets the INCLUDING_DIR indicator, it specifies that it can also process a physical file path as the result of FILE_GET_NAME. In this case the determined path name is returned to the calling application.
If the INCLUDING_DIR indicator is set, the system ignores the parameter WITH_FILE_EXTENSION. It may return an empty file name to the calling application. In this case, the logic does not execute EMERGENCY_FLAG, in accordance with the description of the export parameter. For more information about validating user input, see the Checking Directories section of Function Module FILE_VALIDATE_NAME. |
Export Parameter |
Function |
EMERGENCY_FLAG |
If the value is not SPACE, the system could not determine a physical file name for the logical file name for this operating system from the specifications in Customizing (for more information, see the note in connection with the interface documentation). In this case, the system uses the path specified in the profile parameter DIR_GLOBAL as the physical path. |
FILE_FORMAT |
This parameter contains the file format defined for the logical file name. You can use this parameter, for example, to specify the mode in which the file is to be opened. |
FILE_NAME |
This parameter contains the complete physical file name, including the path. |
Exception |
Function |
FILE_NOT_FOUND |
Triggered if the logical file name is not defined. |
OTHERS |
Triggered if other errors occur. |

The following are possible reasons for the function module being unable to determine a physical path for this operating system (see parameter EMERGENCY_FLAG):
● The operating system is not defined in the control tables.
● The operating system is defined but not assigned to a syntax group.
● No physical path is assigned to the logical path for syntax group.
● No logical path is assigned to the logical file name.
The following definitions exist for the logical file DATA_FILE and the logical path DATA_PATH:
DATA_FILE |
Physical File |
File<PARAM_1> |
||
|
Data Format |
BIN |
||
|
Logical Path: |
DATA_PATH |
||
DATA_PATH |
Syntax Group: |
UNIX |
Physical Path: /tmp/<FILENAME> |
|
|
Syntax Group: |
Microsoft Windows NT |
Physical Path: c:\tmp\<FILENAME> |
|
The operating system of the application server is assigned to syntax group UNIX, the operating system of the presentation server is assigned to the syntax group Windows NT. The two following calls of the function module would produce the specified return values.
CALL FUNCTION 'FILE_GET_NAME' EXPORTING PARAMETER_1 = '01' IMPORTING EXCEPTIONS |
Return Values:
Variable |
Contents |
ld_emergency_flag |
Space |
ld_file_format |
BIN |
ld_file_name |
/tmp/file01 |
CALL FUNCTION 'FILE_GET_NAME' EXPORTING IMPORTING EXCEPTIONS
|
Return Values:
Variable |
Contents |
ld_emergency_flag |
Space |
ld_file_format |
BIN |
ld_file_name |
C:\tmp\FILE.BIN |