Technology Blog Posts by Members
cancel
Showing results for 
Search instead for 
Did you mean: 
Srivatsa
Participant
0 Kudos
638

Step 1: Create the ABAP Class with Required Interfaces

You’ll start by creating a class that contains the logic to be executed in the background.

Interfaces Implemented:

  • IF_OO_ADT_CLASSRUN: Allows testing the class directly in ADT.
  • IF_APJ_DT_EXEC_OBJECT: Defines job metadata and input parameters.
  • IF_APJ_RT_EXEC_OBJECT: Contains the actual logic to be executed in the background job.

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.


📘 Step 2: Create a Job Catalog Entry in ADT

Once your class is ready, the next step is to register it in the Job Catalog using ADT.

How to do it:

  1. In ADT, go to the Project Explorer.
  2. Right-click on your package → New → Other → ABAP Repository Object.
  3. Search for Job Catalog Entry.
  4. Provide:
    • Catalog ID: e.g., ZZ1_INSER_DATA
    • Description: e.g., Insert Sample Titles
    • Execution Class: ZCL_INSERT_SAMPLE_DATA
  5. Save and activate.

Srivatsa_0-1750230956999.png

 

This step makes your class available for job templates.


🧾 Step 3: Create a Job Template in ADT

Now, create a Job Template based on the catalog entry.

Steps:

  1. In ADT, right-click your package → New → Other → ABAP Repository Object.
  2. Search for Job Template.
  3. Provide:
    • Template ID: ZZ1_JOB
    • Description: Insert Sample Titles
    • Job Catalog Entry: ZZ1_INSER_DATA
  4. If your class uses parameters, map them here.
  5. Save and activate.

Srivatsa_1-1750230998629.png

 

This template will be used in the Fiori app to schedule the job.


🌐 Step 4: Create an Application Job Template in Fiori

Now switch to the Fiori Launchpad.

Steps:

  1. Open the "Manage Application Job Templates" app.
  2. Click Create.
  3. Fill in:
    • Template Name: e.g., Insert Sample Titles
    • Job Template ID: ZZ1_JOB (from ADT)
    • Job Catalog ID: ZZ1_INSER_DATA
  4. Save and activate.

This step makes the job template available for end users.

Step 5: Schedule the Job in Fiori

Finally, schedule the job using the Fiori app.

Steps:

  1. Open the "Schedule Application Jobs" app.
  2. Click Create.
  3. Select your Application Job Template.
  4. Set:
    • Start Time: Immediate or scheduled
    • Recurrence: One-time or recurring
  5. Click Schedule.

🧾 Application Logging

Your class uses CL_BALI_LOG to write messages to the application log. This is essential for monitoring and debugging.

Benefits:

  • Structured logging with severity levels.
  • Integration with job monitoring tools.
  • Easy to trace job execution history.
2 Comments