Skip to content

Commit

Permalink
serialization example on cell level
Browse files Browse the repository at this point in the history
  • Loading branch information
oblomov-dev committed Apr 24, 2024
1 parent da47401 commit 9bbd589
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 11 deletions.
30 changes: 23 additions & 7 deletions src/z2ui5_cl_demo_app_192.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -62,23 +64,21 @@ 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( ) ).

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.
Expand All @@ -97,7 +97,6 @@ CLASS z2ui5_cl_demo_app_192 IMPLEMENTATION.

LOOP AT kopf->* ASSIGNING <fs_s_head>.

* APPEND INITIAL LINE TO mt_new_data ASSIGNING FIELD-SYMBOL(<fs_s_new_data>).
DATA(lo_new_data) = NEW z2ui5_cl_demo_app_193( ).
INSERT lo_new_data INTO TABLE mt_new_data2.

Expand All @@ -109,10 +108,27 @@ CLASS z2ui5_cl_demo_app_192 IMPLEMENTATION.

APPEND INITIAL LINE TO <fs_t_head_new> ASSIGNING <fs_s_head_new>.
<fs_s_head_new> = CORRESPONDING #( <fs_s_head> ).
* <fs_s_head> = CORRESPONDING #( <fs_s_head_new> ).

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.
46 changes: 42 additions & 4 deletions src/z2ui5_cl_demo_app_193.clas.abap
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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(<head>).
IF sy-subrc = 0.
mt_kopf_xml = z2ui5_cl_util_api=>xml_srtti_stringify( <head> ).
CLEAR mt_kopf.
ENDIF.

ASSIGN mt_pos->* TO FIELD-SYMBOL(<pos>).
IF sy-subrc = 0.
mt_pos_xml = z2ui5_cl_util_api=>xml_srtti_stringify( <pos> ).
CLEAR mt_pos.
ENDIF.

ENDMETHOD.
ENDCLASS.

0 comments on commit 9bbd589

Please sign in to comment.