adesso orange🍊Stellenangebote:
Software Engineer Trainee · Senior
| (Senior) Cloud Software Engineer BTP
(Senior) Consultant Technologie · Consultant ABAP
Werkstudent Softwareentwicklung · Fiori / UI5 · Consulting · Application Management
Konvertierung IDoc zu XML: Unterschied zwischen den Versionen
Aus SAP Wiki ツ
(Die Seite wurde neu angelegt: „Kategorie: Codeschnipsel === Parameter der Methode === IV_IDOC_NUMBER TYPE EDI_DOCNUM Nummer des IDocs IV_SAVE_TO_DESKTOP TYPE CHAR01 OPTIONAL X = True…“) |
|||
Zeile 10: | Zeile 10: | ||
=== Codeschnipsel === | === Codeschnipsel === | ||
<syntaxhighlight lang="abap" line start="1"> | |||
"Check IDoc No exists | "Check IDoc No exists | ||
SELECT SINGLE docnum FROM EDIDC INTO @DATA(lv_idoc_exists) WHERE docnum = @iv_idoc_number. | SELECT SINGLE docnum FROM EDIDC INTO @DATA(lv_idoc_exists) WHERE docnum = @iv_idoc_number. | ||
Zeile 42: | Zeile 42: | ||
IMPORTING e_lines_written = DATA(lt_lines_written) ). | IMPORTING e_lines_written = DATA(lt_lines_written) ). | ||
ENDIF. | ENDIF. | ||
</syntaxhighlight> |
Aktuelle Version vom 12. August 2021, 08:03 Uhr
Parameter der Methode
IV_IDOC_NUMBER TYPE EDI_DOCNUM Nummer des IDocs IV_SAVE_TO_DESKTOP TYPE CHAR01 OPTIONAL X = True IV_SAVE_TO_APPLSERVER TYPE STRING OPTIONAL Pfad + Dateiname.Dateityp Returnin gvalue( RT_IDOCDATA_AS_XML ) TYPE STRINGTAB IDoc Daten als XML
Codeschnipsel
"Check IDoc No exists
SELECT SINGLE docnum FROM EDIDC INTO @DATA(lv_idoc_exists) WHERE docnum = @iv_idoc_number.
IF sy-subrc <> 0.
RAISE EXCEPTION TYPE zcx_conv_utilities MESSAGE e008(zmc_conv_utilities) WITH iv_idoc_number.
ENDIF.
DATA(lo_idoc_xml) = NEW cl_idoc_xml1( docnum = iv_idoc_number ).
DATA lv_xml TYPE string.
lo_idoc_xml->get_xmldata_as_string( IMPORTING data_string = lv_xml ).
DATA(lt_xml) = VALUE stringtab( ( |{ lv_xml }| ) ).
rt_idocdata_as_xml = lt_xml.
IF iv_save_to_desktop = abap_true.
DATA: lv_temp_dir TYPE string.
cl_gui_frontend_services=>get_desktop_directory( CHANGING desktop_directory = lv_temp_dir ).
cl_gui_cfw=>flush( ).
DATA(lv_filename) = |{ lv_temp_dir }\\my_xml.xml|.
cl_gui_frontend_services=>gui_download( EXPORTING
filename = lv_filename
filetype = 'ASC'
CHANGING
data_tab = lt_xml ).
ELSEIF iv_save_to_applserver IS NOT INITIAL.
"Write file to application server
cl_rsan_ut_appserv_file_writer=>appserver_file_write( EXPORTING i_filename = iv_save_to_applserver "max 255 char in AL11
i_data_tab = lt_xml
i_overwrite = abap_true
IMPORTING e_lines_written = DATA(lt_lines_written) ).
ENDIF.