Advertising:

Create application log in cloud development: Difference between revisions

From SAP Knowledge Base
(Created page with "For T1 / cloud developments the familiar function modules(FMs) or classic classes for creating application logs can no loger be used. For this purpose, SAP offers several released classes for cloud development. The object and sub-object should not be created via SLG0, but via Eclipse with ABAP Development Tools. = How to use the classes = == Create new business application log == <syntaxhighlight lang="abap" line copy> TRY. DATA(lo_log) = cl_bali_log=>create( ). CATCH...")
 
No edit summary
Line 7: Line 7:
<syntaxhighlight lang="abap" line copy>
<syntaxhighlight lang="abap" line copy>
TRY.
TRY.
DATA(lo_log) = cl_bali_log=>create( ).
DATA(log) = cl_bali_log=>create( ).
CATCH cx_bali_runtime INTO DATA(lx_runtime_exception).
CATCH cx_bali_runtime INTO DATA(runtime_exception).
ENDTRY.
ENDTRY.
</syntaxhighlight>
== Create header data for application log ==
<syntaxhighlight lang="abap" line copy>
log->set_header( header = cl_bali_header_setter=>create( object = 'YOBJECT'
                                                          subobject = 'YSUBOBJECT'
                                                          external_id = 'Ext ID' ) ).
</syntaxhighlight>
== Nachrichten zum Anwendungsprotokoll hinzufügen ==
<syntaxhighlight lang="abap" line copy>
TRY.
  DATA(message) = cl_bali_message_setter=>create( severity = if_bali_constants=>c_severity_error
                                                    id = 'YMC_ABC'
                                                    number = '000' ).
  log->add_item( item = lo_message ).
 
  log->add_item( item = cl_bali_message_setter=>create_from_sy( ) ).
 
  DATA(free_text) = cl_bali_free_text_setter=>create( severity = if_bali_constants=>c_severity_error
                                                          text = 'Some Error Text' ).
  log->add_item( item = free_text ).
 
  DATA(exception) = cl_bali_exception_setter=>create( severity = if_bali_constants=>c_severity_error
                                                        exception = ref ).
  lo_log->add_item( item = exception ).
  CATCH cx_bali_runtime INTO DATA(runtime_exception).
ENDTRY.
</syntaxhighlight>
</syntaxhighlight>

Revision as of 11:16, 21 December 2024

For T1 / cloud developments the familiar function modules(FMs) or classic classes for creating application logs can no loger be used. For this purpose, SAP offers several released classes for cloud development. The object and sub-object should not be created via SLG0, but via Eclipse with ABAP Development Tools.

How to use the classes

Create new business application log

TRY.
DATA(log) = cl_bali_log=>create( ).
CATCH cx_bali_runtime INTO DATA(runtime_exception).
ENDTRY.

Create header data for application log

 log->set_header( header = cl_bali_header_setter=>create( object = 'YOBJECT'
                                                          subobject = 'YSUBOBJECT'
                                                          external_id = 'Ext ID' ) ).

Nachrichten zum Anwendungsprotokoll hinzufügen

 
 TRY. 
  DATA(message) = cl_bali_message_setter=>create( severity = if_bali_constants=>c_severity_error
                                                     id = 'YMC_ABC'
                                                     number = '000' ).
   log->add_item( item = lo_message ).
  
   log->add_item( item = cl_bali_message_setter=>create_from_sy( ) ).
  
   DATA(free_text) = cl_bali_free_text_setter=>create( severity = if_bali_constants=>c_severity_error
                                                           text = 'Some Error Text' ).
   log->add_item( item = free_text ).
  
   DATA(exception) = cl_bali_exception_setter=>create( severity = if_bali_constants=>c_severity_error
                                                         exception = ref ).
   lo_log->add_item( item = exception ).
  CATCH cx_bali_runtime INTO DATA(runtime_exception).
 ENDTRY.

This is a wiki created in the spare time of a private person working in the SAP ERP area. The aim is to collect knowledge for the own use. The wiki is maintained to the best of knowledge and belief.
All products shown, including in form of screenshots, belong to SAP SE. Their trademarks are, among others: SAP®,ABAP®,SAP Fiori®,SAP HANA®,SAP NetWeaver®,SAP® R/3®,SAP S/4HANA®,SAP S/4HANA® Cloud