Skip to content

Commit fcd87a7

Browse files
committed
Fix 7 misleading code patterns across documentation
- events.md: remove reference to unbound variable 'name' in message - messages.md: remove incorrect IF sy-subrc check for BAPI return table - tables.md: add check_on_init() guard to prevent table growing on each roundtrip - tables.md: change text() to input() in editable table cells so editing actually works - expression_binding.md: bind product variable with _bind_edit() instead of static assignment - cds.md: add check_on_init() guard around SELECT and READ ENTITIES - cloud.md: add check_on_init() guard around both SELECT examples - dx.md: add check_on_event('POST') guard around message_box_display https://claude.ai/code/session_01AaA4EMw83KMzGP6kaDZPJU
1 parent 996c247 commit fcd87a7

7 files changed

Lines changed: 125 additions & 101 deletions

File tree

docs/development/events.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ 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.

docs/development/messages.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,7 @@ METHOD z2ui5_if_app~main.
6363
username = sy-uname
6464
TABLES
6565
return = lt_bapiret.
66-
IF sy-subrc <> 0.
67-
client->message_box_display( lt_bapiret ).
68-
ENDIF.
66+
client->message_box_display( lt_bapiret ).
6967
7068
ENDMETHOD.
7169
```

docs/development/model/expression_binding.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ CLASS z2ui5_cl_demo_editable IMPLEMENTATION.
5656
` path:"` && client->_bind( val = quantity
5757
path = abap_true ) && `" }`
5858
)->input(
59-
value = product
59+
value = client->_bind_edit( product )
6060
enabled = `{= 500===$` && client->_bind( quantity ) && ` }` ).
6161
client->view_display( view->stringify( ) ).
6262

docs/development/model/tables.md

Lines changed: 48 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,30 @@ ENDCLASS.
2020
2121
CLASS z2ui5_cl_sample_tab IMPLEMENTATION.
2222
METHOD z2ui5_if_app~main.
23-
24-
DO 100 TIMES.
25-
INSERT VALUE #(
26-
count = sy-index
27-
value = `red`
28-
descr = `this is a description` ) INTO TABLE mt_itab.
29-
ENDDO.
30-
31-
DATA(tab) = z2ui5_cl_xml_view=>factory( )->page(
32-
)->table( client->_bind( mt_itab ) ).
33-
tab->columns(
34-
)->column( )->text( `Counter` )->get_parent(
35-
)->column( )->text( `Value` )->get_parent(
36-
)->column( )->text( `Description` ).
37-
tab->items( )->column_list_item( )->cells(
38-
)->text( `{COUNT}`
39-
)->text( `{VALUE}`
40-
)->text( `{DESCR}` ).
41-
client->view_display( tab->stringify( ) ).
42-
23+
24+
IF client->check_on_init( ).
25+
26+
DO 100 TIMES.
27+
INSERT VALUE #(
28+
count = sy-index
29+
value = `red`
30+
descr = `this is a description` ) INTO TABLE mt_itab.
31+
ENDDO.
32+
33+
DATA(tab) = z2ui5_cl_xml_view=>factory( )->page(
34+
)->table( client->_bind( mt_itab ) ).
35+
tab->columns(
36+
)->column( )->text( `Counter` )->get_parent(
37+
)->column( )->text( `Value` )->get_parent(
38+
)->column( )->text( `Description` ).
39+
tab->items( )->column_list_item( )->cells(
40+
)->text( `{COUNT}`
41+
)->text( `{VALUE}`
42+
)->text( `{DESCR}` ).
43+
client->view_display( tab->stringify( ) ).
44+
45+
ENDIF.
46+
4347
ENDMETHOD.
4448
ENDCLASS.
4549
```
@@ -48,26 +52,30 @@ ENDCLASS.
4852
Making a table editable is a simple change. You just need to switch the binding mode to `bind_edit` :
4953
```abap
5054
METHOD z2ui5_if_app~main.
51-
52-
DO 100 TIMES.
53-
INSERT VALUE #(
54-
count = sy-index
55-
value = `red`
56-
descr = `this is a description` ) INTO TABLE mt_itab.
57-
ENDDO.
58-
59-
DATA(tab) = z2ui5_cl_xml_view=>factory( )->page(
60-
)->table( client->_bind_edit( mt_itab ) ).
61-
tab->columns(
62-
)->column( )->text( `Count` )->get_parent(
63-
)->column( )->text( `Value` )->get_parent(
64-
)->column( )->text( `Description` ).
65-
tab->items( )->column_list_item( )->cells(
66-
)->text( `{COUNT}`
67-
)->text( `{VALUE}`
68-
)->text( `{DESCR}` ).
69-
client->view_display( tab->stringify( ) ).
70-
55+
56+
IF client->check_on_init( ).
57+
58+
DO 100 TIMES.
59+
INSERT VALUE #(
60+
count = sy-index
61+
value = `red`
62+
descr = `this is a description` ) INTO TABLE mt_itab.
63+
ENDDO.
64+
65+
DATA(tab) = z2ui5_cl_xml_view=>factory( )->page(
66+
)->table( client->_bind_edit( mt_itab ) ).
67+
tab->columns(
68+
)->column( )->text( `Count` )->get_parent(
69+
)->column( )->text( `Value` )->get_parent(
70+
)->column( )->text( `Description` ).
71+
tab->items( )->column_list_item( )->cells(
72+
)->input( `{COUNT}`
73+
)->input( `{VALUE}`
74+
)->input( `{DESCR}` ).
75+
client->view_display( tab->stringify( ) ).
76+
77+
ENDIF.
78+
7179
ENDMETHOD.
7280
```
7381

docs/development/specific/cds.md

Lines changed: 42 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,28 @@ ENDCLASS.
1919
CLASS z2ui5_cl_sample_cds IMPLEMENTATION.
2020
METHOD z2ui5_if_app~main.
2121
22-
SELECT FROM I_SalesOrder
23-
FIELDS salesorder, salesordertype, salesorganization
24-
INTO TABLE @mt_salesorder
25-
UP TO 10 ROWS.
22+
IF client->check_on_init( ).
2623
27-
DATA(view) = z2ui5_cl_xml_view=>factory( )->page( ).
28-
DATA(table) = view->table( client->_bind( mt_salesorder ) ).
29-
table->columns(
30-
)->column( )->text( `SalesOrder` )->get_parent(
31-
)->column( )->text( `SalesOrderType` )->get_parent(
32-
)->column( )->text( `SalesOrganization` ).
24+
SELECT FROM I_SalesOrder
25+
FIELDS salesorder, salesordertype, salesorganization
26+
INTO TABLE @mt_salesorder
27+
UP TO 10 ROWS.
3328
34-
table->items( )->column_list_item( )->cells(
35-
)->text( `{SALESORDER}`
36-
)->text( `{SALESORDERTYPE}`
37-
)->text( `{SALESORGANIZATION}` ).
29+
DATA(view) = z2ui5_cl_xml_view=>factory( )->page( ).
30+
DATA(table) = view->table( client->_bind( mt_salesorder ) ).
31+
table->columns(
32+
)->column( )->text( `SalesOrder` )->get_parent(
33+
)->column( )->text( `SalesOrderType` )->get_parent(
34+
)->column( )->text( `SalesOrganization` ).
3835
39-
client->view_display( view->stringify( ) ).
36+
table->items( )->column_list_item( )->cells(
37+
)->text( `{SALESORDER}`
38+
)->text( `{SALESORDERTYPE}`
39+
)->text( `{SALESORGANIZATION}` ).
40+
41+
client->view_display( view->stringify( ) ).
42+
43+
ENDIF.
4044
4145
ENDMETHOD.
4246
ENDCLASS.
@@ -59,25 +63,29 @@ ENDCLASS.
5963
CLASS z2ui5_cl_sample_eml_read IMPLEMENTATION.
6064
METHOD z2ui5_if_app~main.
6165
62-
READ ENTITIES OF I_SalesOrderTP
63-
ENTITY SalesOrder
64-
ALL FIELDS WITH
65-
VALUE #( ( SalesOrder = `0000000001` ) )
66-
RESULT mt_salesorder.
67-
68-
DATA(view) = z2ui5_cl_xml_view=>factory( )->page( ).
69-
DATA(table) = view->table( client->_bind( mt_salesorder ) ).
70-
table->columns(
71-
)->column( )->text( `SalesOrder` )->get_parent(
72-
)->column( )->text( `SalesOrderType` )->get_parent(
73-
)->column( )->text( `SalesOrganization` ).
74-
75-
table->items( )->column_list_item( )->cells(
76-
)->text( `{SALESORDER}`
77-
)->text( `{SALESORDERTYPE}`
78-
)->text( `{SALESORGANIZATION}` ).
79-
80-
client->view_display( view->stringify( ) ).
66+
IF client->check_on_init( ).
67+
68+
READ ENTITIES OF I_SalesOrderTP
69+
ENTITY SalesOrder
70+
ALL FIELDS WITH
71+
VALUE #( ( SalesOrder = `0000000001` ) )
72+
RESULT mt_salesorder.
73+
74+
DATA(view) = z2ui5_cl_xml_view=>factory( )->page( ).
75+
DATA(table) = view->table( client->_bind( mt_salesorder ) ).
76+
table->columns(
77+
)->column( )->text( `SalesOrder` )->get_parent(
78+
)->column( )->text( `SalesOrderType` )->get_parent(
79+
)->column( )->text( `SalesOrganization` ).
80+
81+
table->items( )->column_list_item( )->cells(
82+
)->text( `{SALESORDER}`
83+
)->text( `{SALESORDERTYPE}`
84+
)->text( `{SALESORGANIZATION}` ).
85+
86+
client->view_display( view->stringify( ) ).
87+
88+
ENDIF.
8189
8290
ENDMETHOD.
8391
ENDCLASS.

docs/technical/cloud.md

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,21 @@ CLASS z2ui5_cl_demo_app_003 IMPLEMENTATION.
4949
5050
METHOD z2ui5_if_app~main.
5151
52-
SELECT FROM I_SalesOrder
53-
FIELDS salesorder, salesorganization
54-
INTO TABLE @mt_salesorder
55-
UP TO 10 ROWS.
52+
IF client->check_on_init( ).
5653
57-
DATA(view) = z2ui5_cl_xml_view=>factory(
58-
)->list( client->_bind_edit( mt_salesorder )
59-
)->standard_list_item(
60-
title = `{SALESORDER}`
61-
description = `{SALESORGANIZATION}` ).
62-
client->view_display( view->stringify( ) ).
54+
SELECT FROM I_SalesOrder
55+
FIELDS salesorder, salesorganization
56+
INTO TABLE @mt_salesorder
57+
UP TO 10 ROWS.
58+
59+
DATA(view) = z2ui5_cl_xml_view=>factory(
60+
)->list( client->_bind_edit( mt_salesorder )
61+
)->standard_list_item(
62+
title = `{SALESORDER}`
63+
description = `{SALESORGANIZATION}` ).
64+
client->view_display( view->stringify( ) ).
65+
66+
ENDIF.
6367
6468
ENDMETHOD.
6569
ENDCLASS.
@@ -79,17 +83,21 @@ CLASS z2ui5_cl_demo_app_003 IMPLEMENTATION.
7983
8084
METHOD z2ui5_if_app~main.
8185
82-
SELECT FROM vbak
83-
FIELDS vbeln, vkorg
84-
INTO TABLE @mt_salesorder
85-
UP TO 10 ROWS.
86-
87-
DATA(view) = z2ui5_cl_xml_view=>factory(
88-
)->list( client->_bind_edit( mt_salesorder )
89-
)->standard_list_item(
90-
title = `{VBELN}`
91-
description = `{VKORG}` ).
92-
client->view_display( view->stringify( ) ).
86+
IF client->check_on_init( ).
87+
88+
SELECT FROM vbak
89+
FIELDS vbeln, vkorg
90+
INTO TABLE @mt_salesorder
91+
UP TO 10 ROWS.
92+
93+
DATA(view) = z2ui5_cl_xml_view=>factory(
94+
)->list( client->_bind_edit( mt_salesorder )
95+
)->standard_list_item(
96+
title = `{VBELN}`
97+
description = `{VKORG}` ).
98+
client->view_display( view->stringify( ) ).
99+
100+
ENDIF.
93101
94102
ENDMETHOD.
95103
ENDCLASS.

docs/technical/dx.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ CLASS zcl_app_input IMPLEMENTATION.
7575
RETURN.
7676
ENDIF.
7777
78-
client->message_box_display( |Input: { pa_arbgb }| ).
78+
IF client->check_on_event( `POST` ).
79+
client->message_box_display( |Input: { pa_arbgb }| ).
80+
ENDIF.
7981
8082
ENDMETHOD.
8183
ENDCLASS.

0 commit comments

Comments
 (0)