|
1 | 1 | # Logging |
2 | 2 |
|
3 | | -## Use Cases |
| 3 | +<i class="fa-brands fa-github"></i> [GitHub](https://github.com/abap2UI5-addons/logging) |
4 | 4 |
|
5 | | -### 1. UI for abap-logger |
| 5 | +ABAP development is nearly impossible without eventually encountering BAL logging. Whether you like using the standard API or prefer working with open-source projects like abap-logger, in the end, we need a way to display these messages in an abap2UI5 app or a popup. This add-on collects all functionality related to BAL logging. Instead of building various new BAL popups, we can gather the functionality here and develop it collaboratively. Currently, only basic functionality is available, but PRs are welcome! |
6 | 6 |
|
7 | | -UI for the Open Source Project [**abap-logger**](https://github.com/ABAP-Logger/ABAP-Logger) |
| 7 | +### 1. UI for Business Application Log (classic) |
8 | 8 |
|
9 | 9 | ```abap |
10 | | -CLASS z2ui5add_cl_abap_logger_sample DEFINITION PUBLIC FINAL |
11 | | - CREATE PUBLIC . |
| 10 | + METHOD z2ui5_if_app~main. |
12 | 11 |
|
13 | | - PUBLIC SECTION. |
14 | | - INTERFACES z2ui5_if_app. |
| 12 | + DATA(lo_log) = cl_bali_log=>create( ). |
15 | 13 |
|
16 | | -ENDCLASS. |
| 14 | + DATA(lo_msg) = cl_bali_message_setter=>create( |
| 15 | + severity = if_bali_constants=>c_severity_status |
| 16 | + id = 'DEMO_LOG' |
| 17 | + number = '002' |
| 18 | + variable_1 = CONV #( cl_abap_context_info=>get_user_business_partner_id( ) ) ). |
| 19 | + lo_log->add_item( lo_msg ). |
17 | 20 |
|
18 | | -CLASS z2ui5add_cl_abap_logger_sample IMPLEMENTATION. |
| 21 | + " BAPIRET2 |
| 22 | + DATA(lo_bapi) = cl_bali_message_setter=>create_from_bapiret2( VALUE #( type = 'E' |
| 23 | + id = 'DEMO_LOG' |
| 24 | + number = '002' |
| 25 | + message_v1 = 'Dummy' ) ). |
| 26 | + lo_log->add_item( lo_bapi ). |
| 27 | +
|
| 28 | + client->nav_app_call( z2ui5add_cl_bal_cl=>factory_popup( lo_log ) ). |
19 | 29 |
|
| 30 | + ENDMETHOD. |
| 31 | +``` |
| 32 | + |
| 33 | +### 2. UI for Business Application Log (cloud) |
| 34 | + |
| 35 | +```abap |
20 | 36 | METHOD z2ui5_if_app~main. |
21 | 37 |
|
22 | | - DATA: log TYPE REF TO zif_logger. |
23 | | - log = zcl_logger_factory=>create_log( object = 'ZINTERFACES' |
24 | | - subobject = 'ACCOUNTING' |
25 | | - desc = 'Stuff imported from legacy systems' ). |
| 38 | + DATA(lo_log) = cl_bali_log=>create( ). |
26 | 39 |
|
27 | | - log->e( 'You see, what had happened was...' ). |
| 40 | + DATA(lo_msg) = cl_bali_message_setter=>create( |
| 41 | + severity = if_bali_constants=>c_severity_status |
| 42 | + id = 'DEMO_LOG' |
| 43 | + number = '002' |
| 44 | + variable_1 = CONV #( cl_abap_context_info=>get_user_business_partner_id( ) ) ). |
| 45 | + lo_log->add_item( lo_msg ). |
28 | 46 |
|
29 | | - client->nav_app_call( z2ui5add_cl_abap_logger_ui=>display_popup( log ) ). |
| 47 | + " BAPIRET2 |
| 48 | + DATA(lo_bapi) = cl_bali_message_setter=>create_from_bapiret2( VALUE #( type = 'E' |
| 49 | + id = 'DEMO_LOG' |
| 50 | + number = '002' |
| 51 | + message_v1 = 'Dummy' ) ). |
| 52 | + lo_log->add_item( lo_bapi ). |
| 53 | +
|
| 54 | + client->nav_app_call( z2ui5add_cl_bal_cl=>factory_popup( lo_log ) ). |
30 | 55 |
|
31 | 56 | ENDMETHOD. |
| 57 | +``` |
32 | 58 |
|
33 | | -ENDCLASS. |
| 59 | +### 3. BAL Cockpit |
| 60 | +In ABAP for Cloud |
| 61 | + |
| 62 | +```abap |
| 63 | + METHOD z2ui5_if_app~main. |
| 64 | +
|
| 65 | + DATA(lo_log) = cl_bali_log=>create( ). |
| 66 | +
|
| 67 | + DATA(lo_msg) = cl_bali_message_setter=>create( |
| 68 | + severity = if_bali_constants=>c_severity_status |
| 69 | + id = 'DEMO_LOG' |
| 70 | + number = '002' |
| 71 | + variable_1 = CONV #( cl_abap_context_info=>get_user_business_partner_id( ) ) ). |
| 72 | + lo_log->add_item( lo_msg ). |
| 73 | +
|
| 74 | + " BAPIRET2 |
| 75 | + DATA(lo_bapi) = cl_bali_message_setter=>create_from_bapiret2( VALUE #( type = 'E' |
| 76 | + id = 'DEMO_LOG' |
| 77 | + number = '002' |
| 78 | + message_v1 = 'Dummy' ) ). |
| 79 | + lo_log->add_item( lo_bapi ). |
| 80 | +
|
| 81 | + client->nav_app_call( z2ui5add_cl_bal_cl=>factory_popup( lo_log ) ). |
| 82 | +
|
| 83 | + ENDMETHOD. |
34 | 84 | ``` |
35 | 85 |
|
36 | | -### 2. POPUP for BAL Messages |
| 86 | + |
| 87 | +### 4. UI for abap-logger |
| 88 | + |
| 89 | +UI for the Open Source Project [**abap-logger**](https://github.com/ABAP-Logger/ABAP-Logger) |
37 | 90 |
|
38 | 91 | ```abap |
39 | 92 | CLASS z2ui5add_cl_abap_logger_sample DEFINITION PUBLIC FINAL |
@@ -62,5 +115,3 @@ CLASS z2ui5add_cl_abap_logger_sample IMPLEMENTATION. |
62 | 115 | ENDCLASS. |
63 | 116 | ``` |
64 | 117 |
|
65 | | -<br> |
66 | | -<img width="800" alt="SAPGUI 2024-09-05 08 00 51" src="https://github.com/user-attachments/assets/02c6a23a-e4cc-4439-afa0-7842897c8468"> |
|
0 commit comments