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
3 changes: 3 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
- 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`).
- 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.
Expand Down Expand Up @@ -263,6 +264,8 @@ Key rules for `z2ui5_cl_util_xml`:

Write everything directly in `main` — no method encapsulation needed. Count only the lines inside the `main` method, not the total class length.

**Do not extract `view_display` or any other helper method just because the app has a view.** A separate `view_display` method is only justified when the app is large enough to warrant the full canonical structure (≥ 50 lines in `main`). Extracting it in a simple app adds unnecessary indirection.

### Larger apps — canonical template

The following is the **maximum structure**. Only add methods that are actually needed.
Expand Down
86 changes: 26 additions & 60 deletions src/z2ui5_cl_demo_app_001.clas.abap
Original file line number Diff line number Diff line change
@@ -1,84 +1,50 @@
CLASS z2ui5_cl_demo_app_001 DEFINITION PUBLIC CREATE PUBLIC.
CLASS z2ui5_cl_demo_app_001 DEFINITION PUBLIC.

PUBLIC SECTION.

INTERFACES z2ui5_if_app.

DATA product TYPE string.
DATA quantity TYPE string.


PROTECTED SECTION.

DATA client TYPE REF TO z2ui5_if_client.

METHODS z2ui5_set_data.

METHODS display_view
IMPORTING
client TYPE REF TO z2ui5_if_client.
METHODS on_event
IMPORTING
client TYPE REF TO z2ui5_if_client.

PRIVATE SECTION.
ENDCLASS.



CLASS z2ui5_cl_demo_app_001 IMPLEMENTATION.

METHOD z2ui5_if_app~main.

me->client = client.


IF client->check_on_init( ).
display_view( client ).
z2ui5_set_data( ).
ENDIF.

on_event( client ).

ENDMETHOD.


METHOD display_view.

DATA(view) = z2ui5_cl_xml_view=>factory( ).
client->view_display( view->shell(
)->page(
title = 'abap2UI5 - First Example'
navbuttonpress = client->_event_nav_app_leave( )
shownavbutton = client->check_app_prev_stack( )
)->simple_form( title = 'Form Title' editable = abap_true
)->content( 'form'
)->title( 'Input'
)->label( 'quantity'
)->input( client->_bind_edit( quantity )
)->label( `product`
)->input( value = product enabled = abap_false
)->button(
text = 'post'
press = client->_event( 'BUTTON_POST' )
)->stringify( ) ).

ENDMETHOD.


METHOD on_event.

IF client->check_on_event( 'BUTTON_POST' ).
product = `products`.
quantity = `500`.

DATA(view) = z2ui5_cl_xml_view=>factory( ).
view->shell(
)->page(
title = `abap2UI5 - First Example`
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( client->_bind_edit( quantity )
)->label( `product`
)->input(
value = product
enabled = abap_false
)->button(
text = `post`
press = client->_event( `BUTTON_POST` ) ).
client->view_display( view->stringify( ) ).

ELSEIF client->check_on_event( `BUTTON_POST` ).
client->message_toast_display( |{ product } { quantity } - send to the server| ).
ENDIF.

ENDMETHOD.


METHOD z2ui5_set_data.

product = 'products'.
quantity = '500'.

ENDMETHOD.
ENDCLASS.
Loading
Loading