conversion (#210)

* demo update

* Update README.md

* conversions

* fix
This commit is contained in:
oblomov 2023-05-01 22:37:57 +02:00
parent fc4c3f03de
commit e808aa81d0
4 changed files with 95 additions and 33 deletions

View File

@ -4,7 +4,7 @@ Development of UI5 Apps in pure ABAP. Follow this project on [Twitter](https://t
#### Features #### Features
* easy to use implement just one interface for a standalone UI5 application * easy to use implement just one interface for a standalone UI5 application
* pure ABAP development using 100% ABAP (no JavaScript, DDL, EML or Customizing) * 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) * 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) * high system compatibility runs on all ABAP releases (from NW 7.02 to ABAP 2305)
* easy installation abapGit project, no additional app deployment needed * easy installation abapGit project, no additional app deployment needed

View File

@ -33,12 +33,12 @@ CLASS z2ui5_cl_app_demo_03 IMPLEMENTATION.
check_initialized = abap_true. check_initialized = abap_true.
t_tab = VALUE #( t_tab = VALUE #(
( 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 = 'Peter' info = 'incompleted' descr = 'this is a description' icon = 'sap-icon://account' ) ( title = 'row_02' 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 = 'row_03' 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 = 'row_04' 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 = 'row_05' 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_06' info = 'completed' descr = 'this is a description' icon = 'sap-icon://account' )
). ).
ENDIF. ENDIF.

View File

@ -8,9 +8,13 @@ CLASS z2ui5_cl_app_demo_47 DEFINITION PUBLIC.
DATA int2 TYPE i. DATA int2 TYPE i.
DATA int_sum TYPE i. DATA int_sum TYPE i.
DATA dec1 TYPE p length 10 DECIMALS 4. DATA dec1 TYPE p LENGTH 10 DECIMALS 4.
DATA dec2 TYPE p length 10 DECIMALS 4. DATA dec2 TYPE p LENGTH 10 DECIMALS 4.
DATA dec_sum 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. DATA check_initialized TYPE abap_bool.
@ -27,6 +31,48 @@ CLASS z2ui5_cl_app_demo_47 IMPLEMENTATION.
IF check_initialized = abap_false. IF check_initialized = abap_false.
check_initialized = abap_true. 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. ENDIF.
CASE client->get( )-event. 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 ) ). client->nav_app_leave( client->get_app( client->get( )-id_prev_app_stack ) ).
ENDCASE. ENDCASE.
int1 = 5 / 3.
dec1 = 1 / 3.
client->set_next( VALUE #( xml_main = z2ui5_cl_xml_view=>factory( )->shell( client->set_next( VALUE #( xml_main = z2ui5_cl_xml_view=>factory( )->shell(
)->page( )->page(
title = 'abap2UI5 - Integer and Decimals' title = 'abap2UI5 - Integer and Decimals'
@ -65,6 +108,12 @@ CLASS z2ui5_cl_app_demo_47 IMPLEMENTATION.
)->input( client->_bind( dec2 ) )->input( client->_bind( dec2 )
)->input( enabled = abap_false value = client->_bind( dec_sum ) )->input( enabled = abap_false value = client->_bind( dec_sum )
)->button( text = 'calc sum' press = client->_event( 'BUTTON_DEC' ) )->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( ) ) ). )->get_root( )->xml_get( ) ) ).

View File

@ -640,6 +640,7 @@ CLASS z2ui5_lcl_utility_tree_json IMPLEMENTATION.
EXPORTING EXPORTING
json = CONV string( iv_json ) json = CONV string( iv_json )
assoc_arrays = abap_true assoc_arrays = abap_true
" conversion_exits = abap_true
CHANGING CHANGING
data = result->mr_actual data = result->mr_actual
). ).
@ -1331,18 +1332,27 @@ CLASS z2ui5_lcl_fw_handler IMPLEMENTATION.
CASE lr_attri->type_kind. 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 <val> TYPE any.
ASSIGN lo_attri->mr_actual->* TO <val>.
<attribute> = <val>.
WHEN `h`. WHEN `h`.
z2ui5_lcl_utility=>trans_ref_tab_2_tab( z2ui5_lcl_utility=>trans_ref_tab_2_tab(
EXPORTING ir_tab_from = lo_model->get_attribute( lr_attri->name )->mr_actual EXPORTING ir_tab_from = lo_model->get_attribute( lr_attri->name )->mr_actual
IMPORTING t_result = <attribute> ). IMPORTING t_result = <attribute> ).
WHEN 'D' OR 'T' OR 'C'.
DATA(lo_attri) = lo_model->get_attribute( lr_attri->name ).
FIELD-SYMBOLS <val> TYPE any.
ASSIGN lo_attri->mr_actual->* TO <val>.
/ui2/cl_json=>deserialize(
EXPORTING
json = `"` && <val> && `"`
CHANGING
data = <attribute>
).
WHEN OTHERS. WHEN OTHERS.
lo_attri = lo_model->get_attribute( lr_attri->name ).
ASSIGN lo_attri->mr_actual->* TO <val>.
<attribute> = <val>.
ENDCASE. ENDCASE.
ENDLOOP. ENDLOOP.
@ -1576,22 +1586,21 @@ CLASS z2ui5_lcl_fw_handler IMPLEMENTATION.
CASE lr_attri->type_kind. CASE lr_attri->type_kind.
WHEN `g` OR `D` OR `T` OR `C`. " WHEN `g` OR `D` OR `T` OR `C`.
lo_actual->add_attribute( n = lr_attri->name " lo_actual->add_attribute( n = lr_attri->name
v = z2ui5_lcl_utility=>get_abap_2_json( <attribute> ) " v = z2ui5_lcl_utility=>get_abap_2_json( <attribute> )
apos_active = abap_false ). " apos_active = abap_false ).
WHEN `P`. " WHEN `P`.
lo_actual->add_attribute( n = lr_attri->name " lo_actual->add_attribute( n = lr_attri->name
" v = <attribute> " v = /ui2/cl_json=>serialize( <attribute> )
v = CONV string( <attribute> ) " apos_active = abap_false ).
apos_active = abap_false ).
WHEN `I`. " WHEN `I`.
lo_actual->add_attribute( n = lr_attri->name " lo_actual->add_attribute( n = lr_attri->name
" v = <attribute> " " v = <attribute>
v = CONV string( <attribute> ) " v = CONV string( <attribute> )
apos_active = abap_false ). " apos_active = abap_false ).
WHEN `h`. WHEN `h`.
lo_actual->add_attribute( n = lr_attri->name lo_actual->add_attribute( n = lr_attri->name
@ -1599,6 +1608,10 @@ CLASS z2ui5_lcl_fw_handler IMPLEMENTATION.
apos_active = abap_false ). apos_active = abap_false ).
WHEN OTHERS. WHEN OTHERS.
lo_actual->add_attribute(
n = lr_attri->name
v = /ui2/cl_json=>serialize( <attribute> )
apos_active = abap_false ).
ENDCASE. ENDCASE.
ENDLOOP. ENDLOOP.