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: 

To get the File path dynamically

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos
  • 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)

0 Kudos

use

CL_GUI_FRONTEND_SERVICES=>File_open_dialog method.

Regards

Raja

Simha_
Employee
Employee
0 Kudos

Hi,

Use F4_FILENAME to get the path..

and pass it to the GUI_UPLOAD.

Regards,

Simha.

Former Member
0 Kudos

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

Former Member
0 Kudos

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.

rahulkavuri
Active Contributor
0 Kudos

Check this thread

Former Member
0 Kudos

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

Former Member
0 Kudos

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

hymavathi_oruganti
Active Contributor
0 Kudos

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

0 Kudos

Thank you all.

Issue resolved.

with regards

girish

0 Kudos

There is a way to say thanks in SDN,

Reward points for the answers which are helpful to you.

Former Member
0 Kudos

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.

former_member927251
Active Contributor
0 Kudos

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>