Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

logical file name

Former Member
0 Likes
1,514

Hi all,

how can find logical file name corresponding physical file name.

Regards,

Srinivasarao oleti

Hi all,

how can find logical file name corresponding physical file name.

Regards,

Srinivasarao oleti

2 REPLIES 2
Read only

Former Member
0 Likes
1,075

Using Logical Files in ABAP Programs

To create a physical file name from a logical file name in your ABAP programs, use the function module FILE_GET_NAME. To insert the function module call in your program, choose Edit ® Insert statement from the ABAP Editor screen. A dialog box appears. Select Call Function and enter FILE_GET_NAME. The parameters of this function module are listed below.

Import parameters

Parameters

Function

CLIENT

The maintenance tables for the logical files and paths are client-dependent. Therefore, the desired client can be imported. The current client is stored in the system field SY-MANDT.

LOGICAL_FILENAME

Enter the logical file name in upper case letters that you want to convert.

OPERATING_SYSTEM

You can import any operating system that is contained in the list in Transaction SF04 (see Assigning Operating Systems to Syntax Groups). The physical file name will be created according to the syntax group to which the operating system is linked. The default parameter is the value of the system field

SY-OPSYS.

PARAMETER_1

PARAMETER_2

If you specify these import parameters, the reserved words in the physical path names will be replaced by the imported values.

USE_PRESENTATION

_SERVER

With this flag you can decide whether to import the operating system of the presentation server instead of the operating system imported by the parameter OPERATING_SYSTEM.

WITH_FILE_EXTENSION

If you set this flag unequal to SPACE, the file format defined for the logical file name is appended to the physical file name.

Export Parameters

Parameters

Function

EMERGENCY_FLAG

If this parameter is unequal to SPACE, no physical name is defined in the logical path. An emergency physical name was created from table FILENAME and profile parameter DIR_GLOBAL.

FILE_FORMAT

This parameter is the file format defined for the logical file name. You can use this parameter, for example, to decide in which mode the file should be opened.

FILE_NAME

This parameter is the physical file name that you can use with the ABAP statements for working with files.

Exception Parameters

Parameters

Function

FILE_NOT_FOUND

This exception is raised if the logical file is not defined.

OTHERS

This exception is raised if other errors occur.

Suppose the logical file MYTEMP and the logical path TMP_SUB are defined as in the preceding topics and we have the following program:

DATA: FLAG,

FORMAT(3),

FNAME(60).

WRITE SY-OPSYS.

CALL FUNCTION 'FILE_GET_NAME'

EXPORTING

LOGICAL_FILENAME = 'MYTEMP'

OPERATING_SYSTEM = SY-OPSYS

PARAMETER_1 = '01'

IMPORTING

EMERGENCY_FLAG = FLAG

FILE_FORMAT = FORMAT

FILE_NAME = FNAME

EXCEPTIONS

FILE_NOT_FOUND = 1

OTHERS = 2.

IF SY-SUBRC = 0.

WRITE: / 'Flag :', FLAG,

/ 'Format :', FORMAT,

/ 'Phys. Name:', FNAME.

ENDIF.

The output appears as follows:

HP-UX

FLAG :

FORMAT : BIN

Phys. Name: /tmp/TEST01

In this example, the R/3 System is running under the operating system HP-UX, which is member of the syntax group UNIX. The logical file name MYTEMP with the logical path TMP_SUB is converted into a physical file name /tmp/TEST01 as defined for the syntax group UNIX. The field FNAME can be used in the further flow of the program to work with file TEST01 in directory /tmp.

Suppose we have a logical file name EMPTY with the physical file name TEST, connected to a logical path that has no specification of a physical path. If you replace the EXPORTING parameter 'MYTEMP' with 'EMPTY' in the above example, the output appears as follows:

HP-UX

FLAG : X

FORMAT :

Phys. Name: /usr/sap/S11/SYS/global/TEST

The system created an emergency file name, whose path depends on the installation of the current R/3 System.

Read only

0 Likes
1,075

hi Karthikeyan Pandurangan,

Thanks for immediate reply.

By using fm file_get_name , we can get physical file path from logical file name .

but i need to get logical file name from physical file path.

Regards,

Srinivasarao oleti