diff --git a/CLAUDE.md b/CLAUDE.md index 0ce22ac3..fdecab57 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -32,12 +32,16 @@ All serialized files (`.abap`, `.xml`, and any other abapGit-managed file types) - Follow the [SAP ABAP Style Guide](https://github.com/SAP/styleguides/blob/main/clean-abap/CleanABAP.md). - Never use an init flag attribute (`check_initialized`, `mv_init`, `is_initialized`, etc.). Always use `client->check_on_init( )` instead. - Use backticks for all string literals, not single quotes. +- Use string templates (`|...|` with `{ }` for embedded expressions) instead of `&&` for string concatenation (e.g. `|item { name }|` not `` `item ` && name ``). - Prefer functional to procedural language constructs — use `var = VALUE #( ).` to reset a variable, never `CLEAR var.`. -- Do not use Hungarian notation — no type prefixes on variable or attribute names (e.g. `product` not `lv_product`, `client` not `mo_client`). +- Use type prefixes only for tables and structures: prefix table variables/attributes with `t_` (e.g. `t_items`) and structure variables/attributes with `s_` (e.g. `s_screen`). Do not add prefixes to scalar variables or object references. +- Name local types with a `ty_s_` prefix for structure types (e.g. `ty_s_row`) and `ty_t_` for table types (e.g. `ty_t_rows`). Only define a `ty_t_` table type when it is used more than once — for a single-use table, declare it inline with `STANDARD TABLE OF ty_s_xxx`. +- No blank line between a `TYPES` definition and the `DATA` declaration that directly uses it. - Class names are always written in **lowercase** in both `DEFINITION` and `IMPLEMENTATION` — never uppercase. - Classes are **not** `FINAL` — do not add the `FINAL` keyword to class definitions. - Use `DEFINITION PUBLIC.` — never `DEFINITION PUBLIC CREATE PUBLIC.` (`CREATE PUBLIC` is the default and adds unnecessary overhead). - Always include `PROTECTED SECTION.` and `PRIVATE SECTION.` in the class definition, even if empty. +- In every section (`PUBLIC SECTION.`, `PROTECTED SECTION.`), always follow this declaration order: `TYPES` first, then `DATA`, then `METHODS`. - **Blank lines — class definition** (`EMPTY_LINES_IN_CLASS_DEFINITION`): - Add one blank line above each section keyword (`PUBLIC SECTION.`, `PROTECTED SECTION.`, `PRIVATE SECTION.`) — unless the preceding section is empty. - No blank line directly below a section keyword. @@ -138,9 +142,11 @@ Always use `client->_event_nav_app_leave()` to bind the back button event direct METHOD view_display. DATA(view) = z2ui5_cl_xml_view=>factory( ). - DATA(page) = view->page( title = `My App` - shownavbutton = client->check_app_prev_stack( ) - navbuttonpress = client->_event_nav_app_leave( ) ). + DATA(page) = view->shell( + )->page( + title = `My App` + shownavbutton = client->check_app_prev_stack( ) + navbuttonpress = client->_event_nav_app_leave( ) ). " ... client->view_display( view->stringify( ) ). @@ -155,7 +161,7 @@ METHOD on_event. CASE client->get( )-event. WHEN `BACK`. " interact with previous app instance first - CAST z2ui5_cl_app_parent( client->get_app_prev( ) )->set_result( ms_result ). + CAST z2ui5_cl_app_parent( client->get_app_prev( ) )->set_result( s_result ). client->nav_app_leave( ). ENDCASE. @@ -268,6 +274,8 @@ Write everything directly in `main` — no method encapsulation needed. Count on ### Larger apps — canonical template +When the logic no longer fits inside `main`, always extract exactly `on_init` and `on_event` as the first step — never use other method names for this purpose. `main` then becomes a pure dispatcher that calls these two methods. Only add further methods (`view_display`, `data_read`, etc.) when they are actually needed. + The following is the **maximum structure**. Only add methods that are actually needed. ### Event handler sub-methods @@ -281,6 +289,7 @@ CLASS z2ui5_cl_app_xxx DEFINITION PUBLIC. " bound data (DATA attributes for _bind/_bind_edit)... PROTECTED SECTION. DATA client TYPE REF TO z2ui5_if_client. + METHODS on_init. " first call: load data, display view METHODS on_event. " user triggered an event METHODS on_navigation. " returned from sub-app or popup diff --git a/src/z2ui5_cl_demo_app_002.clas.abap b/src/z2ui5_cl_demo_app_002.clas.abap index 8d29fdf8..81fbf586 100644 --- a/src/z2ui5_cl_demo_app_002.clas.abap +++ b/src/z2ui5_cl_demo_app_002.clas.abap @@ -15,7 +15,7 @@ CLASS z2ui5_cl_demo_app_002 DEFINITION PUBLIC. END OF combobox_item. DATA: - BEGIN OF screen, + BEGIN OF s_screen, check_is_active TYPE abap_bool, colour TYPE string, combo_key TYPE string, @@ -27,10 +27,10 @@ CLASS z2ui5_cl_demo_app_002 DEFINITION PUBLIC. time_end TYPE string, check_switch_01 TYPE abap_bool VALUE abap_false, check_switch_02 TYPE abap_bool VALUE abap_false, - END OF screen. + END OF s_screen. - DATA suggestions TYPE STANDARD TABLE OF suggestion_item WITH EMPTY KEY. - DATA combo TYPE STANDARD TABLE OF combobox_item WITH EMPTY KEY. + DATA t_suggestions TYPE STANDARD TABLE OF suggestion_item WITH EMPTY KEY. + DATA t_combo TYPE STANDARD TABLE OF combobox_item WITH EMPTY KEY. PROTECTED SECTION. DATA client TYPE REF TO z2ui5_if_client. @@ -59,7 +59,7 @@ CLASS z2ui5_cl_demo_app_002 IMPLEMENTATION. METHOD on_init. - screen = VALUE #( + s_screen = VALUE #( check_is_active = abap_true colour = `BLUE` combo_key = `GRAY` @@ -69,7 +69,7 @@ CLASS z2ui5_cl_demo_app_002 IMPLEMENTATION. time_start = `05:24:00` time_end = `17:23:57` ). - suggestions = VALUE #( + t_suggestions = VALUE #( ( descr = `Green` value = `GREEN` ) ( descr = `Blue` value = `BLUE` ) ( descr = `Black` value = `BLACK` ) @@ -77,7 +77,7 @@ CLASS z2ui5_cl_demo_app_002 IMPLEMENTATION. ( descr = `Blue2` value = `BLUE2` ) ( descr = `Blue3` value = `BLUE3` ) ). - combo = VALUE #( + t_combo = VALUE #( ( key = `BLUE` text = `green` ) ( key = `GREEN` text = `blue` ) ( key = `BLACK` text = `red` ) @@ -94,7 +94,7 @@ CLASS z2ui5_cl_demo_app_002 IMPLEMENTATION. WHEN `BUTTON_SEND`. client->message_box_display( `success - values send to the server` ). WHEN `BUTTON_CLEAR`. - screen = VALUE #( ). + s_screen = VALUE #( ). client->message_toast_display( `View initialized` ). ENDCASE. @@ -120,9 +120,9 @@ CLASS z2ui5_cl_demo_app_002 IMPLEMENTATION. )->label( `Input with suggestion items` )->input( id = `suggInput` - value = client->_bind_edit( screen-colour ) + value = client->_bind_edit( s_screen-colour ) placeholder = `Fill in your favorite color` - suggestionitems = client->_bind( suggestions ) + suggestionitems = client->_bind( t_suggestions ) showsuggestion = abap_true )->get( )->suggestion_items( )->get( )->list_item( @@ -134,12 +134,12 @@ CLASS z2ui5_cl_demo_app_002 IMPLEMENTATION. editable = abap_true )->content( `form` )->label( `Date` - )->date_picker( client->_bind_edit( screen-date ) + )->date_picker( client->_bind_edit( s_screen-date ) )->label( `Date and Time` - )->date_time_picker( client->_bind_edit( screen-date_time ) + )->date_time_picker( client->_bind_edit( s_screen-date_time ) )->label( `Time Begin/End` - )->time_picker( client->_bind_edit( screen-time_start ) - )->time_picker( client->_bind_edit( screen-time_end ) ). + )->time_picker( client->_bind_edit( s_screen-time_start ) + )->time_picker( client->_bind_edit( s_screen-time_end ) ). DATA(content) = page->grid( `L12 M12 S12` )->content( `layout` @@ -149,26 +149,26 @@ CLASS z2ui5_cl_demo_app_002 IMPLEMENTATION. )->content( `form` ). content->label( `Checkbox` )->checkbox( - selected = client->_bind_edit( screen-check_is_active ) + selected = client->_bind_edit( s_screen-check_is_active ) text = `this is a checkbox` enabled = abap_true ). content->label( `Combobox` )->combobox( - selectedkey = client->_bind_edit( screen-combo_key ) - items = client->_bind( combo ) + selectedkey = client->_bind_edit( s_screen-combo_key ) + items = client->_bind( t_combo ) )->item( key = `{KEY}` text = `{TEXT}` ). content->label( `Combobox2` )->combobox( - selectedkey = client->_bind_edit( screen-combo_key2 ) - items = client->_bind( combo ) + selectedkey = client->_bind_edit( s_screen-combo_key2 ) + items = client->_bind( t_combo ) )->item( key = `{KEY}` text = `{TEXT}` ). content->label( `Segmented Button` )->segmented_button( - client->_bind_edit( screen-segment_key ) + client->_bind_edit( s_screen-segment_key ) )->items( )->segmented_button_item( key = `BLUE` @@ -189,13 +189,13 @@ CLASS z2ui5_cl_demo_app_002 IMPLEMENTATION. customtextoff = `B` ). content->label( `Switch accept/reject` )->switch( - state = client->_bind_edit( screen-check_switch_01 ) + state = client->_bind_edit( s_screen-check_switch_01 ) customtexton = `on` customtextoff = `off` type = `AcceptReject` ). content->label( `Switch normal` )->switch( - state = client->_bind_edit( screen-check_switch_02 ) + state = client->_bind_edit( s_screen-check_switch_02 ) customtexton = `YES` customtextoff = `NO` ). diff --git a/src/z2ui5_cl_demo_app_003.clas.abap b/src/z2ui5_cl_demo_app_003.clas.abap index f9aca216..e7f5f8c5 100644 --- a/src/z2ui5_cl_demo_app_003.clas.abap +++ b/src/z2ui5_cl_demo_app_003.clas.abap @@ -1,11 +1,10 @@ CLASS z2ui5_cl_demo_app_003 DEFINITION PUBLIC. PUBLIC SECTION. - INTERFACES z2ui5_if_app. TYPES: - BEGIN OF ty_row, + BEGIN OF ty_s_row, title TYPE string, value TYPE string, descr TYPE string, @@ -13,61 +12,54 @@ CLASS z2ui5_cl_demo_app_003 DEFINITION PUBLIC. info TYPE string, selected TYPE abap_bool, checkbox TYPE abap_bool, - END OF ty_row. - - DATA t_tab TYPE STANDARD TABLE OF ty_row WITH EMPTY KEY. - + END OF ty_s_row. + DATA t_tab TYPE STANDARD TABLE OF ty_s_row WITH EMPTY KEY. PROTECTED SECTION. PRIVATE SECTION. ENDCLASS. - -CLASS Z2UI5_CL_DEMO_APP_003 IMPLEMENTATION. - +CLASS z2ui5_cl_demo_app_003 IMPLEMENTATION. METHOD z2ui5_if_app~main. IF client->check_on_init( ). t_tab = VALUE #( - ( 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' ) ). + ( 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` ) ). DATA(view) = z2ui5_cl_xml_view=>factory( ). DATA(page) = view->shell( )->page( - title = 'abap2UI5 - List' - navbuttonpress = client->_event_nav_app_leave( ) - shownavbutton = client->check_app_prev_stack( ) ). + title = `abap2UI5 - List` + navbuttonpress = client->_event_nav_app_leave( ) + shownavbutton = client->check_app_prev_stack( ) ). page->list( - headertext = 'List Ouput' + headertext = `List Ouput` items = client->_bind_edit( t_tab ) mode = `SingleSelectMaster` - selectionchange = client->_event( 'SELCHANGE' ) + selectionchange = client->_event( `SELCHANGE` ) )->standard_list_item( - title = '{TITLE}' - description = '{DESCR}' - icon = '{ICON}' - info = '{INFO}' - press = client->_event( 'TEST' ) + title = `{TITLE}` + description = `{DESCR}` + icon = `{ICON}` + info = `{INFO}` + press = client->_event( `TEST` ) selected = `{SELECTED}` ). client->view_display( view->stringify( ) ). + ELSEIF client->check_on_event( `SELCHANGE` ). + client->message_box_display( |go to details for item { t_tab[ selected = abap_true ]-title }| ). ENDIF. - CASE client->get( )-event. - - WHEN 'SELCHANGE'. - client->message_box_display( `go to details for item ` && t_tab[ selected = abap_true ]-title ). - ENDCASE. - ENDMETHOD. + ENDCLASS. diff --git a/src/z2ui5_cl_demo_app_004.clas.abap b/src/z2ui5_cl_demo_app_004.clas.abap index 00e2787d..b742a96a 100644 --- a/src/z2ui5_cl_demo_app_004.clas.abap +++ b/src/z2ui5_cl_demo_app_004.clas.abap @@ -1,112 +1,126 @@ CLASS z2ui5_cl_demo_app_004 DEFINITION PUBLIC. PUBLIC SECTION. - INTERFACES z2ui5_if_app. - DATA mv_view_main TYPE string. + DATA view_main TYPE string. PROTECTED SECTION. - - METHODS z2ui5_view_main_display. - METHODS z2ui5_view_second_display. DATA client TYPE REF TO z2ui5_if_client. + METHODS on_init. + METHODS on_event. + METHODS view_main_display. + METHODS view_second_display. + PRIVATE SECTION. ENDCLASS. - CLASS z2ui5_cl_demo_app_004 IMPLEMENTATION. - METHOD z2ui5_if_app~main. me->client = client. - IF client->check_on_init( ). - z2ui5_view_main_display( ). - client->message_box_display( 'app started, init values set' ). - RETURN. + on_init( ). + ELSEIF client->check_on_event( ). + on_event( ). ENDIF. - CASE client->get( )-event. + ENDMETHOD. - WHEN 'BUTTON_ROUNDTRIP'. - client->message_box_display( 'server-client roundtrip, method on_event of the abap controller was called' ). - WHEN 'BUTTON_RESTART'. - client->nav_app_leave( NEW z2ui5_cl_demo_app_004( ) ). + METHOD on_init. - WHEN 'BUTTON_CHANGE_VIEW'. - CASE mv_view_main. - WHEN 'MAIN'. - z2ui5_view_second_display( ). - WHEN 'SECOND'. - z2ui5_view_main_display( ). - ENDCASE. + view_main_display( ). + client->message_box_display( `app started, init values set` ). - WHEN 'BUTTON_ERROR'. - DATA(lv_dummy) = 1 / 0. + ENDMETHOD. + + + METHOD on_event. + + CASE client->get( )-event. + WHEN `BUTTON_ROUNDTRIP`. + client->message_box_display( `server-client roundtrip, method on_event of the abap controller was called` ). + WHEN `BUTTON_RESTART`. + client->nav_app_leave( NEW z2ui5_cl_demo_app_004( ) ). + WHEN `BUTTON_CHANGE_VIEW`. + CASE view_main. + WHEN `MAIN`. + view_second_display( ). + WHEN `SECOND`. + view_main_display( ). + ENDCASE. + WHEN `BUTTON_ERROR`. + DATA(dummy) = 1 / 0. ENDCASE. ENDMETHOD. - METHOD z2ui5_view_main_display. + METHOD view_main_display. - mv_view_main = 'MAIN'. + view_main = `MAIN`. DATA(view) = z2ui5_cl_xml_view=>factory( ). DATA(page) = view->shell( )->page( - title = 'abap2UI5 - Controller' - navbuttonpress = client->_event_nav_app_leave( ) - shownavbutton = client->check_app_prev_stack( ) ). - - page->grid( 'L6 M12 S12' )->content( 'layout' - )->simple_form( title = 'Controller' - editable = abap_true )->content( 'form' - )->label( 'Roundtrip' + title = `abap2UI5 - Controller` + navbuttonpress = client->_event_nav_app_leave( ) + shownavbutton = client->check_app_prev_stack( ) ). + + page->grid( `L6 M12 S12` + )->content( `layout` + )->simple_form( + title = `Controller` + editable = abap_true + )->content( `form` + )->label( `Roundtrip` )->button( - text = 'Client/Server Interaction' - press = client->_event( 'BUTTON_ROUNDTRIP' ) - )->label( 'System' + text = `Client/Server Interaction` + press = client->_event( `BUTTON_ROUNDTRIP` ) + )->label( `System` )->button( - text = 'Restart App' - press = client->_event( 'BUTTON_RESTART' ) - )->label( 'Change View' + text = `Restart App` + press = client->_event( `BUTTON_RESTART` ) + )->label( `Change View` )->button( - text = 'Display View SECOND' - press = client->_event( 'BUTTON_CHANGE_VIEW' ) - )->label( 'CX_SY_ZERO_DIVIDE' + text = `Display View SECOND` + press = client->_event( `BUTTON_CHANGE_VIEW` ) + )->label( `CX_SY_ZERO_DIVIDE` )->button( - text = 'Error not catched by the user' - press = client->_event( 'BUTTON_ERROR' ) ). + text = `Error not catched by the user` + press = client->_event( `BUTTON_ERROR` ) ). client->view_display( view->stringify( ) ). ENDMETHOD. - METHOD z2ui5_view_second_display. + METHOD view_second_display. - mv_view_main = 'SECOND'. + view_main = `SECOND`. DATA(view) = z2ui5_cl_xml_view=>factory( ). - DATA(page) = view->shell( )->page( - title = 'abap2UI5 - Controller' - navbuttonpress = client->_event_nav_app_leave( ) - shownavbutton = client->check_app_prev_stack( ) ). - - page->grid( 'L12 M12 S12' )->content( 'layout' - )->simple_form( 'View Second' )->content( 'form' - )->label( 'Change View' + DATA(page) = view->shell( + )->page( + title = `abap2UI5 - Controller` + navbuttonpress = client->_event_nav_app_leave( ) + shownavbutton = client->check_app_prev_stack( ) ). + + page->grid( `L12 M12 S12` + )->content( `layout` + )->simple_form( `View Second` + )->content( `form` + )->label( `Change View` )->button( - text = 'Display View MAIN' - press = client->_event( 'BUTTON_CHANGE_VIEW' ) ). + text = `Display View MAIN` + press = client->_event( `BUTTON_CHANGE_VIEW` ) ). client->view_display( view->stringify( ) ). ENDMETHOD. + ENDCLASS. diff --git a/src/z2ui5_cl_demo_app_005.clas.abap b/src/z2ui5_cl_demo_app_005.clas.abap index db72df05..0767f793 100644 --- a/src/z2ui5_cl_demo_app_005.clas.abap +++ b/src/z2ui5_cl_demo_app_005.clas.abap @@ -1,60 +1,59 @@ CLASS z2ui5_cl_demo_app_005 DEFINITION PUBLIC. PUBLIC SECTION. - INTERFACES z2ui5_if_app. DATA value1 TYPE int4. DATA value2 TYPE int4. + PROTECTED SECTION. PRIVATE SECTION. ENDCLASS. - CLASS z2ui5_cl_demo_app_005 IMPLEMENTATION. - METHOD z2ui5_if_app~main. IF client->check_on_init( ). + value1 = 10. value2 = 90. - ENDIF. - CASE client->get( )-event. - WHEN 'SLIDER_CHANGE'. - - client->message_toast_display( |Range Slider { cl_abap_char_utilities=>newline }value1 { value1 } { cl_abap_char_utilities=>newline }value2 { value2 }| ). - - ENDCASE. + ELSEIF client->check_on_event( `SLIDER_CHANGE` ). + client->message_toast_display( |Range Slider { cl_abap_char_utilities=>newline }value1 { value1 } { cl_abap_char_utilities=>newline }value2 { value2 }| ). + ENDIF. DATA(view) = z2ui5_cl_xml_view=>factory( ). DATA(page) = view->shell( )->page( - title = 'abap2UI5 - Range Slider Example' - navbuttonpress = client->_event_nav_app_leave( ) - shownavbutton = client->check_app_prev_stack( ) ). - - DATA(grid) = page->grid( 'L12 M12 S12' )->content( 'layout' ). - - grid->simple_form( title = 'More Controls' - editable = abap_true )->content( 'form' - )->label( 'Range Slider' + title = `abap2UI5 - Range Slider Example` + navbuttonpress = client->_event_nav_app_leave( ) + shownavbutton = client->check_app_prev_stack( ) ). + + DATA(grid) = page->grid( `L12 M12 S12` + )->content( `layout` ). + + grid->simple_form( + title = `More Controls` + editable = abap_true + )->content( `form` + )->label( `Range Slider` )->range_slider( - max = '100' - min = '0' - step = '10' - startvalue = '10' - endvalue = '20' + max = `100` + min = `0` + step = `10` + startvalue = `10` + endvalue = `20` showtickmarks = abap_true - labelinterval = '2' - width = '80%' - class = 'sapUiTinyMargin' + labelinterval = `2` + width = `80%` + class = `sapUiTinyMargin` value = client->_bind_edit( value1 ) value2 = client->_bind_edit( value2 ) - change = client->_event( 'SLIDER_CHANGE' ) ). + change = client->_event( `SLIDER_CHANGE` ) ). client->view_display( view->stringify( ) ). ENDMETHOD. + ENDCLASS. diff --git a/src/z2ui5_cl_demo_app_006.clas.abap b/src/z2ui5_cl_demo_app_006.clas.abap index 72312b2b..7e401469 100644 --- a/src/z2ui5_cl_demo_app_006.clas.abap +++ b/src/z2ui5_cl_demo_app_006.clas.abap @@ -1,11 +1,10 @@ CLASS z2ui5_cl_demo_app_006 DEFINITION PUBLIC. PUBLIC SECTION. - INTERFACES z2ui5_if_app. TYPES: - BEGIN OF ty_row, + BEGIN OF ty_s_row, count TYPE i, value TYPE string, descr TYPE string, @@ -14,119 +13,146 @@ CLASS z2ui5_cl_demo_app_006 DEFINITION PUBLIC. checkbox TYPE abap_bool, percentage TYPE p LENGTH 5 DECIMALS 2, valuecolor TYPE string, - END OF ty_row. - - DATA t_tab TYPE STANDARD TABLE OF ty_row WITH EMPTY KEY. + END OF ty_s_row. + DATA t_tab TYPE STANDARD TABLE OF ty_s_row WITH EMPTY KEY. DATA check_ui5 TYPE abap_bool. - DATA mv_key TYPE string. - METHODS refresh_data. + DATA key TYPE string. PROTECTED SECTION. + DATA client TYPE REF TO z2ui5_if_client. + + METHODS on_init. + METHODS on_event. + METHODS view_display. + METHODS refresh_data. + PRIVATE SECTION. ENDCLASS. CLASS z2ui5_cl_demo_app_006 IMPLEMENTATION. + METHOD z2ui5_if_app~main. - METHOD refresh_data. - - DO 10000 TIMES. - DATA ls_row TYPE ty_row. - ls_row-count = sy-index. - ls_row-value = 'red'. - ls_row-descr = 'this is a description'. - ls_row-checkbox = abap_true. - ls_row-valuecolor = `Good`. - INSERT ls_row INTO TABLE t_tab. - ENDDO. + me->client = client. + IF client->check_on_init( ). + on_init( ). + ELSEIF client->check_on_event( ). + on_event( ). + ENDIF. ENDMETHOD. - METHOD z2ui5_if_app~main. + METHOD on_init. - IF client->check_on_init( ). - refresh_data( ). - ENDIF. + refresh_data( ). + view_display( ). - CASE client->get( )-event. + ENDMETHOD. - WHEN 'SORT_ASCENDING'. - SORT t_tab BY count ASCENDING. - client->message_toast_display( 'sort ascending' ). - WHEN 'SORT_DESCENDING'. + METHOD on_event. + + CASE client->get( )-event. + WHEN `SORT_ASCENDING`. + SORT t_tab BY count ASCENDING. + client->message_toast_display( `sort ascending` ). + WHEN `SORT_DESCENDING`. SORT t_tab BY count DESCENDING. - client->message_toast_display( 'sort descending' ). + client->message_toast_display( `sort descending` ). ENDCASE. + view_display( ). + + ENDMETHOD. + + + METHOD refresh_data. + + t_tab = VALUE #( FOR i = 1 UNTIL i > 10000 ( + count = i + value = `red` + descr = `this is a description` + checkbox = abap_true + valuecolor = `Good` ) ). + + ENDMETHOD. + + + METHOD view_display. + DATA(view) = z2ui5_cl_xml_view=>factory( ). DATA(page) = view->shell( )->page( - title = 'abap2UI5 - Scroll Container with Table and Toolbar' + title = `abap2UI5 - Scroll Container with Table and Toolbar` navbuttonpress = client->_event_nav_app_leave( ) shownavbutton = client->check_app_prev_stack( ) ). - DATA(tab) = page->scroll_container( height = '70%' - vertical = abap_true + DATA(tab) = page->scroll_container( + height = `70%` + vertical = abap_true )->table( growing = abap_true - growingthreshold = '20' + growingthreshold = `20` growingscrolltoload = abap_true items = client->_bind_edit( t_tab ) - sticky = 'ColumnHeaders,HeaderToolbar' ). + sticky = `ColumnHeaders,HeaderToolbar` ). tab->header_toolbar( )->toolbar( - )->title( 'title of the table' + )->title( `title of the table` )->button( - text = 'letf side button' - icon = 'sap-icon://account' - press = client->_event( 'BUTTON_SORT' ) - )->segmented_button( mv_key + text = `letf side button` + icon = `sap-icon://account` + press = client->_event( `BUTTON_SORT` ) + )->segmented_button( key )->items( )->segmented_button_item( - key = 'BLUE' - icon = 'sap-icon://accept' - text = 'blue' + key = `BLUE` + icon = `sap-icon://accept` + text = `blue` )->segmented_button_item( - key = 'GREEN' - icon = 'sap-icon://add-favorite' - text = 'green' + key = `GREEN` + icon = `sap-icon://add-favorite` + text = `green` )->get_parent( )->get_parent( )->toolbar_spacer( )->button( - icon = 'sap-icon://sort-descending' - press = client->_event( 'SORT_DESCENDING' ) + icon = `sap-icon://sort-descending` + press = client->_event( `SORT_DESCENDING` ) )->button( - icon = 'sap-icon://sort-ascending' - press = client->_event( 'SORT_ASCENDING' ) ). + icon = `sap-icon://sort-ascending` + press = client->_event( `SORT_ASCENDING` ) ). tab->columns( )->column( - )->text( 'Color' )->get_parent( + )->text( `Color` )->get_parent( )->column( - )->text( 'Info' )->get_parent( + )->text( `Info` )->get_parent( )->column( - )->text( 'Description' )->get_parent( + )->text( `Description` )->get_parent( )->column( - )->text( 'Checkbox' )->get_parent( + )->text( `Checkbox` )->get_parent( )->column( - )->text( 'Counter' )->get_parent( + )->text( `Counter` )->get_parent( )->column( - )->text( 'Radial Micro Chart' ). - - tab->items( )->column_list_item( )->cells( - )->text( '{VALUE}' - )->text( '{INFO}' - )->text( '{DESCR}' - )->checkbox( selected = '{CHECKBOX}' + )->text( `Radial Micro Chart` ). + + tab->items( + )->column_list_item( + )->cells( + )->text( `{VALUE}` + )->text( `{INFO}` + )->text( `{DESCR}` + )->checkbox( + selected = `{CHECKBOX}` enabled = abap_false - )->text( '{COUNT}' ). + )->text( `{COUNT}` ). client->view_display( view->stringify( ) ). ENDMETHOD. + ENDCLASS.