From ea6b149c7342fe80ec59b2feb9e17fa6d26ddadc Mon Sep 17 00:00:00 2001 From: abapsheep <135960093+abapsheep@users.noreply.github.com> Date: Wed, 27 Mar 2024 09:26:20 +0100 Subject: [PATCH] Update z2ui5_cl_demo_app_132.clas.abap (#150) * Update z2ui5_cl_demo_app_132.clas.abap Update * Update z2ui5_cl_demo_app_132.clas.abap Update * Update z2ui5_cl_demo_app_132.clas.abap Update * Update z2ui5_cl_demo_app_132.clas.abap Update * Update z2ui5_cl_demo_app_132.clas.abap Update --- src/z2ui5_cl_demo_app_132.clas.abap | 106 +++++++++++++++++++++++----- 1 file changed, 90 insertions(+), 16 deletions(-) diff --git a/src/z2ui5_cl_demo_app_132.clas.abap b/src/z2ui5_cl_demo_app_132.clas.abap index 1a99a3ad..3b337060 100644 --- a/src/z2ui5_cl_demo_app_132.clas.abap +++ b/src/z2ui5_cl_demo_app_132.clas.abap @@ -3,22 +3,22 @@ CLASS z2ui5_cl_demo_app_132 DEFINITION CREATE PUBLIC. PUBLIC SECTION. - INTERFACES if_serializable_object. INTERFACES z2ui5_if_app. DATA mv_view_display TYPE abap_bool. DATA mo_parent_view TYPE REF TO z2ui5_cl_xml_view. -DATA mv_perc type string. + DATA mv_perc TYPE string. + DATA mt_table TYPE REF TO data. + DATA mt_table_tmp TYPE REF TO data. + DATA ms_table_row TYPE REF TO data. + DATA mt_table_del TYPE REF TO data. - methods set_app_data - importing - !DATA type STRING . + METHODS set_app_data + IMPORTING !data TYPE string. PROTECTED SECTION. - - DATA client TYPE REF TO z2ui5_if_client. DATA check_initialized TYPE abap_bool. @@ -28,6 +28,10 @@ DATA mv_perc type string. METHODS Render_main. PRIVATE SECTION. + METHODS get_data. + + METHODS get_comp + RETURNING VALUE(result) TYPE abap_component_tab. ENDCLASS. @@ -44,11 +48,11 @@ CLASS z2ui5_cl_demo_app_132 IMPLEMENTATION. ENDMETHOD. METHOD on_init. + get_Data( ). Render_main( ). ENDMETHOD. METHOD render_main. - IF mo_parent_view IS INITIAL. DATA(page) = z2ui5_cl_xml_view=>factory( ). @@ -59,14 +63,13 @@ CLASS z2ui5_cl_demo_app_132 IMPLEMENTATION. ENDIF. - DATA(layout) = page->vertical_layout( class = `sapUiContentPadding` width = `100%` ). + DATA(layout) = page->vertical_layout( class = `sapUiContentPadding` + width = `100%` ). layout->label( 'ProgressIndicator' - )->progress_indicator( - percentvalue = mv_perc - displayvalue = '0,44GB of 32GB used' - showvalue = abap_true - state = 'Success' ). - + )->progress_indicator( percentvalue = mv_perc + displayvalue = '0,44GB of 32GB used' + showvalue = abap_true + state = 'Success' ). IF mo_parent_view IS INITIAL. @@ -93,9 +96,80 @@ CLASS z2ui5_cl_demo_app_132 IMPLEMENTATION. ENDMETHOD. METHOD set_app_data. + mv_perc = data. + ENDMETHOD. + + METHOD get_data. + FIELD-SYMBOLS TYPE STANDARD TABLE. + FIELD-SYMBOLS TYPE STANDARD TABLE. + + DATA(t_comp) = get_comp( ). + + TRY. + + DATA(new_struct_desc) = cl_abap_structdescr=>create( t_comp ). + + DATA(new_table_desc) = cl_abap_tabledescr=>create( p_line_type = new_struct_desc + p_table_kind = cl_abap_tabledescr=>tablekind_std ). + + CREATE DATA mt_table TYPE HANDLE new_table_desc. + CREATE DATA mt_table_del TYPE HANDLE new_table_desc. + CREATE DATA mt_table_tmp TYPE HANDLE new_table_desc. + CREATE DATA ms_table_row TYPE HANDLE new_struct_desc. + + ASSIGN mt_table->* TO
. + + SELECT * FROM Z2UI5_T_UTIL_01 + INTO CORRESPONDING FIELDS OF TABLE @
+ UP TO '100' ROWS. + + CATCH cx_root. + + ENDTRY. + + ASSIGN mt_table_tmp->* TO . + + =
. + ENDMETHOD. + + METHOD get_comp. + TRY. + + DATA index TYPE int4. + + TRY. + + cl_abap_typedescr=>describe_by_name( EXPORTING p_name = 'Z2UI5_T_UTIL_01' + RECEIVING p_descr_ref = DATA(typedesc) + EXCEPTIONS type_not_found = 1 + OTHERS = 2 ). + + DATA(structdesc) = CAST cl_abap_structdescr( typedesc ). + + DATA(comp) = structdesc->get_components( ). + + LOOP AT comp INTO DATA(com). + + IF com-as_include = abap_false. + + APPEND com TO result. + + ENDIF. + + ENDLOOP. + + CATCH cx_root INTO DATA(root). " TODO: variable is assigned but never used (ABAP cleaner) + + ENDTRY. + + DATA(component) = VALUE cl_abap_structdescr=>component_table( + ( name = 'ROW_ID' + type = CAST #( cl_abap_datadescr=>describe_by_data( index ) ) ) ). -mv_perc = data. + APPEND LINES OF component TO result. + CATCH cx_root. + ENDTRY. ENDMETHOD. ENDCLASS.