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

filename from complete file path

Former Member
0 Likes
2,932

Hi,

can anybody let me know the method to get the filename from the complete filepath( this path includes both directory as well as filename)

regards.

venkat.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,228

Hi venkat,

1. Use the FM

PC_SPLIT_COMPLETE_FILENAME

2. This will give u the following things:

DRIVE

EXTENSION

NAME

NAME_WITH_EXT

PATH

regards,

amit m.

Hi,

can anybody let me know the method to get the filename from the complete filepath( this path includes both directory as well as filename)

regards.

venkat.

5 REPLIES 5
Read only

Former Member
0 Likes
1,229

Hi venkat,

1. Use the FM

PC_SPLIT_COMPLETE_FILENAME

2. This will give u the following things:

DRIVE

EXTENSION

NAME

NAME_WITH_EXT

PATH

regards,

amit m.

Read only

Former Member
0 Likes
1,228

hi thr

use the FM

PC_SPLIT_COMPLETE_FILENAME

pls reward if helpful

regards

niharika

Read only

Former Member
0 Likes
1,228

Hi,

Check the below code:

data : ig_path type standard table of tp_path,
       wg_path type tp_path.

data : g_lines     type i          ,
       g_filename  type string     .

parameter : p_input type rlgrap-filename.

  split p_input at '\' into table ig_path.

  describe table ig_path lines g_lines.
  read table ig_path index g_lines into wg_path.
  g_filename = wg_path-val.

write : g_filename.

Regards,

Raghu

Read only

Former Member
0 Likes
1,228

hi,

general file path will be

/home_STAR/GD2/zfile.txt

and file name will be zfile.txt

so split the directory into variables

data: lc_colon typec char1 value '/'.

split lw_dir at at lc_colon into w_var1, w_var2, w_var3.

w_var3 will be the file name.

Regards,

Sriram

Read only

rainer_hbenthal
Active Contributor
0 Likes
1,228

path = 'c:/test/xyz.txt'.

REPLACE ALL OCCURRENCES OF '/' in path with '\'.

find all OCCURRENCES OF '\' in path MATCH OFFSET off.
if sy-subrc > 0.
  fname = path.
else.
  off = off + 1.
  fname = path+off.
endif.