Internal Tabloyu XML Dosyası Olarak İndirmek ve Görüntülemek
"CALL TRANSFORMATION id" fonksiyonu kulanılarak internal tablo XML olarak görüntülenebilir yada masa üstüne indirilebilir.
TYPE-POOLS: abap.
DATA: lt_source_itab TYPE abap_trans_srcbind_tab,
ls_source_wa TYPE abap_trans_resbind.
DATA: output_stream TYPE xstring.
DATA: lo_xml_doc TYPE REF TO cl_xml_document,
lv_xml TYPE string,
lv_filename TYPE string,
lv_fname TYPE string,
lv_path TYPE string,
lv_fpath TYPE string,
lt_xml TYPE TABLE OF string,
lv_localfile TYPE localfile.
*""""""PROGRAM içinde Ayrı bir EXPLORER penceresinde GÖRÜNTÜLEMEK İÇİN"""""""
GET REFERENCE OF gt_itab INTO ls_source_wa-value.
ls_source_wa-name = `ROOTTAG`.
APPEND ls_source_wa TO lt_source_itab.
TRY.
CALL TRANSFORMATION id
SOURCE (lt_source_itab)
RESULT XML output_stream.
CATCH cx_st_error.
ENDTRY.
CALL FUNCTION `DISPLAY_XML_STRING`
EXPORTING
xml_string = output_stream.
*"""""MASAÜSTÜNE indirmek İÇİN"""""""
TRY.
CALL TRANSFORMATION id
SOURCE data_node = gt_itab
RESULT XML lv_xml.
CATCH cx_st_error.
ENDTRY.
CALL METHOD cl_gui_frontend_services=>GET_DESKTOP_DIRECTORY
CHANGING
DESKTOP_DIRECTORY = lv_filename
EXCEPTIONS
cntl_error = 1.
CALL METHOD cl_gui_cfw=>update_view.
IF lv_filename IS NOT INITIAL.
CONCATENATE lv_filename `` `EXPORT.XML` INTO lv_filename.
ELSE.
CONCATENATE `C:` `EXPORT` `.XML` INTO lv_filename.
ENDIF.
CLEAR: lv_fname, lv_path, lv_fpath.
CALL METHOD cl_gui_frontend_services=>file_save_dialog
EXPORTING
default_extension = `XML`
default_file_name = lv_filename
CHANGING
filename = lv_fname
path = lv_path
fullpath = lv_fpath
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
OTHERS = 4.
lv_localfile = lv_fpath.
CREATE OBJECT lo_xml_doc.
lo_xml_doc->parse_string( lv_xml ).
lo_xml_doc->export_to_file( lv_localfile ).