Hallo
da gibt's die SDIXML@ FuBa's
ich habe das ganze so geloest
*----------------------------------------------------------------------*
FORM datei_oeffnen TABLES pt_xml
CHANGING pv_size
pv_subrc.
DATA: lt_file TYPE filetable
, lf_file TYPE file_table
, lv_name(10)
, lv_msg(132)
, lv_dir TYPE string
, lv_filename TYPE string
, lv_subrc TYPE i
, lv_dateiname(50)
, lv_serverpfad(100)
, lv_clientpfad(100)
, lt_split TYPE TABLE OF char100 WITH HEADER LINE
, lv_linct TYPE i
, lt_return TYPE TABLE OF tpstdout WITH HEADER LINE
, lv_rfcdest LIKE rfcdes-rfcdest
, lv_ftpok TYPE xfeld
, lv_size TYPE i
.
CLEAR pv_subrc.
* 2 Druckzeilen Vorschub
SKIP 2.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
* WINDOW_TITLE =
* default_extension = '*'
default_filename = lv_filename
* FILE_FILTER =
initial_directory = 'C:\TEMP'
* MULTISELECTION =
* WITH_ENCODING =
CHANGING
file_table = lt_file
rc = lv_subrc
* USER_ACTION =
* FILE_ENCODING =
EXCEPTIONS
file_open_dialog_failed = 1
cntl_error = 2
error_no_gui = 3
not_supported_by_gui = 4
OTHERS = 5
.
IF sy-subrc <> 0 OR
lv_subrc <> 1.
pv_subrc = 1.
PERFORM protokoll USING '019' 'E' '' '' '' '' ''.
EXIT.
ENDIF.
PERFORM gui_prot USING '018' '' '' '' ''.
READ TABLE lt_file INTO lf_file INDEX 1.
lv_filename = lf_file-filename.
CALL METHOD cl_gui_frontend_services=>gui_upload
EXPORTING
filename = lv_filename
filetype = 'BIN'
* HAS_FIELD_SEPARATOR = SPACE
* HEADER_LENGTH = 0
* DAT_MODE = SPACE
* CODEPAGE = SPACE
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* READ_BY_LINE = 'X'
IMPORTING
filelength = pv_size
* HEADER =
CHANGING
data_tab = pt_xml[]
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
not_supported_by_gui = 17
error_no_gui = 18
OTHERS = 19
.
IF sy-subrc <> 0.
PERFORM protokoll USING '020' 'E' '' lv_filename sy-subrc '' ''.
PERFORM protokoll USING sy-msgno 'E' sy-msgid
sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
pv_subrc = 1.
ELSE.
PERFORM protokoll USING '021' 'H' '' lv_filename '' '' ''.
ENDIF.
ENDFORM. " datei_oeffnen
*&---------------------------------------------------------------------*
*& Form xml_to_table
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM xml_to_table TABLES pt_xml
CHANGING pv_size
pv_subrc.
DATA: lr_doc TYPE REF TO if_ixml_document
, lr_top_element TYPE REF TO if_ixml_element
, lr_element TYPE REF TO if_ixml_element
, lr_ixml_factory TYPE REF TO if_ixml
, lr_items TYPE REF TO if_ixml_node_collection
, lt_xml TYPE dcxmllines
, lt_abap TYPE abap_parmbind_tab
, lv_size TYPE i
, lf_control TYPE dcxmldescl
, lf_problems TYPE dcxmlprbl
, lt_table TYPE TABLE OF text100 WITH HEADER LINE
, lv_ind TYPE i
, lv_value(100)
.
RANGES: lr_atinn FOR cabn-atinn.
PERFORM gui_prot USING '008' '' '' '' ''.
*
* Wandle XML-Monitordefinition um in ein DOM ( Document Object Model )
*
CALL FUNCTION 'SDIXML_XML_TO_DOM'
EXPORTING
xml = pt_xml[]
size = pv_size
IMPORTING
document = lr_doc
EXCEPTIONS
invalid_input = 1
OTHERS = 99.
CASE sy-subrc.
WHEN 0.
" ok
WHEN 1.
" ungültiges XML-Format entdeckt
pv_subrc = 1.
EXIT.
WHEN OTHERS.
pv_subrc = 1.
EXIT.
ENDCASE.
lr_top_element = lr_doc->get_root_element( ).
lv_ind = 0.
lr_items = lr_doc->get_elements_by_tag_name( name = 'StueliPos' ).
*
* Transformiere das DOM in die entsprechende ABAP-Struktur, welche
* für die Erzeugung der Definition in XML-Format verwendet wurde
*
WHILE lv_ind < lr_items->get_length( ).
lr_element ?= lr_items->get_item( lv_ind ).
lv_value = lr_element->get_value( ).
lf_control-err_treat = 'X'.
lf_control-warn_treat = 'X'.
CALL FUNCTION 'SDIXML_DOM_TO_DATA'
EXPORTING
data_as_dom = lr_element
control = lf_control
IMPORTING
dataobject = it_z20pss_konf_ps
problems = lf_problems
EXCEPTIONS
illegal_object = 1
OTHERS = 99.
APPEND it_z20pss_konf_ps.
CASE sy-subrc.
WHEN 0.
IF lf_problems IS NOT INITIAL.
pv_subrc = 1.
EXIT.
ENDIF.
WHEN 1.
pv_subrc = 1.
EXIT.
WHEN OTHERS.
pv_subrc = 1.
EXIT.
ENDCASE.
ADD 1 TO lv_ind.
ENDWHILE.
ENDFORM. " xml_to_table