‎2008 Feb 08 5:05 AM
Hi,
I developed one report.I have to add a push button in the output screen.My requirement is when i click that push button a poppup will appear in that popup window i have to select the file path to save my data in presentation server(Local System).can anybody suggest the popup window name for my requirement.
Thanks & Regards,
Kiran Kumar.G.A
‎2008 Feb 08 5:07 AM
Hi,
use this FM 'GUI_FILE_SAVE_DIALOG'
data : fullpath TYPE string,
l_usract TYPE i.
CALL FUNCTION 'GUI_FILE_SAVE_DIALOG'
EXPORTING
window_title = 'Download as pdf file'
default_extension = 'pdf'
IMPORTING
fullpath = fullpath
user_action = l_usract.
if l_usract = 9.
write 'you hav cancelled'.
else.
write 'proceed downloading'.
write : / 'path = ' , fullpath.
endif.Cheers,
jose.
Edited by: jose on Feb 8, 2008 6:09 AM
‎2008 Feb 08 5:20 AM
use the function module
Pop Window to choose file name
F4_FILENAME
this code will help you
CASE v_okcode.
Export to Excel
WHEN 'EXPORT'.
PERFORM f_export.
ENDCASE. " CASE v_okcode.
&----
*& Form F_EXPORT *
&----
This subroutine is used to export the data to excel *
----
There are no interface parameters to be passed to this subroutine *
----
FORM f_export.
Internal table for DFM Accounts
DATA:
BEGIN OF li_export OCCURS 0,
dfmaccount LIKE " DFM Account
z000k_dfm-dfmaccount,
dfmaccdesc LIKE " DFM Account Desc
z000k_dfm-dfmaccdesc,
END OF li_export.
File Path
DATA:
l_file LIKE rlgrap-filename, " File Path
l_file1 TYPE string. " File Path
Select all the entries into internal table
SELECT dfmaccount " DFM Account
dfmaccdesc " DFM Acc Desc
FROM z000k_dfm
INTO TABLE li_export.
IF NOT li_export[] IS INITIAL.
li_export-dfmaccount = 'DFMAccount'(004).
li_export-dfmaccdesc = 'DFM Account Desc'(005).
INSERT li_export INDEX 1.
Pop Window to choose file name
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
IMPORTING
file_name = l_file.
IF NOT l_file IS INITIAL.
l_file1 = l_file.
Validate File path
PERFORM f_validate_file USING l_file1.
Export to Excel
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = l_file1
filetype = 'ASC'
write_field_separator = 'X'
TABLES
data_tab = li_export[]
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
OTHERS = 22.
IF sy-subrc NE 0.
MESSAGE e815(td) WITH space.
ENDIF. " IF SY-SUBRC EQ 0
ELSE.
MESSAGE e143(xw).
EXIT.
ENDIF. " IF SY-SUBRC EQ 0
ELSE.
MESSAGE i531(0u) WITH text-014.
ENDIF. " IF SY-SUBRC EQ 0.
ENDFORM. " F_EXPORT
&----
*& Form F_VALIDATE_FILE *
&----
This subroutine is used to validate the existence of local file *
----
-->P_LV_FILE1 File path *
----
FORM f_validate_file USING p_lv_file1 TYPE string.
DATA:
l_file TYPE string, " File path
l_res TYPE c, " Result
l_ans TYPE c. " Answer
l_file = p_lv_file1.
*To Validate given file path
CALL METHOD cl_gui_frontend_services=>file_exist
EXPORTING
file = l_file
RECEIVING
result = l_res
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
wrong_parameter = 3
OTHERS = 5.
IF sy-subrc NE 0.
MESSAGE e005(tl).
ELSE.
IF NOT l_res IS INITIAL.
CALL FUNCTION 'POPUP_CONTINUE_YES_NO'
EXPORTING
defaultoption = 'Y'
textline1 = text-015
textline2 = text-016
titel = text-017
start_column = 25
start_row = 6
IMPORTING
answer = l_ans.
IF l_ans EQ 'N'.
MESSAGE e502(ctwf).
ENDIF. " IF l_ans EQ 'N'
ENDIF. " IF NOT l_res IS
ENDIF. " IF sy-subrc NE 0
ENDFORM. " F_VALIDATE_FILE