You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/development/messages.md
+18-13Lines changed: 18 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@ Displaying messages and errors is an everyday requirement for ABAP developers. T
11
11
For short-duration messages, such as success notifications, you can use the message toast:
12
12
13
13
```abap
14
-
METHOD z2ui5_if_app~main.
14
+
METHOD z2ui5_if_app~main.
15
15
16
16
client->message_toast_display( `this is a message` ).
17
17
@@ -23,7 +23,7 @@ ENDMETHOD.
23
23
Want the user to acknowledge the message? You can display a message box that requires manual closure:
24
24
25
25
```abap
26
-
METHOD z2ui5_if_app~main.
26
+
METHOD z2ui5_if_app~main.
27
27
28
28
client->message_box_display( `this is a message` ).
29
29
@@ -33,7 +33,7 @@ ENDMETHOD.
33
33
For error messages, simply change the type:
34
34
35
35
```abap
36
-
METHOD z2ui5_if_app~main.
36
+
METHOD z2ui5_if_app~main.
37
37
38
38
client->message_box_display(
39
39
text = `This is an error message`
@@ -46,7 +46,7 @@ ENDMETHOD.
46
46
You can directly pass common message structures, objects, and variables to the functions:
47
47
###### SY
48
48
```abap
49
-
METHOD z2ui5_if_app~main.
49
+
METHOD z2ui5_if_app~main.
50
50
51
51
MESSAGE ID `NET` TYPE `I` NUMBER `001` INTO DATA(lv_dummy).
52
52
client->message_box_display( sy ).
@@ -55,7 +55,7 @@ ENDMETHOD.
55
55
```
56
56
###### BAPIRET
57
57
```abap
58
-
METHOD z2ui5_if_app~main.
58
+
METHOD z2ui5_if_app~main.
59
59
60
60
DATA lt_bapiret TYPE STANDARD TABLE OF bapiret2.
61
61
CALL FUNCTION `BAPI_USER_GET_DETAIL`
@@ -71,7 +71,7 @@ ENDMETHOD.
71
71
```
72
72
###### CX_ROOT
73
73
```abap
74
-
METHOD z2ui5_if_app~main.
74
+
METHOD z2ui5_if_app~main.
75
75
76
76
TRY.
77
77
DATA(lv_val) = 1 / 0.
@@ -86,7 +86,7 @@ Other imports are supported as well. Just import your message structure, and the
86
86
#### Popup Multi Message
87
87
The message box provides basic output. For a more detailed output, use the popup `z2ui5_cl_pop_messages`:
88
88
```abap
89
-
METHOD z2ui5_if_app~main.
89
+
METHOD z2ui5_if_app~main.
90
90
91
91
DATA(lt_msg) = VALUE bapirettab(
92
92
( type = `E` id = `MSG1` number = `001` message = `An empty Report field causes an empty XML Message to be sent` )
@@ -99,7 +99,7 @@ ENDMETHOD.
99
99
#### Popup Error
100
100
To show a detailed view of your exception, use the following code:
101
101
```abap
102
-
METHOD z2ui5_if_app~main.
102
+
METHOD z2ui5_if_app~main.
103
103
104
104
TRY.
105
105
DATA(lv_val) = 1 / 0.
@@ -111,22 +111,27 @@ ENDMETHOD.
111
111
```
112
112
113
113
#### Uncaught Errors
114
-
What happens if errors are uncaught? In this case, the default HTTP handler exception output is used. The processing is interrupted, and the user will need to refresh the browser. Use this only for unexpected behavior:
114
+
When you don't catch exceptions in your code, the framework catches them and shows the standard error popup. Try:
115
+
115
116
```abap
116
117
METHOD z2ui5_if_app~main.
117
118
118
-
ASSERT 1 = `This is an error message!`.
119
+
RAISE EXCEPTION NEW cx_sy_itab_line_not_found( ).
119
120
120
121
ENDMETHOD.
121
122
```
122
-
Alternatively, achieve the same behavior with an uncaught exception:
123
+
124
+
#### Uncatchable Exceptions / Short Dumps
125
+
What happens if your code creates uncatchable exceptions? In this case, the default HTTP handler exception output is used. The processing is interrupted, and the user will need to refresh the browser. Use this only for unexpected behavior:
126
+
123
127
```abap
124
-
METHOD z2ui5_if_app~main.
128
+
METHOD z2ui5_if_app~main.
125
129
126
-
RAISE EXCEPTION NEW cx_sy_itab_line_not_found( ).
130
+
ASSERT 1 = `This is an error message!`.
127
131
128
132
ENDMETHOD.
129
133
```
134
+
130
135
::: tip **Improvements**
131
136
These message functions are continually being improved. Feel free to open an issue if you encounter errors or incompatibilities, or submit a PR to extend the functionality.
0 commit comments