From e5f0efe49310f630212227c2064af4515a87c118 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Mar 2026 13:58:32 +0000 Subject: [PATCH 01/14] Update CLAUDE.md to require Hungarian notation Replace the no-Hungarian-notation rule with a mandatory Hungarian notation convention. Update all code examples throughout the document to use the correct prefixes (mo_, mv_, mt_, ms_, lo_, lv_, lt_, ls_). https://claude.ai/code/session_01GVUQCR1XcJbdSPwHfUzoZB --- CLAUDE.md | 86 +++++++++++++++++++++++++++---------------------------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 0ce22ac3..7dbd1b70 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -33,7 +33,7 @@ All serialized files (`.abap`, `.xml`, and any other abapGit-managed file types) - 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. - 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 Hungarian notation — always add type prefixes to variable and attribute names (e.g. `lv_product` not `product`, `mo_client` not `client`, `lt_items` not `items`, `ls_row` not `row`). Common prefixes: `lv_` local value, `lt_` local table, `ls_` local structure, `lr_` local reference, `mv_` instance attribute value, `mt_` instance attribute table, `ms_` instance attribute structure, `mo_` instance attribute object. - 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). @@ -56,15 +56,15 @@ All serialized files (`.abap`, `.xml`, and any other abapGit-managed file types) - Always add 1 blank line **before** `ELSEIF` and `ELSE`. - If a branch (`IF`, `ELSEIF`, `ELSE`) contains **more than one statement**, add 1 blank line directly after the condition line as well: ```abap - me->client = client. + mo_client = io_client. - IF client->check_on_init( ). + IF mo_client->check_on_init( ). - product = `products`. - quantity = `500`. + mv_product = `products`. + mv_quantity = `500`. view_display( ). - ELSEIF client->check_on_event( `SAVE` ). + ELSEIF mo_client->check_on_event( `SAVE` ). data_update( ). ENDIF. ``` @@ -85,11 +85,11 @@ Every abap2UI5 app implements `z2ui5_if_app` with a single `main()` method. The Always use `ELSEIF` to chain these checks — never separate `IF` blocks: ```abap -IF client->check_on_init( ). +IF mo_client->check_on_init( ). ... -ELSEIF client->check_on_navigated( ). +ELSEIF mo_client->check_on_navigated( ). ... -ELSEIF client->check_on_event( ). +ELSEIF mo_client->check_on_event( ). ... ENDIF. ``` @@ -99,11 +99,11 @@ ENDIF. `check_on_event( )` accepts an optional event name argument. Use it to check for a specific event directly in the `ELSEIF` chain when there are **2–3 events** and no complex dispatch logic is needed: ```abap -IF client->check_on_init( ). +IF mo_client->check_on_init( ). ... -ELSEIF client->check_on_event( `SAVE` ). +ELSEIF mo_client->check_on_event( `SAVE` ). data_update( ). -ELSEIF client->check_on_event( `DELETE` ). +ELSEIF mo_client->check_on_event( `DELETE` ). data_delete( ). ENDIF. ``` @@ -137,12 +137,12 @@ Always use `client->_event_nav_app_leave()` to bind the back button event direct ```abap 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(lo_view) = z2ui5_cl_xml_view=>factory( ). + DATA(lo_page) = lo_view->page( title = `My App` + shownavbutton = mo_client->check_app_prev_stack( ) + navbuttonpress = mo_client->_event_nav_app_leave( ) ). " ... - client->view_display( view->stringify( ) ). + mo_client->view_display( lo_view->stringify( ) ). ENDMETHOD. ``` @@ -152,11 +152,11 @@ Only use the manual pattern (handling `BACK` in `on_event`) when you need to do ```abap METHOD on_event. - CASE client->get( )-event. + CASE mo_client->get( )-event. WHEN `BACK`. " interact with previous app instance first - CAST z2ui5_cl_app_parent( client->get_app_prev( ) )->set_result( ms_result ). - client->nav_app_leave( ). + CAST z2ui5_cl_app_parent( mo_client->get_app_prev( ) )->set_result( ms_result ). + mo_client->nav_app_leave( ). ENDCASE. ENDMETHOD. @@ -171,9 +171,9 @@ Pre-built methods for common UI5 controls (`shell`, `page`, `simple_form`, `inpu #### View structure and indentation -Always add 1 blank line before `DATA(view) = z2ui5_cl_xml_view=>factory( ).` to visually separate view construction from preceding logic. +Always add 1 blank line before `DATA(lo_view) = z2ui5_cl_xml_view=>factory( ).` to visually separate view construction from preceding logic. -Always build the view in `view_display` and call `client->view_display( view->stringify( ) )` as a **standalone statement at the end** — never nested inside the chain. +Always build the view in `view_display` and call `mo_client->view_display( lo_view->stringify( ) )` as a **standalone statement at the end** — never nested inside the chain. Indent the fluent chain to reflect the XML hierarchy: - Each method that **navigates into a child element** (returns a child node) is indented **4 spaces deeper** than its parent call. @@ -186,11 +186,11 @@ Indent the fluent chain to reflect the XML hierarchy: ```abap )->input( - value = product + value = mv_product enabled = abap_false )->button( text = `Post` - press = client->_event( `POST` ) ). + press = mo_client->_event( `POST` ) ). ``` Never put two or more named parameters on the same line. @@ -198,26 +198,26 @@ Never put two or more named parameters on the same line. ```abap METHOD view_display. - DATA(view) = z2ui5_cl_xml_view=>factory( ). - view->shell( + DATA(lo_view) = z2ui5_cl_xml_view=>factory( ). + lo_view->shell( )->page( title = `My App` - navbuttonpress = client->_event_nav_app_leave( ) - shownavbutton = client->check_app_prev_stack( ) + navbuttonpress = mo_client->_event_nav_app_leave( ) + shownavbutton = mo_client->check_app_prev_stack( ) )->simple_form( title = `Form Title` editable = abap_true )->content( `form` )->label( `Quantity` - )->input( client->_bind_edit( quantity ) + )->input( mo_client->_bind_edit( mv_quantity ) )->label( `Product` )->input( - value = product + value = mv_product enabled = abap_false )->button( text = `Post` - press = client->_event( `POST` ) ). - client->view_display( view->stringify( ) ). + press = mo_client->_event( `POST` ) ). + mo_client->view_display( lo_view->stringify( ) ). ENDMETHOD. ``` @@ -245,7 +245,7 @@ Builds any XML structure directly from element names, namespaces and attributes. ( n = `editable` v = abap_true ) ) )->_( n = `content` ns = `form` )->__( n = `Label` a = `text` v = `qty` -)->__( n = `Input` a = `value` v = client->_bind_edit( qty ) ) +)->__( n = `Input` a = `value` v = mo_client->_bind_edit( mv_qty ) ) ``` Key rules for `z2ui5_cl_util_xml`: @@ -280,7 +280,7 @@ CLASS z2ui5_cl_app_xxx DEFINITION PUBLIC. INTERFACES z2ui5_if_app. " bound data (DATA attributes for _bind/_bind_edit)... PROTECTED SECTION. - DATA client TYPE REF TO z2ui5_if_client. + DATA mo_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 @@ -295,12 +295,12 @@ CLASS z2ui5_cl_app_xxx IMPLEMENTATION. METHOD z2ui5_if_app~main. - me->client = client. - IF client->check_on_init( ). + mo_client = io_client. + IF mo_client->check_on_init( ). on_init( ). - ELSEIF client->check_on_navigated( ). + ELSEIF mo_client->check_on_navigated( ). on_navigation( ). - ELSEIF client->check_on_event( ). + ELSEIF mo_client->check_on_event( ). on_event( ). ENDIF. @@ -318,18 +318,18 @@ CLASS z2ui5_cl_app_xxx IMPLEMENTATION. METHOD on_navigation. data_read( ). - client->view_model_update( ). + mo_client->view_model_update( ). ENDMETHOD. METHOD on_event. - CASE client->get( )-event. + CASE mo_client->get( )-event. WHEN `SAVE`. on_event_save( ). WHEN `BACK`. - client->nav_app_leave( ). + mo_client->nav_app_leave( ). ENDCASE. ENDMETHOD. @@ -344,9 +344,9 @@ CLASS z2ui5_cl_app_xxx IMPLEMENTATION. METHOD view_display. - DATA(view) = z2ui5_cl_xml_view=>factory( ). + DATA(lo_view) = z2ui5_cl_xml_view=>factory( ). " ... - client->view_display( view->stringify( ) ). + mo_client->view_display( lo_view->stringify( ) ). ENDMETHOD. From 95855ff8efc16289f648b31fc4eb2bfbc6c5df2d Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Mar 2026 14:03:00 +0000 Subject: [PATCH 02/14] Refactor app 002 and update notation rule to t_/s_ prefixes only Add t_ prefix to table attributes (t_suggestions, t_combo) and s_ prefix to structure attributes (s_screen) in app 002. Update CLAUDE.md to reflect the narrowed convention: only tables and structures get type prefixes. https://claude.ai/code/session_01GVUQCR1XcJbdSPwHfUzoZB --- CLAUDE.md | 86 ++++++++++++++--------------- src/z2ui5_cl_demo_app_002.clas.abap | 44 +++++++-------- 2 files changed, 65 insertions(+), 65 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 7dbd1b70..6beda517 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -33,7 +33,7 @@ All serialized files (`.abap`, `.xml`, and any other abapGit-managed file types) - 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. - Prefer functional to procedural language constructs — use `var = VALUE #( ).` to reset a variable, never `CLEAR var.`. -- Use Hungarian notation — always add type prefixes to variable and attribute names (e.g. `lv_product` not `product`, `mo_client` not `client`, `lt_items` not `items`, `ls_row` not `row`). Common prefixes: `lv_` local value, `lt_` local table, `ls_` local structure, `lr_` local reference, `mv_` instance attribute value, `mt_` instance attribute table, `ms_` instance attribute structure, `mo_` instance attribute object. +- 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. - 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). @@ -56,15 +56,15 @@ All serialized files (`.abap`, `.xml`, and any other abapGit-managed file types) - Always add 1 blank line **before** `ELSEIF` and `ELSE`. - If a branch (`IF`, `ELSEIF`, `ELSE`) contains **more than one statement**, add 1 blank line directly after the condition line as well: ```abap - mo_client = io_client. + me->client = client. - IF mo_client->check_on_init( ). + IF client->check_on_init( ). - mv_product = `products`. - mv_quantity = `500`. + product = `products`. + quantity = `500`. view_display( ). - ELSEIF mo_client->check_on_event( `SAVE` ). + ELSEIF client->check_on_event( `SAVE` ). data_update( ). ENDIF. ``` @@ -85,11 +85,11 @@ Every abap2UI5 app implements `z2ui5_if_app` with a single `main()` method. The Always use `ELSEIF` to chain these checks — never separate `IF` blocks: ```abap -IF mo_client->check_on_init( ). +IF client->check_on_init( ). ... -ELSEIF mo_client->check_on_navigated( ). +ELSEIF client->check_on_navigated( ). ... -ELSEIF mo_client->check_on_event( ). +ELSEIF client->check_on_event( ). ... ENDIF. ``` @@ -99,11 +99,11 @@ ENDIF. `check_on_event( )` accepts an optional event name argument. Use it to check for a specific event directly in the `ELSEIF` chain when there are **2–3 events** and no complex dispatch logic is needed: ```abap -IF mo_client->check_on_init( ). +IF client->check_on_init( ). ... -ELSEIF mo_client->check_on_event( `SAVE` ). +ELSEIF client->check_on_event( `SAVE` ). data_update( ). -ELSEIF mo_client->check_on_event( `DELETE` ). +ELSEIF client->check_on_event( `DELETE` ). data_delete( ). ENDIF. ``` @@ -137,12 +137,12 @@ Always use `client->_event_nav_app_leave()` to bind the back button event direct ```abap METHOD view_display. - DATA(lo_view) = z2ui5_cl_xml_view=>factory( ). - DATA(lo_page) = lo_view->page( title = `My App` - shownavbutton = mo_client->check_app_prev_stack( ) - navbuttonpress = mo_client->_event_nav_app_leave( ) ). + 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( ) ). " ... - mo_client->view_display( lo_view->stringify( ) ). + client->view_display( view->stringify( ) ). ENDMETHOD. ``` @@ -152,11 +152,11 @@ Only use the manual pattern (handling `BACK` in `on_event`) when you need to do ```abap METHOD on_event. - CASE mo_client->get( )-event. + CASE client->get( )-event. WHEN `BACK`. " interact with previous app instance first - CAST z2ui5_cl_app_parent( mo_client->get_app_prev( ) )->set_result( ms_result ). - mo_client->nav_app_leave( ). + CAST z2ui5_cl_app_parent( client->get_app_prev( ) )->set_result( s_result ). + client->nav_app_leave( ). ENDCASE. ENDMETHOD. @@ -171,9 +171,9 @@ Pre-built methods for common UI5 controls (`shell`, `page`, `simple_form`, `inpu #### View structure and indentation -Always add 1 blank line before `DATA(lo_view) = z2ui5_cl_xml_view=>factory( ).` to visually separate view construction from preceding logic. +Always add 1 blank line before `DATA(view) = z2ui5_cl_xml_view=>factory( ).` to visually separate view construction from preceding logic. -Always build the view in `view_display` and call `mo_client->view_display( lo_view->stringify( ) )` as a **standalone statement at the end** — never nested inside the chain. +Always build the view in `view_display` and call `client->view_display( view->stringify( ) )` as a **standalone statement at the end** — never nested inside the chain. Indent the fluent chain to reflect the XML hierarchy: - Each method that **navigates into a child element** (returns a child node) is indented **4 spaces deeper** than its parent call. @@ -186,11 +186,11 @@ Indent the fluent chain to reflect the XML hierarchy: ```abap )->input( - value = mv_product + value = product enabled = abap_false )->button( text = `Post` - press = mo_client->_event( `POST` ) ). + press = client->_event( `POST` ) ). ``` Never put two or more named parameters on the same line. @@ -198,26 +198,26 @@ Never put two or more named parameters on the same line. ```abap METHOD view_display. - DATA(lo_view) = z2ui5_cl_xml_view=>factory( ). - lo_view->shell( + DATA(view) = z2ui5_cl_xml_view=>factory( ). + view->shell( )->page( title = `My App` - navbuttonpress = mo_client->_event_nav_app_leave( ) - shownavbutton = mo_client->check_app_prev_stack( ) + navbuttonpress = client->_event_nav_app_leave( ) + shownavbutton = client->check_app_prev_stack( ) )->simple_form( title = `Form Title` editable = abap_true )->content( `form` )->label( `Quantity` - )->input( mo_client->_bind_edit( mv_quantity ) + )->input( client->_bind_edit( quantity ) )->label( `Product` )->input( - value = mv_product + value = product enabled = abap_false )->button( text = `Post` - press = mo_client->_event( `POST` ) ). - mo_client->view_display( lo_view->stringify( ) ). + press = client->_event( `POST` ) ). + client->view_display( view->stringify( ) ). ENDMETHOD. ``` @@ -245,7 +245,7 @@ Builds any XML structure directly from element names, namespaces and attributes. ( n = `editable` v = abap_true ) ) )->_( n = `content` ns = `form` )->__( n = `Label` a = `text` v = `qty` -)->__( n = `Input` a = `value` v = mo_client->_bind_edit( mv_qty ) ) +)->__( n = `Input` a = `value` v = client->_bind_edit( qty ) ) ``` Key rules for `z2ui5_cl_util_xml`: @@ -280,7 +280,7 @@ CLASS z2ui5_cl_app_xxx DEFINITION PUBLIC. INTERFACES z2ui5_if_app. " bound data (DATA attributes for _bind/_bind_edit)... PROTECTED SECTION. - DATA mo_client TYPE REF TO z2ui5_if_client. + 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 @@ -295,12 +295,12 @@ CLASS z2ui5_cl_app_xxx IMPLEMENTATION. METHOD z2ui5_if_app~main. - mo_client = io_client. - IF mo_client->check_on_init( ). + me->client = client. + IF client->check_on_init( ). on_init( ). - ELSEIF mo_client->check_on_navigated( ). + ELSEIF client->check_on_navigated( ). on_navigation( ). - ELSEIF mo_client->check_on_event( ). + ELSEIF client->check_on_event( ). on_event( ). ENDIF. @@ -318,18 +318,18 @@ CLASS z2ui5_cl_app_xxx IMPLEMENTATION. METHOD on_navigation. data_read( ). - mo_client->view_model_update( ). + client->view_model_update( ). ENDMETHOD. METHOD on_event. - CASE mo_client->get( )-event. + CASE client->get( )-event. WHEN `SAVE`. on_event_save( ). WHEN `BACK`. - mo_client->nav_app_leave( ). + client->nav_app_leave( ). ENDCASE. ENDMETHOD. @@ -344,9 +344,9 @@ CLASS z2ui5_cl_app_xxx IMPLEMENTATION. METHOD view_display. - DATA(lo_view) = z2ui5_cl_xml_view=>factory( ). + DATA(view) = z2ui5_cl_xml_view=>factory( ). " ... - mo_client->view_display( lo_view->stringify( ) ). + client->view_display( view->stringify( ) ). ENDMETHOD. 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` ). From d88a6ac90953bb260295a81a48e50e83c91b9ad9 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Mar 2026 14:27:27 +0000 Subject: [PATCH 03/14] Refactor app 003 to follow code conventions - Lowercase class name in IMPLEMENTATION block - Replace all single quotes with backticks - Fix shownavbutton indentation alignment - Replace separate CASE block with ELSEIF chain - Fix blank lines: class definition, between blocks, inside method https://claude.ai/code/session_01GVUQCR1XcJbdSPwHfUzoZB --- src/z2ui5_cl_demo_app_003.clas.abap | 47 ++++++++++++----------------- 1 file changed, 20 insertions(+), 27 deletions(-) diff --git a/src/z2ui5_cl_demo_app_003.clas.abap b/src/z2ui5_cl_demo_app_003.clas.abap index f9aca216..e77f1332 100644 --- a/src/z2ui5_cl_demo_app_003.clas.abap +++ b/src/z2ui5_cl_demo_app_003.clas.abap @@ -1,7 +1,6 @@ CLASS z2ui5_cl_demo_app_003 DEFINITION PUBLIC. PUBLIC SECTION. - INTERFACES z2ui5_if_app. TYPES: @@ -17,57 +16,51 @@ CLASS z2ui5_cl_demo_app_003 DEFINITION PUBLIC. DATA t_tab TYPE STANDARD TABLE OF ty_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. From aa2d4ec1c3febb3c904d2b881b33824f66504451 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Mar 2026 14:29:49 +0000 Subject: [PATCH 04/14] Add ty_s_/ty_t_ type naming convention and apply to app 003 Update CLAUDE.md: structure types use ty_s_ prefix, table types use ty_t_, and no blank line between a TYPES definition and its DATA declaration. Rename ty_row to ty_s_row, add ty_t_tab type, and update DATA declaration in app 003 accordingly. https://claude.ai/code/session_01GVUQCR1XcJbdSPwHfUzoZB --- CLAUDE.md | 2 ++ src/z2ui5_cl_demo_app_003.clas.abap | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 6beda517..a43d8dea 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -34,6 +34,8 @@ All serialized files (`.abap`, `.xml`, and any other abapGit-managed file types) - Use backticks for all string literals, not single quotes. - Prefer functional to procedural language constructs — use `var = VALUE #( ).` to reset a variable, never `CLEAR var.`. - 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`). +- 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). diff --git a/src/z2ui5_cl_demo_app_003.clas.abap b/src/z2ui5_cl_demo_app_003.clas.abap index e77f1332..206b4bdb 100644 --- a/src/z2ui5_cl_demo_app_003.clas.abap +++ b/src/z2ui5_cl_demo_app_003.clas.abap @@ -4,7 +4,7 @@ CLASS z2ui5_cl_demo_app_003 DEFINITION PUBLIC. INTERFACES z2ui5_if_app. TYPES: - BEGIN OF ty_row, + BEGIN OF ty_s_row, title TYPE string, value TYPE string, descr TYPE string, @@ -12,9 +12,9 @@ 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. + TYPES ty_t_tab TYPE STANDARD TABLE OF ty_s_row WITH EMPTY KEY. + DATA t_tab TYPE ty_t_tab. PROTECTED SECTION. PRIVATE SECTION. From 0c5e1163817cfc125d3fe3f3f52fd632d9d7ac93 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Mar 2026 14:31:14 +0000 Subject: [PATCH 05/14] Only define ty_t_ table type when used more than once Update rule in CLAUDE.md and simplify app 003: since t_tab is used only once, replace the ty_t_tab type definition with an inline STANDARD TABLE OF declaration directly on the DATA attribute. https://claude.ai/code/session_01GVUQCR1XcJbdSPwHfUzoZB --- CLAUDE.md | 2 +- src/z2ui5_cl_demo_app_003.clas.abap | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index a43d8dea..384428bf 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -34,7 +34,7 @@ All serialized files (`.abap`, `.xml`, and any other abapGit-managed file types) - Use backticks for all string literals, not single quotes. - Prefer functional to procedural language constructs — use `var = VALUE #( ).` to reset a variable, never `CLEAR var.`. - 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`). +- 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. diff --git a/src/z2ui5_cl_demo_app_003.clas.abap b/src/z2ui5_cl_demo_app_003.clas.abap index 206b4bdb..1ffc11f5 100644 --- a/src/z2ui5_cl_demo_app_003.clas.abap +++ b/src/z2ui5_cl_demo_app_003.clas.abap @@ -13,8 +13,7 @@ CLASS z2ui5_cl_demo_app_003 DEFINITION PUBLIC. selected TYPE abap_bool, checkbox TYPE abap_bool, END OF ty_s_row. - TYPES ty_t_tab TYPE STANDARD TABLE OF ty_s_row WITH EMPTY KEY. - DATA t_tab TYPE ty_t_tab. + DATA t_tab TYPE STANDARD TABLE OF ty_s_row WITH EMPTY KEY. PROTECTED SECTION. PRIVATE SECTION. From 5e64a7b4ea28e03fac0b9906bb4e2982e56463a0 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Mar 2026 14:32:43 +0000 Subject: [PATCH 06/14] Use string templates instead of && concatenation in app 003 and CLAUDE.md Replace && with string template |...{ }...| in app 003 message call. Add rule to CLAUDE.md: always prefer string templates over && operator. https://claude.ai/code/session_01GVUQCR1XcJbdSPwHfUzoZB --- CLAUDE.md | 1 + src/z2ui5_cl_demo_app_003.clas.abap | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CLAUDE.md b/CLAUDE.md index 384428bf..b1898c40 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -32,6 +32,7 @@ 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.`. - 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`. diff --git a/src/z2ui5_cl_demo_app_003.clas.abap b/src/z2ui5_cl_demo_app_003.clas.abap index 1ffc11f5..e7f5f8c5 100644 --- a/src/z2ui5_cl_demo_app_003.clas.abap +++ b/src/z2ui5_cl_demo_app_003.clas.abap @@ -57,7 +57,7 @@ CLASS z2ui5_cl_demo_app_003 IMPLEMENTATION. 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 ). + client->message_box_display( |go to details for item { t_tab[ selected = abap_true ]-title }| ). ENDIF. ENDMETHOD. From 128d7ccdbaed3e73a7e610916cfd2fdde695caad Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Mar 2026 14:37:41 +0000 Subject: [PATCH 07/14] Refactor app 004 to follow code conventions - Remove mv_ prefix: mv_view_main -> view_main - Remove lv_ prefix: lv_dummy -> dummy - Replace all single quotes with backticks - Fix blank lines: class definition, between blocks, inside methods - Replace IF/RETURN/ENDIF + CASE with proper ELSEIF chain - Fix simple_form parameters onto separate lines - Fix shownavbutton alignment in both view methods - Fix indentation of grid/content/simple_form chain https://claude.ai/code/session_01GVUQCR1XcJbdSPwHfUzoZB --- src/z2ui5_cl_demo_app_004.clas.abap | 120 ++++++++++++++-------------- 1 file changed, 61 insertions(+), 59 deletions(-) diff --git a/src/z2ui5_cl_demo_app_004.clas.abap b/src/z2ui5_cl_demo_app_004.clas.abap index 00e2787d..11ec5666 100644 --- a/src/z2ui5_cl_demo_app_004.clas.abap +++ b/src/z2ui5_cl_demo_app_004.clas.abap @@ -1,88 +1,86 @@ 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. 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. - ENDIF. - 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 mv_view_main. - WHEN 'MAIN'. - z2ui5_view_second_display( ). - WHEN 'SECOND'. - z2ui5_view_main_display( ). - ENDCASE. + z2ui5_view_main_display( ). + client->message_box_display( `app started, init values set` ). + + ELSEIF client->check_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`. + z2ui5_view_second_display( ). + WHEN `SECOND`. + z2ui5_view_main_display( ). + ENDCASE. + WHEN `BUTTON_ERROR`. + DATA(dummy) = 1 / 0. + ENDCASE. - WHEN 'BUTTON_ERROR'. - DATA(lv_dummy) = 1 / 0. - ENDCASE. + ENDIF. ENDMETHOD. METHOD z2ui5_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( ) ). @@ -91,22 +89,26 @@ CLASS z2ui5_cl_demo_app_004 IMPLEMENTATION. METHOD z2ui5_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. From 1e8943406fa5f544498644e39c880e99e6c44047 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Mar 2026 14:39:42 +0000 Subject: [PATCH 08/14] Move client declaration to top of PROTECTED SECTION in app 004 and CLAUDE.md Add rule: DATA client always comes first in PROTECTED SECTION, before any METHODS declarations. Fix app 004 accordingly. https://claude.ai/code/session_01GVUQCR1XcJbdSPwHfUzoZB --- CLAUDE.md | 1 + src/z2ui5_cl_demo_app_004.clas.abap | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index b1898c40..ac8b3e9f 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -41,6 +41,7 @@ All serialized files (`.abap`, `.xml`, and any other abapGit-managed file types) - 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 `PROTECTED SECTION.`, always declare `DATA client TYPE REF TO z2ui5_if_client.` first, before any `METHODS` declarations. - **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. diff --git a/src/z2ui5_cl_demo_app_004.clas.abap b/src/z2ui5_cl_demo_app_004.clas.abap index 11ec5666..3284bccd 100644 --- a/src/z2ui5_cl_demo_app_004.clas.abap +++ b/src/z2ui5_cl_demo_app_004.clas.abap @@ -6,11 +6,11 @@ CLASS z2ui5_cl_demo_app_004 DEFINITION PUBLIC. DATA view_main TYPE string. PROTECTED SECTION. + DATA client TYPE REF TO z2ui5_if_client. + METHODS z2ui5_view_main_display. METHODS z2ui5_view_second_display. - DATA client TYPE REF TO z2ui5_if_client. - PRIVATE SECTION. ENDCLASS. From 87d1b3635b0a776518f118aece220be2877de2e6 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Mar 2026 14:40:03 +0000 Subject: [PATCH 09/14] Generalize declaration order rule: TYPES then DATA then METHODS Replace the client-specific rule with a general ordering rule that applies to all sections: TYPES declarations first, then DATA, then METHODS. https://claude.ai/code/session_01GVUQCR1XcJbdSPwHfUzoZB --- CLAUDE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CLAUDE.md b/CLAUDE.md index ac8b3e9f..0f72b65a 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -41,7 +41,7 @@ All serialized files (`.abap`, `.xml`, and any other abapGit-managed file types) - 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 `PROTECTED SECTION.`, always declare `DATA client TYPE REF TO z2ui5_if_client.` first, before any `METHODS` declarations. +- 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. From 79c9cd773d0b50313200c150e30c16a923c61648 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Mar 2026 14:41:09 +0000 Subject: [PATCH 10/14] Add rule: extract on_init and on_event when main grows too large MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When logic no longer fits in main, always extract on_init and on_event first — never use other method names for this purpose. https://claude.ai/code/session_01GVUQCR1XcJbdSPwHfUzoZB --- CLAUDE.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CLAUDE.md b/CLAUDE.md index 0f72b65a..de79123e 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -272,6 +272,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 From 20010764177f21ad144ced463bf52c9fab7262f1 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Mar 2026 14:43:12 +0000 Subject: [PATCH 11/14] Refactor app 004: extract on_init and on_event, clean up method names Extract on_init and on_event from main, making main a pure dispatcher. Rename z2ui5_view_main_display/z2ui5_view_second_display to view_main_display/view_second_display. https://claude.ai/code/session_01GVUQCR1XcJbdSPwHfUzoZB --- src/z2ui5_cl_demo_app_004.clas.abap | 58 +++++++++++++++++------------ 1 file changed, 35 insertions(+), 23 deletions(-) diff --git a/src/z2ui5_cl_demo_app_004.clas.abap b/src/z2ui5_cl_demo_app_004.clas.abap index 3284bccd..b742a96a 100644 --- a/src/z2ui5_cl_demo_app_004.clas.abap +++ b/src/z2ui5_cl_demo_app_004.clas.abap @@ -8,8 +8,10 @@ CLASS z2ui5_cl_demo_app_004 DEFINITION PUBLIC. PROTECTED SECTION. DATA client TYPE REF TO z2ui5_if_client. - METHODS z2ui5_view_main_display. - METHODS z2ui5_view_second_display. + METHODS on_init. + METHODS on_event. + METHODS view_main_display. + METHODS view_second_display. PRIVATE SECTION. ENDCLASS. @@ -21,34 +23,44 @@ CLASS z2ui5_cl_demo_app_004 IMPLEMENTATION. me->client = client. IF client->check_on_init( ). + on_init( ). + ELSEIF client->check_on_event( ). + on_event( ). + ENDIF. - z2ui5_view_main_display( ). - client->message_box_display( `app started, init values set` ). + ENDMETHOD. - ELSEIF client->check_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`. - z2ui5_view_second_display( ). - WHEN `SECOND`. - z2ui5_view_main_display( ). - ENDCASE. - WHEN `BUTTON_ERROR`. - DATA(dummy) = 1 / 0. - ENDCASE. + METHOD on_init. - ENDIF. + view_main_display( ). + client->message_box_display( `app started, init values set` ). + + 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. view_main = `MAIN`. @@ -87,7 +99,7 @@ CLASS z2ui5_cl_demo_app_004 IMPLEMENTATION. ENDMETHOD. - METHOD z2ui5_view_second_display. + METHOD view_second_display. view_main = `SECOND`. From f4beb46147d2aeb30fcf28f5818dc85c1607f24b Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Mar 2026 14:45:38 +0000 Subject: [PATCH 12/14] Fix two inconsistencies in CLAUDE.md examples - Back Navigation example: fix view->page() to use shell()->page() chain with parameters split across lines per multi-parameter rule - Canonical template: add missing blank line between DATA client and METHODS group in PROTECTED SECTION https://claude.ai/code/session_01GVUQCR1XcJbdSPwHfUzoZB --- CLAUDE.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index de79123e..fdecab57 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -142,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( ) ). @@ -287,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 From 8a3a07e4c89c5ffd12b78a0ce79a3d7c77777a8f Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Mar 2026 14:48:57 +0000 Subject: [PATCH 13/14] Refactor app 006 to follow code conventions - Rename ty_row to ty_s_row, mv_key to key - Move refresh_data and new methods to PROTECTED SECTION - Add DATA client to PROTECTED SECTION - Extract on_init, on_event, view_display from main - Replace IF/ENDIF + CASE with ELSEIF dispatcher in main - Replace DO loop with functional VALUE #( FOR ... ) in refresh_data - Replace all single quotes with backticks - Fix scroll_container and items/cells chain indentation and parameter formatting https://claude.ai/code/session_01GVUQCR1XcJbdSPwHfUzoZB --- src/z2ui5_cl_demo_app_006.clas.abap | 148 ++++++++++++++++------------ 1 file changed, 87 insertions(+), 61 deletions(-) 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. From b583775d3f43d646bf969a0adff03c3bf62bdf21 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Mar 2026 15:06:31 +0000 Subject: [PATCH 14/14] Refactor app 005 to follow code conventions - Fix blank lines in class definition and between blocks - Replace IF/ENDIF + CASE with ELSEIF chain (single event) - Replace all single quotes with backticks - Fix shownavbutton alignment - Split simple_form parameters onto separate lines - Fix grid->content chain indentation https://claude.ai/code/session_01GVUQCR1XcJbdSPwHfUzoZB --- src/z2ui5_cl_demo_app_005.clas.abap | 55 ++++++++++++++--------------- 1 file changed, 27 insertions(+), 28 deletions(-) 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.