Function Module FILE_VALIDATE_NAME

Use

Using a logical file name, the function module FILE_VALIDATE_NAME checks if a physical file name corresponds to the rules of the logical file name.

Example

The figure below uses a simplified example to illustrate the functional principle of FILE_VALIDATE_NAME. In this example the operating system of the application server is Microsoft Windows.

Figure 1: Functional Principle

The example program ACCESS_APPLSERVER_FILE knows the logical file name PHYS_FILE_VALIDATION as a constant value.

If a user accesses the file c:\tmp\my_file with the program, the following steps are processed:

  • The system calls the function module FILE_VALIDATE_NAME.

  • This calls the function module FILE_GET_NAME. The system uses this function module to determine the complete physical file name for the logical file name and the appropriate operating system. The function module returns this value to FILE_VALIDATE_NAME.

  • The system compares the two physical file names - on the one hand, from the input on the selection screen, and on the other hand, the value returned from calling FILE_GET_NAME.

  • If the two file names match, the user can access the file.

  • If the two file names do not match, function module FILE_VALIDATE_NAME triggers the exception VALIDATION_FAILED. The program can deny the user access to the file.

Checking Directories

You do not need to restrict the check to specific file names, but can allow whole areas of the file system to be used as the access target. In this case, the system performs the check only for the path of the stored directory:

Figure 2: Check

The prerequisite for this is that the logical file name has the data format DIR.

Normalization and Absolute File Names

Function module FILE_VALIDATE_NAME also performs another function:

If a user has specified a physical file name that contains operating system commands for navigating in the file system, the system interprets this navigation before the comparison with the result from FILE_GET_NAME. The system also converts the physical file name that was found to an absolute file name to allow a proper comparison. In the following example, the global work directory is c:\tmp.

Figure 3: Normalization

This ensures that the user can access only the intended files in this context.

Import Parameter

Function

CLIENT

Logical file names can be client-specific. The system 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

Logical file name that is to be used for validation (uppercase is required).

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 the system field SY OPSYS.

PARAMETER_1

PARAMETER_2

PARAMETER_3

Can pass any values to the placeholders marked with <PARAM_1> to <PARAM_3> in the physical file and path names.

WITH_FILE_EXTENSION

Indicates that the extension of the file name format of the logical file name is to be appended to the physical file name.

USE_BUFFER

Indicates that the control tables are to be buffered.

ELEMINATE_BLANKS

Defines whether all spaces are to be removed from the returned file name.

Note

The import parameters are passed by FILE_VALIDATE_NAME to FILE_GET_NAME, to determine a physical file name. The system compares this to the content of the CHANGING parameter PHYSICAL_FILENAME. You therefore influence the determination of the physical file name that is used for validation.

Export Parameter

Function

VALIDATION_ACTIVE

If the value is not SPACE, the system could not determine a physical file name for the logical file name or an assigned alias.

TS_ALIAS

Sorted table of the defined aliases (including those for the passed logical file name).

CHANGING Parameter

Function

PHYSICAL_FILENAME

Describes the physical file name that FILE_VALIDATE_NAME compares with the settings of the transferred logical file name. Since the physical file name might need to be normalized, it has the type CHANGING.

Exception

Function

LOGICAL_FILENAME_NOT_FOUND

Triggered if the function module FILE_GET_NAME has propagated the exception FILE_NOT_FOUND to FILE_VALIDATE_NAME.

VALIDATION_FAILED

Triggered if the physical file name in PHYSICAL_FILENAME does not correspond to the restrictions in LOGICAL_FILENAME.