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

return file path

Former Member
0 Likes
1,041

How to return file path without the filename c:\folder1\folder2\folder3?

Pass in c:\folder1\folder2\folder3\abc.txt

Want to return c:\folder1\folder2\folder3

Any code sample or function module?

9 REPLIES 9
Read only

Former Member
0 Likes
990

Hi,

SO_SPLIT_FILE_AND_PATH

Read only

Former Member
0 Likes
990

hi paul,

use this code,,this will solve ur probelm.

DAAT : F_NAME LIKE RLGRAP-FILENAME.

parameter: f_path like rlgrap-filename obligatory.

call function 'F4_FILENAME'

exporting

program_name = sy-repid

dynpro_number = sy-dynnr

importing

file_name = f_name

exceptions

others = 1.

if sy-subrc ne 0 .

write : / 'Enter File Name'.

endif.

With Regards,

T.Durai murugan.

Read only

keerthy_k
Product and Topic Expert
Product and Topic Expert
0 Likes
990

Hi,

u can use either of these FM's

TRINT_SPLIT_FILE_AND_PATH or

SO_SPLIT_FILE_AND_PATH

Keerthi

Read only

Former Member
0 Likes
990

Function Modules hampers the performance of your program because the memory of the function group get loaded into you program at runtime.So for small requirement avoid FM.. use codes.

DATA:w_path(255) TYPE c VALUE 'c:\folder1\folder2\folder3\abc.txt',
     w_file(255) TYPE c,
     w_len TYPE i.

w_len = strlen( w_path ).

DO.

  IF w_path+w_len(1) = '\'.
    w_file = w_path+w_len.
    w_path+w_len = space.
    EXIT.
  ENDIF.
  SUBTRACT 1 FROM w_len.
  IF w_len LT 1.
    EXIT.
  ENDIF.
ENDDO.


WRITE : w_path,w_file+1.

Try out these codes it will work.

Regards,

Gurpreet

Read only

former_member203501
Active Contributor
0 Likes
990

please search before posting ....here is one of the search result

Read only

Former Member
0 Likes
990

Hi,

Call the method DIRECTORY_BROWSE from class CL_GUI_FRONTEND_SERVICES.

Regards,

Shailaja

Read only

Former Member
0 Likes
990

hi ,


use below fm to browser for foler or path
TMP_GUI_BROWSE_FOR_FOLDER 

or use the below fm to browse the path or get the path by passing full file length

TMP_GUI_GET_TEMPPATH 

Regards,

Prabhudas

Read only

former_member156446
Active Contributor
0 Likes
990

Try this code:

*FORM fr_f4_app_server  CHANGING p_path1.
*
*  DATA: lv_input TYPE dxfields-longpath,
*        lv_output TYPE dxfields-longpath.
*
*  lv_input = p_path1.
*
*  CALL FUNCTION 'F4_DXFILENAME_TOPRECURSION'
*    EXPORTING
*      i_location_flag = 'A'
*      i_path          = lv_input
*    IMPORTING
*      o_path          = lv_output
*    EXCEPTIONS
*      rfc_error       = 1
*      error_with_gui  = 2
*      OTHERS          = 3.
*  IF sy-subrc EQ 0.
*    DATA: lv_path TYPE rlgrap-filename.
*    lv_path  = lv_output.
*
*    CALL FUNCTION 'LIST_SPLIT_PATH'
*      EXPORTING
*        filename = lv_path
*      IMPORTING
*        pathname = lv_path.
*    IF sy-subrc EQ 0.
*      p_path1 = lv_path.
*    ENDIF.
*  ENDIF.
*
*ENDFORM.                    " FR_F4_APP_SERVER

Read only

Former Member
0 Likes
990

Hi,

U can use both the fms to get the op as e.x:

TRINT_SPLIT_FILE_AND_PATH or

SO_SPLIT_FILE_AND_PATH

If u pass the parameter as c:\data\abc.text then u will get

STRIPPED_NAME ABc.TXT

FILE_PATH C:\DATA\

Regards