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: 

File Save Dialog: Writing data to a new File

Former Member
0 Kudos

Hi ,

I am allowing user to save a file in a directory using file_save_dialog in cl_gui_frontend_services, so i can write data to it using gui_download.

When the user choose the file at the selection screen its not getting displayed in the parameter box.

I have used the following code.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR d_wfil.

PERFORM dest_local.

FORM dest_local .

DATA:

s1 TYPE string,

s2 TYPE string.

DATA: cv_filename TYPE string.

CALL METHOD cl_gui_frontend_services=>file_save_dialog

EXPORTING

window_title = 'File'

default_extension = 'TXT'

default_file_name = cv_filename

  • FILE_FILTER =

initial_directory = 'C:\Documents and Settings\root\Desktop'

  • WITH_ENCODING =

  • PROMPT_ON_OVERWRITE = 'X'

CHANGING

filename = s

path = s1

fullpath = cv_filename

  • user_action =

  • FILE_ENCODING =

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.

endform.

3 REPLIES 3

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Please make sure that you move the value to the screen parameters field.




IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

<b>  d_wfil = cv_filename.</b>

endform.

Regards,

Rich Heilman

ferry_lianto
Active Contributor
0 Kudos

Hi Ram,

Please check this link for sample codes.

Regards,

Ferry Lianto

Former Member
0 Kudos

Hi Ram,

You need to use file_open_dialog from cl_gui_frontend_services.

Ex:

parameters: p_file type localfile.

at selection-screen on value-request for p_file.

data: ifile type filetable.

data: xfile like line of ifile.

data: rc type i.

call method cl_gui_frontend_services=>file_open_dialog

exporting

initial_directory

= 'C:\'

changing

file_table = ifile

rc = rc.

read table ifile into xfile index 1.

check sy-subrc = 0.

p_file = xfile-filename.

Cheers,

Vikram

Pls reward for helpful replies!!