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: 

selection of Folder/File name using the same Fun.Module

Former Member
0 Kudos
181

Please let me know if there is a function module which can fetch folder name/File name from the directory path when f4 option of selection screen field is selected. Currently I am able to get the file name using FM F4_DXFILENAME_4_DYNP but the requirment is like I have to select either folder name or the file name depending on user selection.

Note: Please let me know if there is a single Function module which can get folder name or the file name based on the user selection.i.e, if the user want to select a folder he can select or he can select files in the folder for processing

1 ACCEPTED SOLUTION

athavanraja
Active Contributor
0 Kudos
132

there is no single fm.

you should use may be two input fields one for folder and one for filename.

for foler use : cl_gui_frontend_services=>directory_browse

for file name : cl_gui_frontend_services=>file_open_dialog

you could have continued in the old thread

Regards

Raja

5 REPLIES 5

athavanraja
Active Contributor
0 Kudos
133

there is no single fm.

you should use may be two input fields one for folder and one for filename.

for foler use : cl_gui_frontend_services=>directory_browse

for file name : cl_gui_frontend_services=>file_open_dialog

you could have continued in the old thread

Regards

Raja

0 Kudos
132

when ever method cl_gui_frontend_services=>directory_browse

to get folder name is used, I am getting a windows dialog to select the folder name. When I select the folder name, The return parameter 'selected_folder' is not returning the selected folder name. Please let me know if there is something else that has to be done inorder to get the folder name.

0 Kudos
132

Hi Sridhar,

Immediately after the method call cl_gui_frontend_services=>directory_browse, have the following method call,

CALL METHOD cl_gui_cfw=>flush.

And then your variable will get filled with 'selected_folder'...

Hope this helps..

Sri

Former Member
0 Kudos
132

Hi,

Try with the below logic:

parameters: p_path like rlgrap-filename

at selection-screen on value-request for p_path.

*-Identify the path

perform get_path.

call function 'F4_FILENAME'

exporting

program_name = syst-cprog

dynpro_number = syst-dynnr

field_name = ' '

importing

file_name = p_path.

Thanks

Eswar

Former Member
0 Kudos
132

Hi sridhar

try this:

PARAMETER : TXT_FILE(100).

AT SELECTION-SCREEN ON VALUE-REQUEST FOR TXT_FILE.

PERFORM GETFILE.

start-of-selection.

PERFORM GETDATA.

FORM GETDATA.

DATA : FILENAME TYPE STRING.

FILENAME = TXT_FILE.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = FILENAME

FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = 'X'

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • CHECK_BOM = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

TABLES

DATA_TAB = IT_UPLOAD

  • EXCEPTIONS

  • FILE_OPEN_ERROR = 1

  • FILE_READ_ERROR = 2

  • NO_BATCH = 3

  • GUI_REFUSE_FILETRANSFER = 4

  • INVALID_TYPE = 5

  • NO_AUTHORITY = 6

  • UNKNOWN_ERROR = 7

  • BAD_DATA_FORMAT = 8

  • HEADER_NOT_ALLOWED = 9

  • SEPARATOR_NOT_ALLOWED = 10

  • HEADER_TOO_LONG = 11

  • UNKNOWN_DP_ERROR = 12

  • ACCESS_DENIED = 13

  • DP_OUT_OF_MEMORY = 14

  • DISK_FULL = 15

  • DP_TIMEOUT = 16

  • OTHERS = 17

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDFORM.

FORM GETFILE.

CALL FUNCTION 'WS_FILENAME_GET'

EXPORTING

  • DEF_FILENAME = ' '

DEF_PATH = '.'

  • MASK = ' '

  • MODE = ' '

  • TITLE = ' '

IMPORTING

FILENAME = TXT_FILE

  • RC =

  • EXCEPTIONS

  • INV_WINSYS = 1

  • NO_BATCH = 2

  • SELECTION_CANCEL = 3

  • SELECTION_ERROR = 4

  • OTHERS = 5

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDFORM.

<b>This is a part of my BDC program its working for me u try n reply if it works for u.</b>

regards

vijay