From e808aa81d086f01677fc54c753265a2a40d81614 Mon Sep 17 00:00:00 2001 From: oblomov <102328295+oblomov-dev@users.noreply.github.com> Date: Mon, 1 May 2023 22:37:57 +0200 Subject: [PATCH] conversion (#210) * demo update * Update README.md * conversions * fix --- README.md | 2 +- src/00/z2ui5_cl_app_demo_03.clas.abap | 12 ++-- src/00/z2ui5_cl_app_demo_47.clas.abap | 61 +++++++++++++++++-- ...z2ui5_cl_http_handler.clas.locals_imp.abap | 53 ++++++++++------ 4 files changed, 95 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index c9cc99f5..50088b04 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Development of UI5 Apps in pure ABAP. Follow this project on [Twitter](https://t #### Features * easy to use – implement just one interface for a standalone UI5 application * pure ABAP – development using 100% ABAP (no JavaScript, DDL, EML or Customizing) -* low system footprint – based on a plain http handler (no BSP, OData, CDS, BOPF, FE or RAP) +* low system footprint – based on a plain http handler (no BSP, OData, CDS, BOPF or RAP) * cloud and on-premise ready – works with both language versions (ABAP for Cloud, Standard ABAP) * high system compatibility – runs on all ABAP releases (from NW 7.02 to ABAP 2305) * easy installation – abapGit project, no additional app deployment needed diff --git a/src/00/z2ui5_cl_app_demo_03.clas.abap b/src/00/z2ui5_cl_app_demo_03.clas.abap index 8d78639c..df0a9c32 100644 --- a/src/00/z2ui5_cl_app_demo_03.clas.abap +++ b/src/00/z2ui5_cl_app_demo_03.clas.abap @@ -33,12 +33,12 @@ CLASS z2ui5_cl_app_demo_03 IMPLEMENTATION. check_initialized = abap_true. t_tab = VALUE #( - ( title = 'Peter' info = 'completed' descr = 'this is a description' icon = 'sap-icon://account' ) - ( title = 'Peter' info = 'incompleted' descr = 'this is a description' icon = 'sap-icon://account' ) - ( title = 'Peter' info = 'working' descr = 'this is a description' icon = 'sap-icon://account' ) - ( title = 'Peter' info = 'working' descr = 'this is a description' icon = 'sap-icon://account' ) - ( title = 'Peter' info = 'completed' descr = 'this is a description' icon = 'sap-icon://account' ) - ( title = 'Peter' info = 'completed' descr = 'this is a description' icon = 'sap-icon://account' ) + ( title = 'row_01' info = 'completed' descr = 'this is a description' icon = 'sap-icon://account' ) + ( title = 'row_02' info = 'incompleted' descr = 'this is a description' icon = 'sap-icon://account' ) + ( title = 'row_03' info = 'working' descr = 'this is a description' icon = 'sap-icon://account' ) + ( title = 'row_04' info = 'working' descr = 'this is a description' icon = 'sap-icon://account' ) + ( title = 'row_05' info = 'completed' descr = 'this is a description' icon = 'sap-icon://account' ) + ( title = 'row_06' info = 'completed' descr = 'this is a description' icon = 'sap-icon://account' ) ). ENDIF. diff --git a/src/00/z2ui5_cl_app_demo_47.clas.abap b/src/00/z2ui5_cl_app_demo_47.clas.abap index 762f0b42..f9be453f 100644 --- a/src/00/z2ui5_cl_app_demo_47.clas.abap +++ b/src/00/z2ui5_cl_app_demo_47.clas.abap @@ -8,9 +8,13 @@ CLASS z2ui5_cl_app_demo_47 DEFINITION PUBLIC. DATA int2 TYPE i. DATA int_sum TYPE i. - DATA dec1 TYPE p length 10 DECIMALS 4. - DATA dec2 TYPE p length 10 DECIMALS 4. - DATA dec_sum TYPE p length 10 DECIMALS 4. + DATA dec1 TYPE p LENGTH 10 DECIMALS 4. + DATA dec2 TYPE p LENGTH 10 DECIMALS 4. + DATA dec_sum TYPE p LENGTH 10 DECIMALS 4. + + DATA boolean TYPE abap_bool. + DATA date TYPE d. + DATA time TYPE t. DATA check_initialized TYPE abap_bool. @@ -27,6 +31,48 @@ CLASS z2ui5_cl_app_demo_47 IMPLEMENTATION. IF check_initialized = abap_false. check_initialized = abap_true. + date = sy-datum. + time = sy-uzeit. + dec1 = -1 / 3. + +* /ui2/cl_json=>serialize( +* EXPORTING +* data = time +** compress = +** name = +** pretty_name = +** type_descr = +** assoc_arrays = +** ts_as_iso8601 = +** expand_includes = +** assoc_arrays_opt = +** numc_as_string = +** name_mappings = +** conversion_exits = +** format_output = +** hex_as_base64 = +* RECEIVING +* r_json = data(lv_json) +* ). +* +* data(lv_test) = conv string( lv_json ). +* lv_test = lv_test+1. +* lv_test = shift_right( val = lv_test sub = `"` ). +* +* /ui2/cl_json=>deserialize( +* EXPORTING +* json = lv_test +** jsonx = +** pretty_name = +** assoc_arrays = +** assoc_arrays_opt = +** name_mappings = +* conversion_exits = abap_true +** hex_as_base64 = +* CHANGING +* data = time2 +* ). + ENDIF. CASE client->get( )-event. @@ -38,9 +84,6 @@ CLASS z2ui5_cl_app_demo_47 IMPLEMENTATION. client->nav_app_leave( client->get_app( client->get( )-id_prev_app_stack ) ). ENDCASE. - int1 = 5 / 3. - dec1 = 1 / 3. - client->set_next( VALUE #( xml_main = z2ui5_cl_xml_view=>factory( )->shell( )->page( title = 'abap2UI5 - Integer and Decimals' @@ -65,6 +108,12 @@ CLASS z2ui5_cl_app_demo_47 IMPLEMENTATION. )->input( client->_bind( dec2 ) )->input( enabled = abap_false value = client->_bind( dec_sum ) )->button( text = 'calc sum' press = client->_event( 'BUTTON_DEC' ) + )->label( 'date' + )->input( client->_bind( date ) + )->label( 'time' + )->input( client->_bind( time ) + )->label( 'boolean' + )->input( client->_bind( boolean ) )->get_root( )->xml_get( ) ) ). diff --git a/src/z2ui5_cl_http_handler.clas.locals_imp.abap b/src/z2ui5_cl_http_handler.clas.locals_imp.abap index 71a458bb..32b15f80 100644 --- a/src/z2ui5_cl_http_handler.clas.locals_imp.abap +++ b/src/z2ui5_cl_http_handler.clas.locals_imp.abap @@ -640,6 +640,7 @@ CLASS z2ui5_lcl_utility_tree_json IMPLEMENTATION. EXPORTING json = CONV string( iv_json ) assoc_arrays = abap_true + " conversion_exits = abap_true CHANGING data = result->mr_actual ). @@ -1331,18 +1332,27 @@ CLASS z2ui5_lcl_fw_handler IMPLEMENTATION. CASE lr_attri->type_kind. - WHEN `g` OR `I` OR `C` OR `P`. - DATA(lo_attri) = lo_model->get_attribute( lr_attri->name ). - FIELD-SYMBOLS TYPE any. - ASSIGN lo_attri->mr_actual->* TO . - = . - WHEN `h`. z2ui5_lcl_utility=>trans_ref_tab_2_tab( EXPORTING ir_tab_from = lo_model->get_attribute( lr_attri->name )->mr_actual IMPORTING t_result = ). + WHEN 'D' OR 'T' OR 'C'. + DATA(lo_attri) = lo_model->get_attribute( lr_attri->name ). + FIELD-SYMBOLS TYPE any. + ASSIGN lo_attri->mr_actual->* TO . + /ui2/cl_json=>deserialize( + EXPORTING + json = `"` && && `"` + CHANGING + data = + ). + WHEN OTHERS. + lo_attri = lo_model->get_attribute( lr_attri->name ). + ASSIGN lo_attri->mr_actual->* TO . + = . + ENDCASE. ENDLOOP. @@ -1576,22 +1586,21 @@ CLASS z2ui5_lcl_fw_handler IMPLEMENTATION. CASE lr_attri->type_kind. - WHEN `g` OR `D` OR `T` OR `C`. - lo_actual->add_attribute( n = lr_attri->name - v = z2ui5_lcl_utility=>get_abap_2_json( ) - apos_active = abap_false ). + " WHEN `g` OR `D` OR `T` OR `C`. + " lo_actual->add_attribute( n = lr_attri->name + " v = z2ui5_lcl_utility=>get_abap_2_json( ) + " apos_active = abap_false ). - WHEN `P`. - lo_actual->add_attribute( n = lr_attri->name - " v = - v = CONV string( ) - apos_active = abap_false ). + " WHEN `P`. + " lo_actual->add_attribute( n = lr_attri->name + " v = /ui2/cl_json=>serialize( ) + " apos_active = abap_false ). - WHEN `I`. - lo_actual->add_attribute( n = lr_attri->name - " v = - v = CONV string( ) - apos_active = abap_false ). + " WHEN `I`. + " lo_actual->add_attribute( n = lr_attri->name + " " v = + " v = CONV string( ) + " apos_active = abap_false ). WHEN `h`. lo_actual->add_attribute( n = lr_attri->name @@ -1599,6 +1608,10 @@ CLASS z2ui5_lcl_fw_handler IMPLEMENTATION. apos_active = abap_false ). WHEN OTHERS. + lo_actual->add_attribute( + n = lr_attri->name + v = /ui2/cl_json=>serialize( ) + apos_active = abap_false ). ENDCASE. ENDLOOP.