Overview
Prerequisites.
You finished the BTP ABAP Environment initial setup .You have been assigned with role SAP_BR_DEVELOPER in BTP ABAP Environment.You have been assigned with role SAP_BR_ADMINISTRATOR in BTP ABAP Environment.You have installed Eclipse with ADT .
Process.
Step 1. Create ABAP class with interface if_apj_rt_run in Eclipse.
In next screen, select the transport request and Finish.
Replace the class code as the following ABAP codes:
CLASS zcl_application_job DEFINITION
PUBLIC
FINAL
CREATE PUBLIC .
PUBLIC SECTION.
INTERFACES if_apj_rt_run .
INTERFACES if_apj_dt_defaults.
TYPES:
BEGIN OF ty_name_range,
sign TYPE c LENGTH 1,
option TYPE c LENGTH 2,
low TYPE c LENGTH 50,
high TYPE c LENGTH 50,
END OF ty_name_range.
TYPES: ty_name_ranges TYPE STANDARD TABLE OF ty_name_range WITH EMPTY KEY.
“! <p class=”shorttext synchronized” lang=”en”>Numbers available</p>
DATA numbers_available TYPE abap_bool VALUE abap_true.
“! <p class=”shorttext synchronized” lang=”en”>Numbers</p>
DATA numbers TYPE RANGE OF i.
“! <p class=”shorttext synchronized” lang=”en”>Names available</p>
DATA names_available TYPE abap_bool VALUE abap_true.
“! <p class=”shorttext synchronized” lang=”en”>Names</p>
DATA names TYPE ty_name_ranges.
“! <p class=”shorttext synchronized” lang=”en”>Some text</p>
DATA text TYPE c LENGTH 255.
“! <p class=”shorttext synchronized” lang=”en”>Public attribute which is not used on the selection screen</p>
DATA another_public_attribute TYPE c LENGTH 10.
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
CLASS zcl_application_job IMPLEMENTATION.
METHOD if_apj_rt_run~execute.
TRY.
DATA(l_log) = cl_bali_log=>create_with_header(
header = cl_bali_header_setter=>create( object = ‘ZOBJECT’
subobject = ‘ZSUBOBJECT’ ) ).
IF numbers_available = abap_true AND ’42’ IN numbers.
l_log->add_item( item = cl_bali_free_text_setter=>create( severity = if_bali_constants=>c_severity_information
text = ’42 is in the number ranges’ ) ).
ENDIF.
IF names_available = abap_true AND names IS NOT INITIAL.
l_log->add_item( item = cl_bali_free_text_setter=>create( severity = if_bali_constants=>c_severity_status
text = ‘Some names are available’ ) ).
ENDIF.
l_log->add_item( item = cl_bali_free_text_setter=>create( severity = if_bali_constants=>c_severity_status
text = CONV #( text ) ) ).
cl_bali_log_db=>get_instance( )->save_log_2nd_db_connection( log = l_log
assign_to_current_appl_job = abap_true ).
CATCH cx_bali_runtime INTO DATA(l_runtime_exception).
” some error handling
ENDTRY.
ENDMETHOD.
ENDCLASS.
Save and Activate the class.
Step 2. Create Application Job Catalog Entry in Eclipse.
In next screen, select the transport request and finish .
Save and Activate.
Step 3. Create Application Job Template in Eclipse.
In next screen, select the transport request and finish .
Save and Activate.
Step 4. Schedule the background job in BTP ABAP Environment .
The End!
Thank you for your time!
Jacky Liu
OverviewIn lob systems, business needs to run some repeative background job periodically like in financial closing time monthly. In ECC or SAP S/4HANA Cloud.An ABAP Developer can develop an classic ABAP program and schedule background job with transaction code SM36. But to keep core clean, classic ABAP should be avoided and reduced. So our customers are checking how to realize the similar functions SAP BTP ABAP Environment. Today, I will demo the step by step processes .Prerequisites.You finished the BTP ABAP Environment initial setup .You have been assigned with role SAP_BR_DEVELOPER in BTP ABAP Environment.You have been assigned with role SAP_BR_ADMINISTRATOR in BTP ABAP Environment.You have installed Eclipse with ADT . Process.Step 1. Create ABAP class with interface if_apj_rt_run in Eclipse. In next screen, select the transport request and Finish.Replace the class code as the following ABAP codes:CLASS zcl_application_job DEFINITION
PUBLIC
FINAL
CREATE PUBLIC .
PUBLIC SECTION.
INTERFACES if_apj_rt_run .
INTERFACES if_apj_dt_defaults.
TYPES:
BEGIN OF ty_name_range,
sign TYPE c LENGTH 1,
option TYPE c LENGTH 2,
low TYPE c LENGTH 50,
high TYPE c LENGTH 50,
END OF ty_name_range.
TYPES: ty_name_ranges TYPE STANDARD TABLE OF ty_name_range WITH EMPTY KEY.
“! <p class=”shorttext synchronized” lang=”en”>Numbers available</p>
DATA numbers_available TYPE abap_bool VALUE abap_true.
“! <p class=”shorttext synchronized” lang=”en”>Numbers</p>
DATA numbers TYPE RANGE OF i.
“! <p class=”shorttext synchronized” lang=”en”>Names available</p>
DATA names_available TYPE abap_bool VALUE abap_true.
“! <p class=”shorttext synchronized” lang=”en”>Names</p>
DATA names TYPE ty_name_ranges.
“! <p class=”shorttext synchronized” lang=”en”>Some text</p>
DATA text TYPE c LENGTH 255.
“! <p class=”shorttext synchronized” lang=”en”>Public attribute which is not used on the selection screen</p>
DATA another_public_attribute TYPE c LENGTH 10.
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
CLASS zcl_application_job IMPLEMENTATION.
METHOD if_apj_rt_run~execute.
TRY.
DATA(l_log) = cl_bali_log=>create_with_header(
header = cl_bali_header_setter=>create( object = ‘ZOBJECT’
subobject = ‘ZSUBOBJECT’ ) ).
IF numbers_available = abap_true AND ’42’ IN numbers.
l_log->add_item( item = cl_bali_free_text_setter=>create( severity = if_bali_constants=>c_severity_information
text = ’42 is in the number ranges’ ) ).
ENDIF.
IF names_available = abap_true AND names IS NOT INITIAL.
l_log->add_item( item = cl_bali_free_text_setter=>create( severity = if_bali_constants=>c_severity_status
text = ‘Some names are available’ ) ).
ENDIF.
l_log->add_item( item = cl_bali_free_text_setter=>create( severity = if_bali_constants=>c_severity_status
text = CONV #( text ) ) ).
cl_bali_log_db=>get_instance( )->save_log_2nd_db_connection( log = l_log
assign_to_current_appl_job = abap_true ).
CATCH cx_bali_runtime INTO DATA(l_runtime_exception).
” some error handling
ENDTRY.
ENDMETHOD.
ENDCLASS.Save and Activate the class.Step 2. Create Application Job Catalog Entry in Eclipse. In next screen, select the transport request and finish .Save and Activate. Step 3. Create Application Job Template in Eclipse. In next screen, select the transport request and finish . Save and Activate. Step 4. Schedule the background job in BTP ABAP Environment . The End!Thank you for your time!Jacky Liu Read More Technology Blog Posts by SAP articles
#SAP
#SAPTechnologyblog