Advertising:

Create job templates for Fiori App application job (F1240).

From SAP Knowledge Base
Revision as of 11:35, 31 December 2024 by Unirab (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Job templates can be created which can then be used in the “Application job” or “Application Jobs” app to create jobs.

Overview of the required objects in ADT

  • Creation of Y/Z class
    • Use of interfaces
      • if_apj_dt_exec_object
      • if_apj_rt_exec_object
    • Implementation method if_apj_dt_exec_object~get_parameters.
    • Implementation method if_apj_rt_exec_object~execute
  • Creation of Application Job Catalog Entry
    • Assignment of the class with execute method
  • Creation Job Template
    • Assignment of Job Catalog Entry
    • Definition of default values when a template is used for job creation

Creating the required objects in ADT

Y/Z class

Maybe you are interested ending the classes with “_ajob”.

Example Code
 CLASS ycl_name_of_class_ajob DEFINITION
  PUBLIC
  FINAL
  CREATE PUBLIC .

  PUBLIC SECTION.
    INTERFACES: if_apj_dt_exec_object,
                if_apj_rt_exec_object.
    
    "Spätere Parameter bei Jobanlage
    CONSTANTS: cv_material       TYPE selname VALUE 'SO_MATNR' ##NO_TEXT,
               cv_posting_date   TYPE selname VALIE 'P_PODATE' ##NO_TEXT.
  PROTECTED SECTION.
  PRIVATE SECTION.
 ENDCLASS.

 CLASS ycl_name_of_class_ajob IMPLEMENTATION.
  METHOD if_apj_dt_exec_object~get_parameters.

    et_parameter_def = VALUE #(
          ( selname = 'SO_MATNR'  kind = 'S' datatype = 'C' component_type = 'MATNR'      length = '40'  decimals = '0' param_text ='Material'(001) changeable_ind = 'X' )
          ( selname = 'P_PODATE'  kind = 'P' datatype = 'D' component_type = 'BUDAT'      length = '6'  decimals = '0' param_text ='Posting Date'(004) changeable_ind = 'X' mandatory_ind = '' )
      ).

    " Default value
    et_parameter_val = VALUE #(
      ( selname = 'P_PODATE'
        kind    = 'P'
        sign    = 'I'
        option  = 'EQ'
        low     = sy-datum ) ##NO_TEXT
    ).
  ENDMETHOD.

  METHOD if_apj_rt_exec_object~execute.

    TRY.
        DATA(lo_log) = cl_bali_log=>create_with_header( cl_bali_header_setter=>create( object ='' subobject = '' external_id = '' ) ).
      CATCH cx_bali_runtime.
    ENDTRY.

    TRY.
        DATA(lv_posting_date) = it_parameters[ selname = cv_posting_date ]-low.
      CATCH cx_sy_itab_line_not_found.
       RETURN.
    ENDTRY.

    DATA: ltr_material      TYPE RANGE OF matnr.

    LOOP AT it_parameters ASSIGNING FIELD-SYMBOL(<ls_para>).
      CASE <ls_para>-selname.
        WHEN cv_material.
          APPEND INITIAL LINE TO ltr_material ASSIGNING FIELD-SYMBOL(<ls_add_material>).
          MOVE-CORRESPONDING <ls_para> TO <ls_add_material>.
        WHEN OTHERS.
         "Handling, wenn ein Parameter da ist, der nicht erwartet wird
      ENDCASE.
    ENDLOOP.

    "Dein
    "Application Code
    "hier

    TRY.
        cl_bali_log_db=>get_instance( )->save_log( log = lo_log
                                                   assign_to_current_appl_job = abap_true ).
     CATCH cx_bali_runtime.
    ENDTRY.
   ENDMETHOD.
  ENDCLASS.

Creation of job entry

The object in ADT is called “Application Job Catalog Entry”. Maybe you are interested calling it “_JOB_CAT”. Once the object has been created, the class in which the execute method is located can be specified under “General Information”.

Creation of job template

The object in ADT is called “Application Job Template”. Maybe you are interested calling it “_JOB_TEMP”. Once the object has been created, the job catalog entry that has already been created can be assigned under “General Information”. Default values ​​can be specified for “Parameters”.

Debug application jobs

Application jobs that are created and carried out via the app can also be seen in SM37 like the classic jobs. However, the job name has a randomly generated name. Debugging is possible if you mark the job using a checkbox and enter it in the transaction field JDBG in the GUI and confirm with Enter. If a breakpoint is set in the above-mentioned methods in the GUI, the debugger starts.


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