Application Development 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: 

How to find out the file name

0 Kudos

Hi,

In selection screen (parameter) user will give input TXT file from presentation server to upload to SAP. I need to capture the file name only but not the path and need to concatenate with date stamp and need to download error log in XLS file to presentation server.

How to find out the file name from selection screen?

I searched SCN threads but not found relavant solution.

Thanks,

R Kumar

4 REPLIES 4

Former Member
0 Kudos

Kumar,

you can use this fm TRINT_SPLIT_FILE_AND_PATH

Thanks

Bala Duvvuri

krishnendu_laha
Active Contributor
0 Kudos

hello,

Please check the class CL_GUI_FRONTEND_SERVICES....there you will find suitable methods for GUI related transaction.

Thanks

Former Member
0 Kudos

Its difficult to get what user will be giving file name for uploading and from which particular folder .

Example -File path-

C:\ABC\upload.txt

Declare a internal table with atleast 10 fields of 20 Char.(As per you require)

And then after getting the file name .Try to use SPLIT command with '\' .

As each folder and file name is seperated by '\' and get them in internal table .

Check for filed with extension .txt after looping and you will get the file name .

Hope u got an idea.

After split ,itab will have values like for file path : C:\ABC\upload.txt

Itab-first = C:

Itab-second = ABC

Itab-third = upload.txt

Itab-fourth = Blank

Itab-fifth =Blank.

So Itab-third contains the file name,Which you want .

Use CONCATENATE statement to add date etc for the file name.

Thanks!

bbalci
Contributor
0 Kudos

Hi

This code gets only filename from selection screen :

REPORT x.

PARAMETERS p_file(100).

DATA : gv_full_path LIKE ibipparms-path,

gv_full_path_string TYPE string,

gv_filename(100),

gv_file_ext(3).

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

  • Ask user to select file with a popup :

CALL FUNCTION 'F4_FILENAME'

IMPORTING

file_name = gv_full_path.

  • Get filename from path :

gv_full_path_string = gv_full_path.

CALL FUNCTION 'CH_SPLIT_FILENAME'

EXPORTING

complete_filename = gv_full_path_string

IMPORTING

extension = gv_file_ext

name = gv_filename.

CONCATENATE gv_filename '.' gv_file_ext INTO gv_filename.

p_file = gv_filename.

I hope it helps.