You’ll start by creating a class that contains the logic to be executed in the background.
Your class might look like this:
CLASS zcl_insert_sample_data DEFINITION
PUBLIC
FINAL
CREATE PUBLIC.
PUBLIC SECTION.
INTERFACES: if_oo_adt_classrun,
if_apj_dt_exec_object,
if_apj_rt_exec_object.
PRIVATE SECTION.
METHODS: insert_sample_data.
ENDCLASS.
METHOD if_apj_rt_exec_object~execute.
* " This is the method that will be called by the background job
DATA: application_log TYPE REF TO if_bali_log,
application_log_free_text TYPE REF TO if_bali_free_text_setter.
TRY.
insert_sample_data( ).
application_log = cl_bali_log=>create_with_header(
header = cl_bali_header_setter=>create( object = 'XYZ' " Use your custom log object/subobject
subobject = 'INSERT' ) ).
application_log_free_text = cl_bali_free_text_setter=>create(
severity = if_bali_constants=>c_severity_information " Or c_severity_success
text = 'Sample data inserted successfully.' ).
application_log->add_item( item = application_log_free_text ).
cl_bali_log_db=>get_instance( )->save_log(
log = application_log
assign_to_current_appl_job = abap_true ).
CATCH cx_root INTO DATA(lx_error).
" Log the error message to the Application Log
* application_log = cl_bali_log=>create_with_header(
* header = cl_bali_header_setter=>create( object = 'ZSAMPLE_DATA'
* subobject = 'INSERT' ) ).
* application_log_free_text = cl_bali_free_text_setter=>create(
* severity = if_bali_constants=>c_severity_error
* text = |Error inserting data: { lx_error->get_text( ) }| ).
*
* application_log->add_item( item = application_log_free_text ).
* cl_bali_log_db=>get_instance( )->save_log(
* log = application_log
* assign_to_current_appl_job = abap_true ).
" Re-raise the exception to signal job failure to the framework
* RAISE EXCEPTION TYPE cx_apj_rt_exec_object
* EXPORTING
* previous = lx_error.
ENDTRY.
This class inserts sample data into a custom table and logs the result using CL_BALI_LOG.
Once your class is ready, the next step is to register it in the Job Catalog using ADT.
This step makes your class available for job templates.
Now, create a Job Template based on the catalog entry.
This template will be used in the Fiori app to schedule the job.
Now switch to the Fiori Launchpad.
This step makes the job template available for end users.
Finally, schedule the job using the Fiori app.
Your class uses CL_BALI_LOG to write messages to the application log. This is essential for monitoring and debugging.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
17 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 | |
3 | |
3 | |
3 |