From fc4c3f03de784a6f34ed57b68c6c7e368ef7e469 Mon Sep 17 00:00:00 2001 From: oblomov <102328295+oblomov-dev@users.noreply.github.com> Date: Sun, 30 Apr 2023 13:24:59 +0200 Subject: [PATCH] decimals (#209) --- src/00/z2ui5_cl_app_demo_00.clas.abap | 3 +- src/00/z2ui5_cl_app_demo_47.clas.abap | 72 +++++++++++++++++++ src/00/z2ui5_cl_app_demo_47.clas.xml | 16 +++++ ...z2ui5_cl_http_handler.clas.locals_imp.abap | 17 +++-- 4 files changed, 103 insertions(+), 5 deletions(-) create mode 100644 src/00/z2ui5_cl_app_demo_47.clas.abap create mode 100644 src/00/z2ui5_cl_app_demo_47.clas.xml diff --git a/src/00/z2ui5_cl_app_demo_00.clas.abap b/src/00/z2ui5_cl_app_demo_00.clas.abap index abb46fa4..45c4212a 100644 --- a/src/00/z2ui5_cl_app_demo_00.clas.abap +++ b/src/00/z2ui5_cl_app_demo_00.clas.abap @@ -111,7 +111,8 @@ CLASS Z2UI5_CL_APP_DEMO_00 IMPLEMENTATION. ). grid->simple_form( title = 'HowTo - More' layout = 'ResponsiveGridLayout' )->content( 'form' - )->button( text = 'Side Effects' press = client->_event( 'z2ui5_cl_app_demo_27' ) + )->button( text = 'Side Effects' press = client->_event( 'z2ui5_cl_app_demo_27' ) + )->button( text = 'Integer and Decimals' press = client->_event( 'z2ui5_cl_app_demo_47' ) ). DATA(form) = page->grid( 'L9 M12 S12' diff --git a/src/00/z2ui5_cl_app_demo_47.clas.abap b/src/00/z2ui5_cl_app_demo_47.clas.abap new file mode 100644 index 00000000..762f0b42 --- /dev/null +++ b/src/00/z2ui5_cl_app_demo_47.clas.abap @@ -0,0 +1,72 @@ +CLASS z2ui5_cl_app_demo_47 DEFINITION PUBLIC. + + PUBLIC SECTION. + + INTERFACES z2ui5_if_app. + + DATA int1 TYPE i. + 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 check_initialized TYPE abap_bool. + + PROTECTED SECTION. + PRIVATE SECTION. +ENDCLASS. + + + +CLASS z2ui5_cl_app_demo_47 IMPLEMENTATION. + + + METHOD z2ui5_if_app~main. + + IF check_initialized = abap_false. + check_initialized = abap_true. + ENDIF. + + CASE client->get( )-event. + WHEN 'BUTTON_INT'. + int_sum = int1 + int2. + WHEN 'BUTTON_DEC'. + dec_sum = dec1 + dec2. + WHEN 'BACK'. + 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' + navbuttonpress = client->_event( 'BACK' ) + shownavbutton = abap_true + )->header_content( + )->link( + text = 'Source_Code' + href = z2ui5_cl_xml_view=>hlp_get_source_code_url( app = me get = client->get( ) ) + target = '_blank' + )->get_parent( + )->simple_form( title = 'Integer and Decimals' editable = abap_true + )->content( 'form' + )->title( 'Input' + )->label( 'integer' + )->input( value = client->_bind( int1 ) + )->input( value = client->_bind( int2 ) + )->input( enabled = abap_false value = client->_bind( int_sum ) + )->button( text = 'calc sum' press = client->_event( 'BUTTON_INT' ) + )->label( 'decimals' + )->input( client->_bind( dec1 ) + )->input( client->_bind( dec2 ) + )->input( enabled = abap_false value = client->_bind( dec_sum ) + )->button( text = 'calc sum' press = client->_event( 'BUTTON_DEC' ) + )->get_root( )->xml_get( ) ) ). + + + ENDMETHOD. +ENDCLASS. diff --git a/src/00/z2ui5_cl_app_demo_47.clas.xml b/src/00/z2ui5_cl_app_demo_47.clas.xml new file mode 100644 index 00000000..011e8fb4 --- /dev/null +++ b/src/00/z2ui5_cl_app_demo_47.clas.xml @@ -0,0 +1,16 @@ + + + + + + Z2UI5_CL_APP_DEMO_47 + E + type conversion + 1 + X + X + X + + + + diff --git a/src/z2ui5_cl_http_handler.clas.locals_imp.abap b/src/z2ui5_cl_http_handler.clas.locals_imp.abap index 5e32c0e5..71a458bb 100644 --- a/src/z2ui5_cl_http_handler.clas.locals_imp.abap +++ b/src/z2ui5_cl_http_handler.clas.locals_imp.abap @@ -1331,9 +1331,11 @@ CLASS z2ui5_lcl_fw_handler IMPLEMENTATION. CASE lr_attri->type_kind. - WHEN `g` OR `I` OR `C`. - DATA(lv_value) = lo_model->get_attribute( lr_attri->name )->get_val( ). - = lv_value. + 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( @@ -1574,13 +1576,20 @@ CLASS z2ui5_lcl_fw_handler IMPLEMENTATION. CASE lr_attri->type_kind. - WHEN `g` OR `D` OR `P` OR `T` OR `C`. + 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 `I`. lo_actual->add_attribute( n = lr_attri->name + " v = v = CONV string( ) apos_active = abap_false ).