Skip to content

Commit ec59e8f

Browse files
authored
Merge pull request #40 from abap2UI5/claude/review-docs-snippets-ab7yz
optimize language and add explanations
2 parents 93a658f + 36a5e97 commit ec59e8f

40 files changed

Lines changed: 423 additions & 191 deletions

docs/advanced/extensibility/custom_js.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ If the standard UI5 framework functionalities do not fulfill all your requiremen
77

88
The idea is to send the custom JavaScript function along with the view to the frontend and invoke it later when an event is triggered.
99

10-
Below is a working example that you can use as a starting point:
10+
Below is a working example that you can use as a starting point. The `_generic` method creates an arbitrary XML/HTML element — here an HTML `<script>` tag (namespace `html`). The `_cc_plain_xml` method injects raw content into that element, in this case the JavaScript function definition. On the backend side, `client->follow_up_action` then executes the function by name on the frontend:
1111

1212
```abap
1313
METHOD z2ui5_if_app~main.
1414
1515
IF client->check_on_init( ).
1616
DATA(view) = z2ui5_cl_xml_view=>factory( ).
17-
view->_generic( name = `script` ns = `html`
17+
view->_generic( name = `script` ns = `html`
1818
)->_cc_plain_xml(
1919
|function myFunction() \{ console.log( `Hello World` ); \}|
2020
).

docs/advanced/extensibility/user_exits.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22

33
abap2UI5 contains predefined user exits which can be used to modify the standard behavior. The user exits are exposed by the interface [`Z2UI5_IF_EXIT`](https://github.com/abap2UI5/abap2UI5/blob/main/src/02/z2ui5_if_exit.intf.abap). To use them in your system you have to create a new class which implements the interface and its methods. They're called dynamically by abap2UI5 class [`Z2UI5_CL_EXIT`](https://github.com/abap2UI5/abap2UI5/blob/main/src/02/z2ui5_cl_exit.clas.abap). You should **not** include your class into abap2UI5 packages but in any other custom package.
44

5-
The following example changes the title, theme and the time drafts are saved in the backend:
5+
The interface provides two exit methods:
6+
* **`set_config_http_get`** — called during the initial HTTP GET request (page load). Use it to customize frontend settings like the page title, UI5 theme, or UI5 version.
7+
* **`set_config_http_post`** — called on every subsequent HTTP POST request (each roundtrip). Use it to configure backend behavior like the draft expiration time.
8+
9+
Both methods receive a `cs_config` changing parameter whose fields you can set as needed. The following example changes the title, theme and the time drafts are saved in the backend:
610

711
```abap
812
CLASS zcl_a2ui5_user_exit DEFINITION PUBLIC.

docs/advanced/fiori.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ sap.ui.core.Component.create({
6565
```
6666

6767
5. Create abap2UI5 app class
68+
69+
On the ABAP side, the app receives the Fiori startup parameters (such as the app class name and any custom key-value pairs) via `client->get( )-t_comp_params`. The `check_initialized` flag ensures the parameters are only read once on the first roundtrip. Setting `backgrounddesign = 'List'` gives the page a white background that blends in with the Fiori object page:
6870
```abap
6971
METHOD z2ui5_if_app~main.
7072

docs/configuration/authorization.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ abap2UI5 offers flexible ways to manage authorization handling. It doesn't inclu
99
One of the easiest ways to manage access to different apps is by implementing checks within the HTTP handler. This approach lets you restrict access to individual apps based on the APP_START parameter, directly in the ICF service handler class.
1010

1111
##### Example: Restricting Access Based on URL Parameters
12-
In this example, we use the ICF handler class to control which apps can be accessed based on the APP_START parameter in the HTTP request. If an unauthorized app is requested, access is denied.
12+
In this example, we use the ICF handler class to control which apps can be accessed based on the APP_START parameter in the HTTP request. The `get_header_field( 'APP_START' )` method reads the URL query parameter that specifies which abap2UI5 app class to launch. If an unauthorized app is requested, access is denied.
1313
```abap
1414
CLASS z2ui5_cl_launchpad_handler DEFINITION PUBLIC.
1515
@@ -36,7 +36,7 @@ CLASS z2ui5_cl_launchpad_handler IMPLEMENTATION.
3636
ENDCLASS.
3737
```
3838
##### Example: Authorization Objects in Service Handlers
39-
You can also use the SAP authorization objects:
39+
You can also combine this with SAP authorization objects. The example below uses a custom authorization object `Z_APP_AUTH` with a field `APP` — you need to create this object in transaction `SU21` and assign it to the relevant roles in your system:
4040
```abap
4141
CLASS z2ui5_cl_launchpad_handler DEFINITION PUBLIC.
4242
@@ -85,8 +85,8 @@ CLASS z2ui5_cl_app IMPLEMENTATION.
8585
8686
METHOD z2ui5_if_app~main.
8787
" Perform an authorization check before launching the app
88-
AUTHORITY-CHECK OBJECT 'Z_APP_AUTH'
89-
ID 'APP' FIELD 'Z2UI5_APP_001'.
88+
AUTHORITY-CHECK OBJECT `Z_APP_AUTH`
89+
ID `APP` FIELD `Z2UI5_APP_001`.
9090
9191
IF sy-subrc <> 0.
9292
" Authorization failed, deny access

docs/configuration/btp.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,12 @@ Integrate your abap2UI5 apps into BTP Services like Build Workzone. Find all inf
2424

2525
##### Additional Properties
2626

27-
* HTML5.DynamicDestination true
28-
* product.name ABAP System
29-
* sap-client (client)
30-
* WebIDEEnabled true
31-
* WebIDEUsage odata_abap,dev_abap
27+
These properties are required by SAP Build Work Zone to correctly route requests to your ABAP backend:
28+
29+
| Property | Value | Description |
30+
|---|---|---|
31+
| HTML5.DynamicDestination | `true` | Allows HTML5 apps to resolve this destination at runtime |
32+
| product.name | `ABAP System` | Identifies the backend type for the Work Zone tile configuration |
33+
| sap-client | *(your client number)* | The SAP system client to connect to (e.g. `001`) |
34+
| WebIDEEnabled | `true` | Enables the destination for SAP Business Application Studio |
35+
| WebIDEUsage | `odata_abap,dev_abap` | Declares supported protocols for development tools |

docs/configuration/launchpad.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ Sometimes, installation via abapGit can cause cache-related issues. Here's how t
2525
#### Cache Management
2626

2727
1. Recalculate app index of z2ui5 with report /UI5/APP_INDEX_CALCULATE
28-
![389816897-f18e791e-1e07-4381-a8a8-deb5af3ec02c](https://github.com/user-attachments/assets/50c505ab-c58e-46a6-999e-67c4e4cdb929)
29-
![389816886-093d087f-4d7d-48b3-b7c4-75c16046af5b](https://github.com/user-attachments/assets/81f8feae-fcfe-4175-aa91-28ce8d681539)
28+
![App index calculation report selection screen](https://github.com/user-attachments/assets/50c505ab-c58e-46a6-999e-67c4e4cdb929)
29+
![App index calculation report output](https://github.com/user-attachments/assets/81f8feae-fcfe-4175-aa91-28ce8d681539)
3030

3131
2. Recalculate index of distribution layer with report /UI5/APP_INDEX_CALCULATE (if tab isn't visible try switching to another tab, then it usually appears)
32-
![389817086-2a480005-f9f9-46e8-a432-456494957665](https://github.com/user-attachments/assets/3fce0f2e-96f9-4487-9226-7940336582b1)
33-
![389817130-389f2be1-d75b-4dbb-aa81-e5b5e4202440](https://github.com/user-attachments/assets/dc149874-6731-496d-90bf-79cb83d8c97d)
32+
![Distribution layer tab in app index calculation report](https://github.com/user-attachments/assets/3fce0f2e-96f9-4487-9226-7940336582b1)
33+
![Distribution layer recalculation output](https://github.com/user-attachments/assets/dc149874-6731-496d-90bf-79cb83d8c97d)
3434

3535
3. Invalidate http caches in transaction SMICM
36-
![389817432-f6568b5e-0588-4a98-83cc-f1bd58e0dd64](https://github.com/user-attachments/assets/497b7677-8009-472e-9b50-34719105a12e)
36+
![HTTP cache invalidation in transaction SMICM](https://github.com/user-attachments/assets/497b7677-8009-472e-9b50-34719105a12e)
3737

3838
4. Clear browser caches and hard reload
3939

@@ -59,7 +59,9 @@ Find more information in the blog article on [LinkedIn.](https://www.linkedin.co
5959
<br>
6060

6161
#### Approach
62-
(1/3) Use a single Interface:
62+
The integration works in three steps: you implement a simple interface, the Launchpad calls a generic OData proxy service, and the proxy delegates to your ABAP class to calculate the KPI count.
63+
64+
(1/3) Implement the `z2ui5_if_lp_kpi` interface. The `count` method receives an optional `filter` string (from the OData `$filter` parameter) and returns the KPI value as an integer:
6365
```abap
6466
INTERFACE z2ui5_if_lp_kpi
6567
PUBLIC.
@@ -72,7 +74,7 @@ INTERFACE z2ui5_if_lp_kpi
7274
7375
ENDINTERFACE.
7476
```
75-
(2/3) Which can be used on app level to return KPIs:
77+
(2/3) Implement the interface in your app class alongside `z2ui5_if_app`. The `count` method contains your custom KPI calculation logic (e.g. counting open items from the database):
7678
```abap
7779
CLASS z2ui5_cl_lp_kpi_hello_world DEFINITION PUBLIC.
7880
@@ -95,7 +97,7 @@ CLASS z2ui5_cl_lp_kpi_hello_world IMPLEMENTATION.
9597
9698
ENDCLASS.
9799
```
98-
(3/3) A generic OData service takes care of everything else (which just returns n dummy entries). Just maintain the KPI at the Launchpad with the following endpoint:
100+
(3/3) A generic OData proxy service (`Z2UI5_PROXY_KPI_SRV`) handles the rest. It receives the `$filter` parameter containing your class name, instantiates the class, calls `count`, and returns that many dummy OData entries. The Launchpad displays the `$count` result as the tile KPI. Configure the tile with this endpoint:
99101
```
100-
.../sap/opu/odata/sap/Z2UI5_PROXY_KPI_SRV/ENTITYCollection/$count?$filter=CLASS eq 'z2ui5_cl_proxy_kpi_hello_world'
102+
.../sap/opu/odata/sap/Z2UI5_PROXY_KPI_SRV/ENTITYCollection/$count?$filter=CLASS eq 'z2ui5_cl_lp_kpi_hello_world'
101103
```

docs/configuration/performance.md

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,38 @@ Frontend logic is kept to a minimum: no business logic runs in the browser. Ever
1010

1111
abap2UI5 has been successfully tested with tables containing large numbers of entries and columns. So, you can confidently develop your app — performance shouldn't be a concern.
1212

13+
### view_display vs view_model_update
14+
15+
The most impactful optimization is choosing the right update method:
16+
17+
- **`client->view_display( )`** — sends a new XML view and model to the frontend. UI5 destroys the current view and creates a new one from scratch. Use this only on initialization or when the view structure changes.
18+
- **`client->view_model_update( )`** — sends only updated model data. UI5 refreshes the existing view via data binding — only the changed controls are re-rendered. This preserves UI state (scroll position, focus, etc.) and is significantly faster.
19+
20+
```abap
21+
METHOD z2ui5_if_app~main.
22+
23+
CASE abap_true.
24+
25+
WHEN client->check_on_init( ).
26+
DATA(view) = z2ui5_cl_xml_view=>factory(
27+
)->page( `My App`
28+
)->text( client->_bind( mv_text )
29+
)->button( text = `update` press = client->_event( `UPDATE` ) ).
30+
client->view_display( view->stringify( ) ).
31+
32+
WHEN client->check_on_event( `UPDATE` ).
33+
mv_text = `new value`.
34+
client->view_model_update( ).
35+
36+
ENDCASE.
37+
38+
ENDMETHOD.
39+
```
40+
1341
### Suggestions
1442
Want to optimize your app even more? Here are a few tips:
15-
* Only call the `client->view_display` method when necessary. Instead, prefer using `client->model_update` so the UI5 framework only re-renders the controls that have actually changed
16-
* Prefer using `client->bind` and use `client->bind_edit` only when users need to make changes that are processed in the backend. Otherwise, it leads to unnecessary data transfers
43+
* Only call `client->view_display` when necessary. Prefer `client->view_model_update` so the UI5 framework only re-renders controls that have actually changed
44+
* Prefer `client->_bind` and use `client->_bind_edit` only when users need to make changes that are processed in the backend. Otherwise, it leads to unnecessary data transfers
1745
* Declare public attributes in your app class only for variables displayed in the frontend. This helps prevent the framework from accessing unused values
1846
* Follow standard ABAP best practices, such as reducing loops and using sorted tables, as you would in any other ABAP development project
1947

docs/configuration/productive_usage.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ The project will be continuously further developed, so there's no specific "stab
1818

1919
#### Transport
2020
Install the project using abapGit into your development system. Then, use the normal transport process for deployment to production:
21-
![alt text](image-3.png){ width=80% }
21+
![Transport process from development to production via abapGit](image-3.png){ width=80% }
2222

2323
#### Renaming
2424
If you're starting new development but already have abap2UI5 apps running in production, and you're worried about updating to the latest release, consider installing abap2UI5 multiple times in your system using the [renaming feature](/advanced/renaming). This way, you can safely continue development without affecting your existing apps in production.

docs/configuration/troubleshooting.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ On the frontend, abap2UI5 behaves like a standard UI5 app, so you can use all ty
1313

1414
##### Debugging Tools
1515
To begin, press `Ctrl+F12` to open the built-in debugger tools in abap2UI5
16-
![alt text](debug.png)
16+
![Built-in debugger showing XML View and Data Model inspection](debug.png)
1717
Here, you can inspect the XML View and check the Data Model bound to the view.
1818

1919
##### UI5 Inspector

docs/development/events.md

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -22,69 +22,76 @@ METHOD z2ui5_if_app~main.
2222
2323
CASE client->get( )-event.
2424
WHEN `BUTTON_POST`.
25-
client->message_box_display( |Your name is { name }| ).
25+
client->message_box_display( `The button was pressed` ).
2626
ENDCASE.
2727
2828
ENDMETHOD.
2929
```
30-
If the backend needs additional information about the specific event, use parameters like `$event`, `$source`, and `$params` to send further details. Use the t_arg parameter to include these details. Check out [this documentation](https://openui5.hana.ondemand.com/#/topic/b0fb4de7364f4bcbb053a99aa645affe) for more information, and refer to sample `Z2UI5_CL_DEMO_APP_167`.
30+
If the backend needs additional information about the specific event, use the `t_arg` parameter to include additional details. Three special prefixes are available:
31+
32+
- **`$source`** — the UI5 control that triggered the event (e.g. `${$source>/text}` returns the button text)
33+
- **`$parameters`** — the event parameters as defined by the UI5 control (e.g. `${$parameters>/id}` returns the element ID)
34+
- **`$event`** — the UI5 event object itself (e.g. `$event>sId` returns the event type like `press`)
35+
36+
Check out [this documentation](https://openui5.hana.ondemand.com/#/topic/b0fb4de7364f4bcbb053a99aa645affe) for more information, and refer to sample `Z2UI5_CL_DEMO_APP_167`.
3137

3238
#### Source
33-
Send properties of the event source control to the backend:
39+
Send properties of the event source control to the backend. The syntax `${$source>/text}` reads the `text` property from the UI5 control that fired the event — here the button itself, so the result is the button's label (`post`):
3440
```abap
3541
METHOD z2ui5_if_app~main.
3642
3743
client->view_display( z2ui5_cl_xml_view=>factory(
38-
)->button( text = `post` press = client->_event(
39-
val = `BUTTON_POST`
40-
t_arg = VALUE #( ( `${$source>/text}` ) ) )
44+
)->button( text = `post` press = client->_event(
45+
val = `BUTTON_POST`
46+
"reads button text → result: "post"
47+
t_arg = VALUE #( ( `${$source>/text}` ) ) )
4148
)->stringify( ) ).
42-
49+
4350
CASE client->get( )-event.
4451
WHEN `BUTTON_POST`.
4552
client->message_box_display( |The button text is { client->get_event_arg( ) }| ).
4653
ENDCASE.
47-
54+
4855
ENDMETHOD.
4956
```
5057

5158
#### Parameters
52-
Retrieve parameters of the event:
59+
Retrieve parameters of the event. The syntax `${$parameters>/id}` reads the `id` parameter from the event's parameter map — UI5 generates a qualified ID like `mainView--button_id`:
5360
```abap
5461
METHOD z2ui5_if_app~main.
5562
5663
client->view_display( z2ui5_cl_xml_view=>factory(
57-
)->button( text = `post` id = `button_id` press = client->_event(
58-
val = `BUTTON_POST`
59-
t_arg = VALUE #( ( `${$parameters>/id}` ) ) )
64+
)->button( text = `post` id = `button_id` press = client->_event(
65+
val = `BUTTON_POST`
66+
"reads event parameter 'id' → result: "mainView--button_id"
67+
t_arg = VALUE #( ( `${$parameters>/id}` ) ) )
6068
)->stringify( ) ).
61-
69+
6270
CASE client->get( )-event.
6371
WHEN `BUTTON_POST`.
64-
"mainView--button_id
6572
client->message_box_display( |The button id is { client->get_event_arg( ) }| ).
6673
ENDCASE.
67-
74+
6875
ENDMETHOD.
6976
```
7077

7178
#### Event
72-
Retrieve specific properties of the event:
79+
Retrieve specific properties of the event object. The syntax `$event>sId` accesses the `sId` attribute of the UI5 event — here it returns the event type name (`press`). Note: no `${...}` wrapper here because `$event` directly references the event object:
7380
```abap
7481
METHOD z2ui5_if_app~main.
7582
7683
client->view_display( z2ui5_cl_xml_view=>factory(
77-
)->button( text = `post` press = client->_event(
78-
val = `BUTTON_POST`
79-
t_arg = VALUE #( ( `$event>sId` ) ) )
84+
)->button( text = `post` press = client->_event(
85+
val = `BUTTON_POST`
86+
"reads event object attribute → result: "press"
87+
t_arg = VALUE #( ( `$event>sId` ) ) )
8088
)->stringify( ) ).
81-
89+
8290
CASE client->get( )-event.
8391
WHEN `BUTTON_POST`.
84-
"press
8592
client->message_box_display( |The event id is { client->get_event_arg( ) }| ).
8693
ENDCASE.
87-
94+
8895
ENDMETHOD.
8996
```
9097
::: warning
@@ -127,7 +134,14 @@ This is just a demonstration. In this case, it would be easier to access `name`
127134
:::
128135

129136
### Frontend
130-
If you don't want to process the event in the backend, you can also directly trigger actions at the frontend. The following frontend events are available:
137+
If you don't want to process the event in the backend, you can directly trigger actions at the frontend using `client->_event_client`. The difference between the two methods:
138+
139+
- **`client->_event( )`** — triggers a backend roundtrip, the event is processed in the `main` method
140+
- **`client->_event_client( )`** — executes an action directly in the browser, no backend call
141+
142+
To use a frontend event on a UI5 control property (like `press`), wrap `_event_client` inside `_event`. To execute a frontend event after backend processing, pass `_event_client` to `client->follow_up_action`.
143+
144+
The following frontend events are available:
131145
```abap
132146
CONSTANTS:
133147
BEGIN OF cs_event,

0 commit comments

Comments
 (0)