Folgende Benutzer bedankten sich beim Autor a-dead-trousers für den Beitrag:
dejo79
Code: Alles auswählen.
REPORT zdj_test_transform.
CLASS lcl_xmltest DEFINITION.
PUBLIC SECTION.
INTERFACES:
if_serializable_object.
DATA counter TYPE i.
DATA t_mara TYPE mara_tt.
DATA s_mara TYPE mara.
DATA r_equi TYPE REF TO zcl_msb5_ih_equi.
METHODS:
constructor
IMPORTING
iv_counter TYPE i
it_mara TYPE mara_tt
is_mara TYPE mara.
ENDCLASS.
CLASS lcl_xmltest IMPLEMENTATION.
METHOD constructor.
me->counter = iv_counter.
me->s_mara = is_mara.
me->t_mara = it_mara.
CREATE OBJECT me->r_equi.
me->r_equi->load( 'TEQ-30' ).
ENDMETHOD.
ENDCLASS.
DATA: go_ixml TYPE REF TO if_ixml,
go_stream_factory TYPE REF TO if_ixml_stream_factory,
go_encoding TYPE REF TO if_ixml_encoding,
go_xml_o TYPE REF TO if_ixml_ostream,
go_xml_i TYPE REF TO if_ixml_istream,
gv_xml_xstring TYPE xstring.
DATA: go_old TYPE REF TO lcl_xmltest,
go_new TYPE REF TO lcl_xmltest.
DATA lt_mara TYPE TABLE OF mara.
DATA ls_mara TYPE mara.
CONSTANTS: gc_encoding TYPE string VALUE 'UTF-16'. "or UTF-8 etc.
START-OF-SELECTION.
SELECT *
FROM mara
INTO TABLE lt_mara
UP TO 10 ROWS.
READ TABLE lt_mara INTO ls_mara INDEX 1.
CREATE OBJECT go_old
EXPORTING
iv_counter = 5
it_mara = lt_mara
is_mara = ls_mara.
go_ixml = cl_ixml=>create( ).
go_stream_factory = go_ixml->create_stream_factory( ).
go_encoding = go_ixml->create_encoding( character_set = gc_encoding byte_order = 0 ).
go_xml_o = go_stream_factory->create_ostream_xstring( gv_xml_xstring ).
go_xml_o->set_encoding( go_encoding ).
CALL TRANSFORMATION id_indent
OPTIONS data_refs = 'heap-or-create'
SOURCE obj = go_old
RESULT XML go_xml_o.
CALL TRANSFORMATION id_indent
SOURCE XML gv_xml_xstring
RESULT obj = go_new.
BREAK-POINT.
END-OF-SELECTION.
Code: Alles auswählen.
DATA:
lo_object type ref to lcl_xmltest,
ld_string TYPE string.
CALL TRANSFORMATION ID
OPTIONS data_refs = 'heap-or-create'
SOURCE obj = lo_object
RESULT XML ld_string.
Folgende Benutzer bedankten sich beim Autor a-dead-trousers für den Beitrag:
dejo79
Code: Alles auswählen.
CREATE OBJECT lo_old
EXPORTING
iv_counter = 5.
CALL TRANSFORMATION id
OPTIONS data_refs = 'heap-or-create'
SOURCE obj = lo_old
RESULT XML lv_xml_xstring.
ls_xml-uname = sy-uname.
ls_xml-xml = lv_xml_xstring.
MODIFY zjd_xstring FROM ls_xml.
COMMIT WORK.
CALL TRANSFORMATION id
SOURCE XML lv_xml_xstring
RESULT obj = lo_new.
Code: Alles auswählen.
REPORT zdj_test_transform.
*----------------------------------------------------------------------*
* CLASS lcl_mysample DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_xmltest DEFINITION.
PUBLIC SECTION.
INTERFACES:
if_serializable_object.
DATA counter TYPE i.
DATA r_equi TYPE REF TO zcl_msb5_ih_equi. "in dieser Klassen muss auch if_serializable_object includiert werden!!!
METHODS:
constructor.
ENDCLASS. "lcl_mysample DEFINITION
*----------------------------------------------------------------------*
* CLASS lcl_mysample IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_xmltest IMPLEMENTATION.
METHOD constructor.
CREATE OBJECT me->r_equi.
me->r_equi->load( 'TEQ-30' ).
ENDMETHOD. "constructor
ENDCLASS. "lcl_mysample IMPLEMENTATION
DATA lo_old TYPE REF TO lcl_xmltest.
DATA lv_xstring TYPE xstring.
DATA lt_xml TYPE TABLE OF zjd_xstring.
DATA ls_xml TYPE zjd_xstring.
START-OF-SELECTION.
CREATE OBJECT lo_old.
lo_old->counter = 5.
CALL TRANSFORMATION id_indent
OPTIONS data_refs = 'heap-or-create'
SOURCE obj = lo_old
RESULT XML lv_xstring.
* CALL FUNCTION 'SCOL_TRACE_SHOW_XML'
* EXPORTING
* xdoc = lv_xstring.
ls_xml-uname = sy-uname.
ls_xml-xml = lv_xstring.
MODIFY zjd_xstring FROM ls_xml.
COMMIT WORK.
END-OF-SELECTION.
Code: Alles auswählen.
REPORT zdj_test_transform2.
*----------------------------------------------------------------------*
* CLASS lcl_xmltest DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_xmltest DEFINITION.
PUBLIC SECTION.
INTERFACES:
if_serializable_object.
DATA counter TYPE i.
DATA r_equi TYPE REF TO zcl_msb5_ih_equi. "in dieser Klassen muss auch if_serializable_object includiert werden!!!
ENDCLASS. "lcl_mysample DEFINITION
*----------------------------------------------------------------------*
* CLASS lcl_mysample IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_xmltest IMPLEMENTATION.
*nn
ENDCLASS. "lcl_mysample IMPLEMENTATION
DATA lo_new TYPE REF TO lcl_xmltest.
DATA lv_xstring TYPE xstring.
DATA lv_1 TYPE string VALUE 'ZDJ_TEST_TRANSFORM'.
DATA lv_2 TYPE string VALUE 'ZDJ_TEST_TRANSFORM2'.
DATA lv_1x TYPE xstring.
DATA lv_2x TYPE xstring.
START-OF-SELECTION.
SELECT SINGLE xml
FROM zjd_xstring
INTO lv_xstring
WHERE uname = sy-uname.
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
text = lv_1
IMPORTING
buffer = lv_1x.
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
text = lv_2
IMPORTING
buffer = lv_2x.
REPLACE ALL OCCURRENCES OF lv_1x IN lv_xstring WITH lv_2x IN BYTE MODE.
* CALL FUNCTION 'SCOL_TRACE_SHOW_XML'
* EXPORTING
* xdoc = lv_xstring.
CALL TRANSFORMATION id
SOURCE XML lv_xstring
RESULT obj = lo_new.
END-OF-SELECTION.