From 9bbd58951d9c64a15803d062a51cf81e08ed50b7 Mon Sep 17 00:00:00 2001 From: "oblomov-dev@outlook.com" Date: Wed, 24 Apr 2024 06:03:46 +0000 Subject: [PATCH] serialization example on cell level --- src/z2ui5_cl_demo_app_192.clas.abap | 30 ++++++++++++++----- src/z2ui5_cl_demo_app_193.clas.abap | 46 ++++++++++++++++++++++++++--- 2 files changed, 65 insertions(+), 11 deletions(-) diff --git a/src/z2ui5_cl_demo_app_192.clas.abap b/src/z2ui5_cl_demo_app_192.clas.abap index bdf98564..60ae8dbc 100644 --- a/src/z2ui5_cl_demo_app_192.clas.abap +++ b/src/z2ui5_cl_demo_app_192.clas.abap @@ -39,6 +39,8 @@ CLASS z2ui5_cl_demo_app_192 DEFINITION PUBLIC. PROTECTED SECTION. METHODS get_data. + METHODS xml_parse. + METHODS xml_stringify. PRIVATE SECTION. ENDCLASS. @@ -62,7 +64,7 @@ CLASS z2ui5_cl_demo_app_192 IMPLEMENTATION. view->shell( )->page( title = 'xxx' navbuttonpress = client->_event( val = 'BACK' ) - shownavbutton = xsdbool( client->get( )-s_draft-id_prev_app_stack IS NOT INITIAL ) + shownavbutton = abap_true )->header_content( ). client->view_display( view->stringify( ) ). @@ -70,15 +72,13 @@ CLASS z2ui5_cl_demo_app_192 IMPLEMENTATION. ENDMETHOD. METHOD z2ui5_if_app~main. + xml_parse( ). me->client = client. get_data( ). ui5_display( ). -* DATA(lv_stringify) = z2ui5_cl_util_api=>xml_srtti_stringify( data = mt_new_data2 ). - -* DATA(lr_result) = z2ui5_cl_util_api=>xml_srtti_parse( rtti_data = lv_stringify ). - + xml_stringify( ). ENDMETHOD. METHOD get_data. @@ -97,7 +97,6 @@ CLASS z2ui5_cl_demo_app_192 IMPLEMENTATION. LOOP AT kopf->* ASSIGNING . -* APPEND INITIAL LINE TO mt_new_data ASSIGNING FIELD-SYMBOL(). DATA(lo_new_data) = NEW z2ui5_cl_demo_app_193( ). INSERT lo_new_data INTO TABLE mt_new_data2. @@ -109,10 +108,27 @@ CLASS z2ui5_cl_demo_app_192 IMPLEMENTATION. APPEND INITIAL LINE TO ASSIGNING . = CORRESPONDING #( ). -* = CORRESPONDING #( ). ENDLOOP. ENDMETHOD. + + METHOD xml_parse. + + LOOP AT mt_new_data2 INTO DATA(lo_data). + lo_data->xml_parse( ). + ENDLOOP. + + ENDMETHOD. + + + METHOD xml_stringify. + + LOOP AT mt_new_data2 INTO DATA(lo_data). + lo_data->xml_stringify( ). + ENDLOOP. + + ENDMETHOD. + ENDCLASS. diff --git a/src/z2ui5_cl_demo_app_193.clas.abap b/src/z2ui5_cl_demo_app_193.clas.abap index 9484f399..4e84c729 100644 --- a/src/z2ui5_cl_demo_app_193.clas.abap +++ b/src/z2ui5_cl_demo_app_193.clas.abap @@ -1,6 +1,7 @@ CLASS z2ui5_cl_demo_app_193 DEFINITION PUBLIC. PUBLIC SECTION. + INTERFACES if_serializable_object. TYPES: BEGIN OF ty_s_key_value, @@ -11,16 +12,53 @@ CLASS z2ui5_cl_demo_app_193 DEFINITION PUBLIC. END OF ty_s_key_value, ty_t_key_values TYPE STANDARD TABLE OF ty_s_key_value WITH EMPTY KEY. - DATA: - mt_kopf TYPE REF TO data, - mt_pos TYPE REF TO data, - mt_keyva TYPE ty_t_key_values. + DATA mt_kopf TYPE REF TO data. + DATA mt_pos TYPE REF TO data. + DATA mt_keyva TYPE ty_t_key_values. + + DATA mt_kopf_xml TYPE string. + DATA mt_pos_xml TYPE string. + + METHODS xml_parse. + METHODS xml_stringify. PROTECTED SECTION. PRIVATE SECTION. ENDCLASS. + + CLASS z2ui5_cl_demo_app_193 IMPLEMENTATION. + METHOD xml_parse. + + IF mt_pos_xml IS NOT INITIAL. + mt_kopf = z2ui5_cl_util_api=>xml_srtti_parse( mt_kopf_xml ). + CLEAR mt_kopf_xml. + ENDIF. + + IF mt_pos_xml IS NOT INITIAL. + mt_pos = z2ui5_cl_util_api=>xml_srtti_parse( mt_pos_xml ). + CLEAR mt_pos_xml. + ENDIF. + + ENDMETHOD. + + + METHOD xml_stringify. + + ASSIGN mt_kopf->* TO FIELD-SYMBOL(). + IF sy-subrc = 0. + mt_kopf_xml = z2ui5_cl_util_api=>xml_srtti_stringify( ). + CLEAR mt_kopf. + ENDIF. + + ASSIGN mt_pos->* TO FIELD-SYMBOL(). + IF sy-subrc = 0. + mt_pos_xml = z2ui5_cl_util_api=>xml_srtti_stringify( ). + CLEAR mt_pos. + ENDIF. + + ENDMETHOD. ENDCLASS.