Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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( ) ).

Expand All @@ -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.

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
44 changes: 22 additions & 22 deletions src/z2ui5_cl_demo_app_002.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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.
Expand Down Expand Up @@ -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`
Expand All @@ -69,15 +69,15 @@ 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` )
( descr = `Gray` value = `GRAY` )
( 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` )
Expand All @@ -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.

Expand All @@ -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(
Expand All @@ -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`
Expand All @@ -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`
Expand All @@ -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` ).

Expand Down
54 changes: 23 additions & 31 deletions src/z2ui5_cl_demo_app_003.clas.abap
Original file line number Diff line number Diff line change
@@ -1,73 +1,65 @@
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,
icon TYPE string,
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.
Loading
Loading