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

Open File dialog

Former Member
0 Likes
7,863

Hi,

when using the screen painter is there any way to put a f4 open file dialog on a input text field?

Best regards

Lisa M SImonsen

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,664

Hi

Here is the exact code for what you are looking for

I just created a screen 100 with one element of type input field with the name file_name

on value request of that field, i call the module which opens a file save dialog box.

REPORT Z_FILE_POPUP_TST .

data ok_code like sy-ucomm.

data : file_name like rlgrap-filename.

call screen 100.

&----


*& Module f4_help_file INPUT

&----


  • text

----


module f4_help_file input.

DATA : fname TYPE string, fpath TYPE string, fpath_full TYPE string.

CALL METHOD cl_gui_frontend_services=>file_save_dialog

EXPORTING

window_title = 'Choose a location'

CHANGING

filename = fname

path = fpath

fullpath = fpath_full

EXCEPTIONS

cntl_error = 1

error_no_gui = 2

not_supported_by_gui = 3

OTHERS = 4.

IF sy-subrc <> 0.

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

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

ENDIF.

file_name = fpath.

endmodule. " f4_help_file INPUT

*****************************************************************************

The screen Flow logic

PROCESS BEFORE OUTPUT.

  • MODULE STATUS_0100.

*

PROCESS AFTER INPUT.

  • MODULE USER_COMMAND_0100.

PROCESS ON VALUE-REQUEST.

field file_name module f4_help_file.

Hi,

when using the screen painter is there any way to put a f4 open file dialog on a input text field?

Best regards

Lisa M SImonsen

5 REPLIES 5
Read only

Former Member
0 Likes
2,664

hi,

check out the below sample code ...hope it might help you


  CALL FUNCTION 'WS_FILENAME_GET'
   EXPORTING
*     DEF_FILENAME           = ' '
*     DEF_PATH               = ' '
     MASK                   = ',*.*,*.'
     MODE                   = 'O'
*     TITLE                  = ' '
   IMPORTING
     FILENAME               = P_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.
 

Regards,

Santosh

Edited by: Santosh Kumar Patha on Mar 13, 2008 9:38 PM

Read only

Former Member
0 Likes
2,664

Hi

Declare the field TYPE rlgrap-filename then it should automatically give you f4 help for file.

Regards,

Venkat

Read only

Former Member
0 Likes
2,664

hi ,

For opening any file on your PC - using File_open_dialog

codeform get_filename using value(p_flag) type rprxxxxx-kr_feld4

changing p_filename type rlgrap-filename.

class cl_gui_frontend_services definition load.

data: l_filefilter type string,

l_filename type string,

l_filetable type filetable,

l_rc type i,

l_user_action type i,

l_window_title type string.

only when local

check p_flag is initial.

Set data type drop-down and popup title

concatenate cl_gui_frontend_services=>filetype_text

cl_gui_frontend_services=>filetype_all

into l_filefilter.

l_window_title = text-f02.

Dialogue

call method cl_gui_frontend_services=>file_open_dialog

exporting

window_title = l_window_title

default_extension = con_ext

DEFAULT_FILENAME =

file_filter = l_filefilter

initial_directory = con_init_dir

MULTISELECTION =

changing

file_table = l_filetable

rc = l_rc

user_action = l_user_action

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 e899(5a) with 'Error'.

endif.

dialogue not canceled

check l_user_action cl_gui_frontend_services=>action_cancel.

read table l_filetable into l_filename index 1.

check sy-subrc = 0.

p_filename = l_filename.

endform. " get_filename[/code]

regards,

venkat.

Read only

Former Member
0 Likes
2,664

Hi all thanks for you grate input but i need to use the screenpainter field.

In the atributes list in the screen painter, under reference list is there not a search help here that can do this?

Name Type Search help

FILE_DIR I/O

Because i need to do it here.

unless im overseeing something?

Best regards

Lisa M Simonsen

Read only

Former Member
0 Likes
2,665

Hi

Here is the exact code for what you are looking for

I just created a screen 100 with one element of type input field with the name file_name

on value request of that field, i call the module which opens a file save dialog box.

REPORT Z_FILE_POPUP_TST .

data ok_code like sy-ucomm.

data : file_name like rlgrap-filename.

call screen 100.

&----


*& Module f4_help_file INPUT

&----


  • text

----


module f4_help_file input.

DATA : fname TYPE string, fpath TYPE string, fpath_full TYPE string.

CALL METHOD cl_gui_frontend_services=>file_save_dialog

EXPORTING

window_title = 'Choose a location'

CHANGING

filename = fname

path = fpath

fullpath = fpath_full

EXCEPTIONS

cntl_error = 1

error_no_gui = 2

not_supported_by_gui = 3

OTHERS = 4.

IF sy-subrc <> 0.

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

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

ENDIF.

file_name = fpath.

endmodule. " f4_help_file INPUT

*****************************************************************************

The screen Flow logic

PROCESS BEFORE OUTPUT.

  • MODULE STATUS_0100.

*

PROCESS AFTER INPUT.

  • MODULE USER_COMMAND_0100.

PROCESS ON VALUE-REQUEST.

field file_name module f4_help_file.