Start of Content Area

Background documentation Function Module FILE_VALIDATE_NAME  Locate the document in its SAP Library structure

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

 

Example

The following graphic shows an example of the function principle of FILE_VALIDATE_NAME in a simplified way. In this example the operating system of the application server is Microsoft Windows.

 

This graphic is explained in the accompanying text

 

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

If a user now tries to access the file c:\tmp\my_file using the program,

      Firstly, function module FILE_VALIDATE_NAME is called.

      This then call function module FILE_GET_NAME which gets the logical file name and complete physical file name that match the operating system and returns this to FILE_VALIDATE_NAME.

      Now both physical names – that of the selection screen entry and that from returning the FILE_GET_NAME call – can be compared with each other.

      If these match then access is possible.

      If both file names do not match, function module FILE_VALIDATE_NAME triggers the exception VALIDATION_FAILED and the program can react to it and deny access to the file.

Directory Check

It is possible to restrict the check not to specific file names but to allow whole areas of the file system to be used as access target. In this case the check is only executed for the path of the stored directory.

This graphic is explained in the accompanying text

 

 

 

 

Prerequisite for this is that the attribute Data Format has the value DIR when defining the logical file name.

 

Normalization and Absolute File Names

Function module FILE_VALIDATE_NAME takes over another function:

If a user has specified a physical file name that contains operating system commands for navigating in the file system, then this navigation is interpreted before comparison with the result from FILE_GET_NAME. The physical file names that were found are also converted to absolute file names to make it possible to compare them properly. In the following example the global work directory is defined as c:\tmp.

This graphic is explained in the accompanying text

 

 

 

This ensures that it is only possible to access the intended file in this context.

 

Table: Interfaces of Function Module FILE_VALIDATE_NAME

·                            Import Parameters

·                            Function

·                            CLIENT

·                            Logical file names can also be defined as client-specific. This means it is possible to determine the client whose definition is to be used. The default is the current client as it is saved in system field SYMANDT.

·                            LOGICAL_FILENAME

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

·                            PARAMETER_1

·                            PARAMETER_2

·                            PARAMETER_3

·                            This means any values can be transferred to the placeholders labeled <PARAM_1> to <PARAM_3> in the physical file and path names.

·                            WITH_FILE_EXTENSION

·                            Indicates that the file format defined for the logical file name is to be attached to the physical file name as a file extension.

·                            USE_BUFFER

·                            Indicates that the control tables are to be buffered.

·                            ELEMINATE_BLANKS

·                            This flag specifies if all empty spaces are to be removed from the file name.

 

Note

The IMPORTING parameters are transferred by FILE_VALIDATE_NAME to FILE_GET_NAME to get a physical file name with which the content of the CHANGING parameter PHYISICAL_FILENAME is compared. You influence the determination of the file name that is used for validation.

 

CHANGING Parameters

Function

PHYSICAL_FILENAME

This indiactor describes the physical file name that FILE_VALIDATE_NAME compares with the settings of the transferred logical file name. The physical file name is of type CHANGING as it might need to be normalized.

 

EXCEPTIONS

Function

LOGICAL_FILENAME_NOT_FOUND

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

VALIDATION_FAILED

Triggered when the pysical file name in PHYSICAL_FILENAME does not correspond to the restrictions in LOGICAL_FILENAME.

 

 

End of Content Area