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

To get the File path dynamically

Former Member
0 Likes
3,028

Hi all,

I am using the <b>Gui_upload function, and i want to get the file dynamically from the search help</b>,

So please help me in finding the answer.

Thanks,

Girish

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,205

Hai Girish

Check the following Code

DATA: I_FILETABLE TYPE FILETABLE,

V_RC TYPE I.

PARAMETERS: P_FILE LIKE RLGRAP-FILENAME. "local file with contracts

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.

CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG

EXPORTING

WINDOW_TITLE = 'Find File'

DEFAULT_EXTENSION = 'C:\'

DEFAULT_FILENAME = ''

FILE_FILTER = ',..'

  • INITIAL_DIRECTORY =

  • MULTISELECTION =

  • WITH_ENCODING =

CHANGING

FILE_TABLE = I_FILETABLE

RC = V_RC

  • USER_ACTION =

  • FILE_ENCODING =

EXCEPTIONS

FILE_OPEN_DIALOG_FAILED = 1

CNTL_ERROR = 2

ERROR_NO_GUI = 3

NOT_SUPPORTED_BY_GUI = 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.

READ TABLE I_FILETABLE INTO P_FILE INDEX 1.

Thanks & Regards

Sreenivasulu P

Message was edited by: Sreenivasulu Ponnadi

13 REPLIES 13
Read only

Former Member
0 Likes
2,205
  • Set the input file path dynamically depending on the client

CONCATENATE c_path sy-sysid c_unix INTO v_file.

p_path = v_file.(according to ur values)

Read only

0 Likes
2,205

use

CL_GUI_FRONTEND_SERVICES=>File_open_dialog method.

Regards

Raja

Read only

Simha_
Product and Topic Expert
Product and Topic Expert
0 Likes
2,205

Hi,

Use F4_FILENAME to get the path..

and pass it to the GUI_UPLOAD.

Regards,

Simha.

Read only

Former Member
0 Likes
2,205

hi,

see if this code helps


DATA: gv_FILENM(128) TYPE C.

PARAMETER: p_FILE(128)        DEFAULT ''.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_FILE.

  CALL FUNCTION 'WS_FILENAME_GET'
     EXPORTING
          MASK             = ',Text File(Tab Delemited),*.txt.'
          MODE             = '0'
     IMPORTING
          FILENAME         = gv_FILENM
*         RC               =
    EXCEPTIONS
         INV_WINSYS       = 1
         NO_BATCH         = 2
         SELECTION_CANCEL = 3
         SELECTION_ERROR  = 4
         OTHERS           = 5
            .
  IF SY-SUBRC EQ 0.
    MOVE gv_FILENM TO p_FILE.
  ENDIF.

regards,

Khusro Habib

Read only

Former Member
0 Likes
2,205

Hi girish,

1. use like this.

2. just copy paste in new program.

3.

report abc.

DATA : file_name TYPE string.

*----


PARAMETERS : p_file LIKE rlgrap-filename OBLIGATORY.

*----


AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

CLEAR p_file.

CALL FUNCTION 'F4_FILENAME'

IMPORTING

file_name = p_file.

*----


use file_name in gui_upload

file_name = p_file.

regards,

amit m.

Read only

rahulkavuri
Active Contributor
0 Likes
2,205

Check this thread

Read only

Former Member
0 Likes
2,205

do you mean F4 help ?

if so, use Function module "F4_FILENAME" in the AT SELECTION-SCREEN ON VALUE REQUEST FOR P_FILENAME, TO give F4 help to the user.

Regards

srikanth

Read only

Former Member
0 Likes
2,206

Hai Girish

Check the following Code

DATA: I_FILETABLE TYPE FILETABLE,

V_RC TYPE I.

PARAMETERS: P_FILE LIKE RLGRAP-FILENAME. "local file with contracts

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.

CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG

EXPORTING

WINDOW_TITLE = 'Find File'

DEFAULT_EXTENSION = 'C:\'

DEFAULT_FILENAME = ''

FILE_FILTER = ',..'

  • INITIAL_DIRECTORY =

  • MULTISELECTION =

  • WITH_ENCODING =

CHANGING

FILE_TABLE = I_FILETABLE

RC = V_RC

  • USER_ACTION =

  • FILE_ENCODING =

EXCEPTIONS

FILE_OPEN_DIALOG_FAILED = 1

CNTL_ERROR = 2

ERROR_NO_GUI = 3

NOT_SUPPORTED_BY_GUI = 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.

READ TABLE I_FILETABLE INTO P_FILE INDEX 1.

Thanks & Regards

Sreenivasulu P

Message was edited by: Sreenivasulu Ponnadi

Read only

hymavathi_oruganti
Active Contributor
0 Likes
2,205

PARAMETERS: FILENAME LIKE RLGRAP-FILE.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR filename.

CALL FUNCTION 'KD_GET_FILENAME_ON_F4'

EXPORTING

field_name = filename

CHANGING

file_name = filename.

Message was edited by: Hymavathi Oruganti

Read only

0 Likes
2,205

Thank you all.

Issue resolved.

with regards

girish

Read only

0 Likes
2,205

There is a way to say thanks in SDN,

Reward points for the answers which are helpful to you.

Read only

Former Member
0 Likes
2,205

See this sample code in the below link

  CALL FUNCTION 'WS_FILENAME_GET'
       EXPORTING
            def_filename     = p_infile
            mask             = ',*.txt.'
            mode             = 'O'
            title            = 'Upload File'(078)
       IMPORTING
            filename         = p_infile
       EXCEPTIONS
            inv_winsys       = 1
            no_batch         = 2
            selection_cancel = 3
            selection_error  = 4
            OTHERS           = 5.

http://www.sapdevelopment.co.uk/file/file_uptabpc.htm

http://www.sapdevelopment.co.uk/file/file_updown.htm

Also refer

http://www.sapdevelopment.co.uk/file/file_selection.htm

If ur problem got solved kindly reward points and close the thread.

Read only

Former Member
0 Likes
2,205

Hi Girish,

Refer the code below.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_ppath.

REFRESH: git_tab.

  • Open the Browse Dialog Box on the Desktop

CALL METHOD cl_gui_frontend_services=>file_open_dialog

EXPORTING

default_filename = gc_defaultfile

initial_directory = gc_defaultdir

CHANGING

file_table = git_tab

rc = gv_subrc.

  • Assign the selected file name to the file path field

READ TABLE git_tab INTO p_ppath INDEX 1.

<b>Please reward points if it helps and close the thread.</b>