Technical Articles
Create Application Logs and attach it to Application Job in ABAP Cloud
In your Fiori Launchpad search for application :- Application Logs
Key Features
You can use this reuse library to:
- view application log details
- filter the logs by severity
- search for message texts
- display the message details
Steps Involved:-
- Create Application log Object, Subobject and External reference in ADT.
- Create Job Catalog entry.
- Create Application Job template.
- Writing code in job template class using provided interfaces- IF_APJ_DT_EXEC_OBJECT, IF_APJ_RT_EXEC_OBJECT.
- Writing code for Application Logs
- Execute Job.
Details:
Log Object, SubObject in ADT.
New Object > Others > Application Log Object.
Add your object and Subobject like below code
{
"formatVersion": "1",
"header": {
"description": "new log",
"originalLanguage": "en",
"abapLanguageVersion": "cloudDevelopment"
},
"subobjects": [
{
"name": "ZSUBOBJECT1",
"description": "Subobject 1"
}
]
}
Create Job Catalog
New > Others > Application Job Catalog Entry
Here add a custom class
Application Log Catalog Entry
Create Application Job Template
New > Others > Application Job Template
Here provide your created catalog
Application Job Template
Now let’s add very simple required code in the class
Interfaces: The two interfaces used are related to job execution, one gets parameters for the job other executes the code, If_oo_adt_classrun is just a reuse interface to run code as an ABAP application to debug or test.
With cl_bali_log=>create_with_header, cl_bali_header_setter=>, Provide your Object and subobject to initiate log object.
Then with cl_bali_message_setter,cl_bali_freetext_setter,cl_bali_exception_setter we have formed all type of logging type messages.
l_log->add_item, adds item to logs.
Then method save_log will write the logs in database.
it may require COMMIT WORK.
Also notice in the code we have a parameter assign_to_current_appl_job, This will attach the logs to the running Application Job itself.
CLASS z_new_job_class_ec DEFINITION
PUBLIC
FINAL
CREATE PUBLIC .
PUBLIC SECTION.
INTERFACES if_apj_dt_exec_object.
INTERFACES if_apj_rt_exec_object.
INTERFACES if_oo_adt_classrun.
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
CLASS z_new_job_class_ec IMPLEMENTATION.
METHOD if_apj_dt_exec_object~get_parameters.
* You can Insert code here for getting Job parameters
ENDMETHOD.
METHOD if_apj_rt_exec_object~execute.
DATA(l_log) = cl_bali_log=>create_with_header( cl_bali_header_setter=>create( object =
'ZNEWLOG' subobject = 'ZSUBOBJECT1' ) ).
"Add a message as item to the log
DATA(l_message) = cl_bali_message_setter=>create( severity =
if_bali_constants=>c_severity_error
id = 'PO'
number = '000' ).
l_log->add_item( item = l_message ).
"Add a second message, this time from system fields SY-MSGID, ...
MESSAGE ID 'ZTEST' TYPE 'S' NUMBER '058' INTO DATA(l_text).
l_log->add_item( item = cl_bali_message_setter=>create_from_sy( ) ).
"Add a free text to the log
DATA(l_free_text) = cl_bali_free_text_setter=>create( severity =
if_bali_constants=>c_severity_error
text = 'Some Error Text' ).
l_log->add_item( item = l_free_text ).
" Add an exception to the log
DATA: i TYPE i.
TRY.
i = 1 / 0.
CATCH cx_sy_zerodivide INTO DATA(l_ref).
ENDTRY.
DATA(l_exception) = cl_bali_exception_setter=>create( severity =
if_bali_constants=>c_severity_error
exception = l_ref ).
l_log->add_item( item = l_exception ).
"Save the log into the database
cl_bali_log_db=>get_instance( )->save_log( log = l_log assign_to_current_appl_job = abap_true ).
COMMIT WORK.
CATCH cx_bali_runtime INTO DATA(l_runtime_exception).
ENDTRY.
ENDMETHOD.
Let’s Test it now.
Create Job from Job template in application:- Application Job
Create Job
Select your template here via job template description.
Check Scheduling Options
Parameters coming from code in interface:
IF_APJ_DT_EXEC_OBJECT.
Hit Schedule
Log Generated. Click on it.
Job logs:
Summary:
Here you can find some documentation:
https://help.sap.com/docs/btp/sap-business-technology-platform/application-logs?q=Application%20Los
This short blog can help ABAP devs create Application logs and attach it to the Application Jobs with newer approach. Also since this is a reuse logging mechanism this can leveraged in other applications as well.
Since i am also new to ABAP cloud , Expert suggestions & feedbacks are much appreciated.
If you like this blog post you can follow me for more blogs i will try to make in coming future specifically related to ABAP in cloud.








Thanks. There's an official documentation about CL_BALI_LOG only in SAP BTP documentation (as far as I can find), but I can find the class in ABAP 7.57 on premise, do you know if the class is officially supported in on premise systems? Generally speaking, how to know if something allowed in SAP BTP is supported in ABAP On Premise?
Hi Sandra ,
That was one of the reason for me to write this blog because even i was unable to relate the documentation properly back to ABAP cloud. To your question for on-premise i belive it should work. Haven't tried.
I generally look at the propoerties of the object in question.
The ABAP language version and the API state(Release Contracts)- (For cloud or Key-User):
Thanks. I wanted to know if there's an official SAP recommendation for these Cloud-released objects which also exist in on premise systems, would SAP Support help if we use them and there is a bug. Or is it recommended to continue using the old supported BAL function modules (BAL_LOG_XXXX and others).
The only thing I can say is that your code works fine in on premise systems (7.57), the log appears via transaction code SLG1, but it's not my question.
No worry, we'll see 😉
Hello Sandra,
With 2022 on prem/pce release SAP recommends using Embedded steampunk (ABAP Cloud) even in On Premise and PCE implementations where only cloud released and whitelisted objects can work so definitely you should get support in case of issues.
you can also follow Boris's blog for more details.
How to use Embedded Steampunk in SAP S/4HANA Cloud, private edition and in on-premise – The new ABAP extensibility guide | SAP Blogs
Thanks, got it now, so it's officially supported: if I try to use it with S/4HANA 2022 (ABAP 7.57), custom class created with ABAP Language Version "ABAP for Cloud Development", I've got below syntax error when trying to call function module BAL_LOG_CREATE - There's no syntax error if I keep the default "Standard ABAP" language version, and of course CL_BALI_LOG can be used in this context too.
The use of Function Module BAL_LOG_CREATE is not permitted. Use Class CL_BALI_LOG instead.
This is what I was looking for. Thanks for sharing!
Thanks for sharing! There was another blog post recently about application log (not in Cloud), just posting a link here for reference: link
Hi Bunny Arora I was trying to replicate this but the Job Template which I have created in ADT is not reflecting in S4 Hana Launchpad in Application Job.
Do I need to do something extra to do that ?
Thanks in Advance
I don't think so. If you're creating the template, you should be able to see it in launchpad.. For others we have to design roles..Try repeating the steps maybe you missed something.
Hello Bunny Arora ,
Thanks for your blog, it was an informative read. I wanted to ask below points,
Thanks in advance.
Hi Devesh,
Re your question number 1 look here https://help.sap.com/docs/btp/sap-business-technology-platform/how-to-use-fiori-reuse-library
Cheers
Alex
Thanks @Alessandro Guarneri
@Alessandro Guarneri I want to enable viewing of application logs in a custom Fiori app and tried following the freestyle and fiori elements approach....I tried browsing for a reference blog but could not find any....do you have any reference blog....where I can take logic reference from
Thanks Devesh !