Skip to content

Commit 9183b3e

Browse files
authored
Merge pull request #17 from abap2UI5/test
added logging and custom js
2 parents 4ceb866 + b6575d2 commit 9183b3e

File tree

9 files changed

+116
-126
lines changed

9 files changed

+116
-126
lines changed

docs/.vitepress/config.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,10 @@ export default defineConfig({
104104
{ text: 'Barcode Scanning', link: '/development/barcodes' },
105105
{ text: 'File Handling', link: '/development/files', },
106106
{ text: 'XLSX', link: '/development/xlsx', },
107+
{ text: 'Logging', link: '/development/logging' },
107108
{ text: 'Device Capabilities', link: '/development/ndc' },
108109
{ text: 'CDS, EML', link: '/development/cds' },
110+
{ text: 'Custom JS', link: '/development/custom_js' },
109111
]
110112
},
111113
]

docs/addons/logging.md

Lines changed: 0 additions & 120 deletions
This file was deleted.

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](image.png)
16+
![alt text](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/cds.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ CLASS z2ui5_cl_sample_cds DEFINITION
1919
ENDCLASS.
2020
2121
CLASS z2ui5_cl_sample_cds IMPLEMENTATION.
22-
2322
METHOD z2ui5_if_app~main.
2423
2524
SELECT FROM I_SalesOrder
@@ -42,7 +41,6 @@ CLASS z2ui5_cl_sample_cds IMPLEMENTATION.
4241
client->view_display( view->stringify( ) ).
4342
4443
ENDMETHOD.
45-
4644
ENDCLASS.
4745
```
4846

docs/development/custom_js.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
outline: [2, 6]
3+
---
4+
# Custom JS
5+
6+
If the standard UI5 framework functionalities do not fulfill all your requirements, you can define and call your own custom JavaScript functions. For example, this approach is used in the scanner section to play a sound after scanning.
7+
8+
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.
9+
10+
Below is a working example that you can use as a starting point:
11+
12+
```abap
13+
METHOD z2ui5_if_app~main.
14+
15+
IF client->check_on_init( ).
16+
DATA(view) = z2ui5_cl_xml_view=>factory( ).
17+
view->_generic( name = `script` ns = `html`
18+
)->_cc_plain_xml(
19+
|function myFunction() \{ console.log( `Hello World` ); \}|
20+
).
21+
view->page(
22+
)->button( text = `call custom JS`
23+
press = client->_event( 'CUSTOM_JS' ) ).
24+
client->view_display( view->stringify( ) ).
25+
ENDIF.
26+
27+
IF client->get( )-event = 'CUSTOM_JS'.
28+
client->follow_up_action( `myFunction()` ).
29+
ENDIF.
30+
31+
ENDMETHOD.
32+
```

docs/development/general.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ CLASS z2ui5_cl_app IMPLEMENTATION.
2121
RETURN.
2222
ENDIF.
2323
24-
"callback after previous app
24+
"callback after navigation
2525
IF client->check_on_navigated( ).
2626
DATA(lo_app_prev) = client->get_app_prev( ).
2727
"read attributes of previous app
2828
RETURN.
2929
ENDIF.
3030
31-
"handle events
31+
"handle events after frontend
3232
CASE client->get( )-event.
3333
WHEN 'OK'.
3434
data(lt_arg) = client->get_event_arg( ).

docs/development/logging.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
---
2+
outline: [2, 6]
3+
---
4+
# Logging, BAL
5+
6+
Logging is essential for developing end-user business processes. In ABAP systems, the standard tool for this purpose is the Business Application Log (BAL), which is supported in both on-premise systems and ABAP Cloud. With abap2UI5, you can use BAL functions just as you would in classic development. Logs can be displayed in tables or using the predefined popups provided by the framework.
7+
8+
##### BAL Variables
9+
In ABAP classic, you can use the classic BAL function modules and display the BAL table with the popup `z2ui5_cl_pop_messages`:
10+
```abap
11+
METHOD z2ui5_if_app~main.
12+
13+
DATA(lt_bal) = VALUE bal_t_msgr(
14+
( msgid = 'Z001' msgno = '001' msgty = 'S' time_stmp = '21354' msgnumber = '01' )
15+
( msgid = 'Z001' msgno = '001' msgty = 'S' time_stmp = '21354' msgnumber = '02' ) ).
16+
17+
client->nav_app_call( z2ui5_cl_pop_messages=>factory( lt_bal ) ).
18+
19+
ENDMETHOD.
20+
```
21+
22+
##### ABAP Cloud
23+
In ABAP Cloud, you can directly pass the logging object into the popup:
24+
```abap
25+
METHOD z2ui5_if_app~main.
26+
27+
DATA(lo_log) = cl_bali_log=>create( ).
28+
DATA(lo_msg) = cl_bali_message_setter=>create(
29+
severity = if_bali_constants=>c_severity_status
30+
id = 'DEMO_LOG'
31+
number = '002'
32+
variable_1 = `username` ).
33+
lo_log->add_item( lo_msg ).
34+
35+
DATA(lo_bapi) = cl_bali_message_setter=>create_from_bapiret2(
36+
VALUE #(
37+
type = 'E'
38+
id = 'DEMO_LOG'
39+
number = '002'
40+
message_v1 = 'Dummy' ) ).
41+
lo_log->add_item( lo_bapi ).
42+
43+
client->nav_app_call( z2ui5_cl_pop_messages=>factory( lo_log ) ).
44+
45+
ENDMETHOD.
46+
```
47+
48+
##### abap-logger
49+
In on-premise systems, you also have the option to use the fantastic open-source project [**abap-logger**](https://github.com/ABAP-Logger/ABAP-Logger). This tool simplifies working with BAL logs and integrates seamlessly with abap2UI5. Here’s an example:
50+
```abap
51+
METHOD z2ui5_if_app~main.
52+
53+
DATA(log) = zcl_logger_factory=>create_log( desc = 'ABAP Logger' ).
54+
log->e( 'This is an error...' ).
55+
log->s( 'This is a success message...' ).
56+
57+
client->nav_app_call( z2ui5_cl_pop_messages=>factory( log ) ).
58+
59+
ENDMETHOD.
60+
```
61+
62+
##### BAL Popup
63+
Compared to message classes, BAL logs include more detailed information, such as timestamps. You can also use the specific BAL log popup to display this information. All the examples above can be used with the `z2ui5_cl_pop_bal` popup instead. Here’s an example using the abap-logger:
64+
65+
```abap
66+
METHOD z2ui5_if_app~main.
67+
68+
DATA(lo_log) = zcl_logger_factory=>create_log( desc = 'ABAP Logger' ).
69+
log->e( 'This is an error...' ).
70+
71+
client->nav_app_call( z2ui5_cl_pop_bal=>factory( lo_log ) ).
72+
73+
ENDMETHOD.
74+
```
75+
76+
::: tip
77+
This popup is still in its early stages and offers basic functionality. If you’ve implemented BAL features with abap2UI5, consider contributing to extend its capabilities. Contributions are always welcome!
78+
:::

docs/development/xlsx.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ ENDCLASS.
175175
:::
176176

177177
::: tip **ABAP Cloud**
178-
The snippets provided above are not compatible with ABAP Cloud. To make them compatible, replace the code in the lcl_help class with functions from the new XCO_CP_XLSX APIs.
178+
The code snippets above are not compatible with ABAP Cloud, modify the lcl_help class by replacing its code with functions from the new XCO_CP_XLSX APIs to ensure compatibility.
179179
:::
180180

181181
#### abap2xlsx

0 commit comments

Comments
 (0)