Content is now moved to GitHub. Future update will be performed at Abap-for-Cloud-Development-CheatSheet. |
Disclaimer:
|
Standard ABAP object/ based solution | Public local API to use instead in ABAP for Cloud Development |
Business Partner | |
Table: KNA1 KNB1 KNVK KNVP KNVV LFA1 LFB1 LFM1 | CDS view: i_customer i_customercompany i_contactperson i_custsalespartnerfunc i_customersalesarea i_supplier i_suppliercompany i_supplierpurchasingorg |
Delivery | |
Table: LIKP LIPS TVST | CDS view: i_deliverydocument i_deliverydocumentitem i_shippingpoint |
Finance | |
Table: BKPF BSEG ACDOCA SKA1 SKB1 T001 T003 CEPC Function Module: BAPI_ACC_EMPLOYEE_EXP_POST BAPI_ACC_INVOICE_RECEIPT_CHECK BAPI_ACC_INVOICE_RECEIPT_POST BAPI_ACC_DOCUMENT_CHECK BAPI_ACC_DOCUMENT_POST BAPI_ACC_ACT_POSTINGS_REVERSE | CDS view: i_journalentry i_operationalacctgdocitem i_journalentryitem i_glaccountlineitem i_glaccountlineitemrawdata i_glaccountinchartofaccounts i_glaccountincompanycode i_companycode i_profitcenter Behavior Definition: i_journalentrytp |
Finance(Hierarchy) | |
Table: SETHEADER SETHEADERT SETLEAF SETNODE | CDS view: i_costcenterhierarchy i_costcenterhierarchynode i_costctractivitytypehiernode i_functionalareahierarchy i_functionalareahiernode i_profitcenterhierarchy i_profitcenterhierarchynode |
Manufacturing | |
Table: MARA MARC MARD MARM AFKO AFPO AFRU AFVC AFVU AFVV MKAL PLKO PLPO Function Module: BAPI_MATERIAL_MAINTAINDATA_RT BAPI_MATERIAL_SAVEREPLICA BAPI_MATERIAL_SAVEDATA BAPI_PLANNEDORDER_GET_DETAIL BAPI_PRODORD_CHANGE BAPI_PRODORD_COMPLETE_TECH BAPI_PRODORD_CREATE BAPI_PRODORD_RELEASE BAPI_MATERIAL_STOCK_REQ_LIST | CDS view: i_product i_productqm i_productsales i_productprocurement i_productplantbasic i_productsupplyplanning i_productstoragelocationbasic i_productunitsofmeasure i_manufacturingorder i_manufacturingorderitem i_mfgorderconfirmation i_manufacturingorderoperation i_manufacturingorderoperation i_manufacturingorderoperation i_productionversion i_billofoperationsgroup i_mfgbillofoperationsoperation Behavior Definition: i_producttp_2 i_plannedordertp i_productionordertp i_productionordconfirmationtp i_plndindeprqmttp i_supplydemanditemtp |
Payment | |
Table: REGUH REGUP REGUV REGUT | CDS view: i_paymentprogramcontrol i_paymentproposalpayment i_paymentproposalitem i_paymentproposalcontrol |
Physical Inventory Management | |
Table: IKPF ISEG T001L T001W MSEG MKPF Function Module: MB_CREATE_GOODS_MOVEMENT MB_POST_GOODS_MOVEMENT BAPI_GOODSMVT_CANCEL BAPI_GOODSMVT_CREATE BAPI_MATPHYSINV_CHANGECOUNT BAPI_MATPHYSINV_COUNT BAPI_MATPHYSINV_CREATE | CDS view: i_physinvtrydocheader i_physinvtrydocitem i_storagelocation i_plant i_materialdocumentitem_2 i_materialdocumentheader_2 Behavior Definition: i_materialdocumenttp i_physicalinventorydocumenttp |
Sales | |
Table: VBAK VBAP VBEP VBFA VBKD VBRK VBRP TVGRT TVKBT TVKBZ TVKGR TVKO TVTA TVTW Function Module: BAPISDORDER_GETDETAILEDLIST BAPI_SALESORDER_CREATEFROMDAT2 | CDS view: i_salesdocument i_salesdocumentitem i_salesdocumentscheduleline i_sddocumentmultilevelprocflow i_salesdocument i_billingdocumentbasic i_billingdocumentitembasic i_salesgroup i_salesoffice i_salesareasalesoffice i_salesgroup i_salesorganization i_salesarea i_distributionchannel Behavior Definition: i_salesordertp |
Sales (Pricing) | |
Table: KONH KONM KONP KONV PRCD_ELEMENTS T685 T685A | CDS view: i_slsprcgconditionrecord i_slsprcgcndnrecordscale i_slsprcgconditionrecord i_slsprcgconditionrecord i_slsprcgconditionrecord i_conditiontype i_pricingconditiontype |
Sourcing and Procurement | |
Table: EKKO EKPO RBKP RSEG MATDOC EBAN EBKN EINA EINE MSKA MSKU MSLB MSLBH Function Module: BAPI_PO_CHANGE BAPI_PO_CREATE1 BAPI_PR_CHANGE BAPI_PR_CREATE BAPI_REQUISITION_CHANGE BAPI_REQUISITION_CREATE BAPI_REQUISITION_GETDETAIL BAPI_INCOMINGINVOICE_CREATE BAPI_INCOMINGINVOICE_POST BAPI_INCOMINGINVOICE_RELEASE | CDS view: i_purchaseorderapi01 i_purchaseorderitemapi01 i_supplierinvoiceapi01 i_suplrinvcitempurordrefapi01 i_materialdocumentheader_2 i_purchaserequisitionitemapi01 i_purreqnacctassgmtapi01 i_purchasinginforecordapi01 i_purchasinginforecordapi01 i_materialstock Behavior Definition: i_purchaseordertp_2 i_purchaserequisitiontp i_purchasecontracttp i_supplierinvoicetp |
Standard ABAP syntax/ based solution | Syntax/API to use instead in ABAP for Cloud Development |
ABAP memory | |
EXPORT <input variable> TO MEMORY ID <ID name>. IMPORT <parameter name> TO <output variable> FROM MEMORY ID <ID name>. | EXPORT <parameter name> = <input variable> TO INTERNAL TABLE / DATA BUFFER IMPORT <parameter name> = <output variable> FROM INTERNAL TABLE / DATA BUFFER. |
ABAP Object | |
Table: DD01L DD02L DD02V DD03L DD04L | Class: xco_cp_abap_dictionary xco_cp_database_table xco_cp_cds xco_cp_data_element xco_cp_domain |
Access management | |
SAP Role x Profiles based access management | Access Control based on Authority Object/Field, Restriction Type/Field, IAM app, CDS Access Control Object and Business Catalog/Role For the detailed solution , scroll down below to "Access management" |
Application log | |
Tcode: SLG0 SLG1 Function module: BAL_LOG_CREATE BAL_LOG_MSG_ADD BAL_DB_SAVE BAL_DB_SEARCH BAL_LOG_MSG_READ BAL_DSP_TXT_MSG_READ Table: BALHDR BALDAT | Class: cl_bali_object_handler(CRUD application log object) cl_bali_log / cl_bali_header_setter(Write log) cl_bali_log_db/cl_bali_log_filter(Read log) xco_cp_bal Fiori app: Application logs |
Calculation | |
ADD, SUBTRACT, MULTIPLY, DIVIDE | ADD-> + or += SUBTRACT-> – or –= MULTIPLY-> * or *= DIVIDE-> / or /= |
Calendar(Factory calendar) | |
Tcode: SCAL Function module: FACTORYDATE_CONVERT_TO_DATE DATE_CONVERT_TO_FACTORYDATE CALCULATE_DATE RKE_SELECT_FACTDAYS_FOR_PERIOD Table: TFACD TFACS | Class: CL_FHC_CALENDAR_RUNTIME CDS views: I_FactoryCalendarBasic I_FactoryCalendarBasicText .... For the detailed solution , scroll down below to "Calendar(Factory calendar)" |
Calendar(General) | |
Function module: MONTH_NAMES_GET WEEK_GET_FIRST_DAY DATE_GET_WEEK | Class: CL_SCAL_UTILS |
Calendar(Public holidays) | |
Tcode: SCAL Function module: HOLIDAY_CHECK_AND_GET_INFO HOLIDAY_GET HOLIDAY_CALENDAR_GET Table: THOC THOCD | Class: CL_FHC_CALENDAR_RUNTIME CDS views: I_PublicHolidayCalendarBasic I_PublHolidayCalendarBasicText ... For the detailed solution , scroll down below to "Calendar(Public holidays)" |
Call stack | |
Function module: SYSTEM_CALLSTACK SYSTEM_CALLSTACK_OF_PROCESS | Class: xco_cp_call_stack |
Conversion(XSTRING, Binary, BASE64) | |
Function module: SCMS_BINARY_TO_XSTRING SCMS_BINARY_TO_STRING SCMS_XSTRING_TO_BINARY SCMS_STRING_TO_XSTRING SCMS_BASE64_ENCODE_STR SCMS_BASE64_DECODE_STR | Class: xco_cp=>xstring xco_cp_binary |
Count itab rows | |
DESCRIBE TABLE lt_table line DATA(lv_count) | DATA(lv_count) = lines( lt_table ) |
Date handling | |
Function module: CONVERT_DATE_TO_EXTERNAL CONVERT_DATE_TO_INTERNAL DATE_CONV_EXT_TO_INT DATE_CHECK_PLAUSIBILITY Class: cl_demo_date_time With write: WRITE sy-datum TO date. | Class: cl_abap_datfm cl_abap_timefm cl_abap_tstmp |
Debugging | |
SAP GUI based debugging Synatax: break-point | ABAP Development Tools based debugging |
Documents change logs | |
Table: CDHDR CDPOS Tcode: SCDO Function module: CHANGEDOCUMENT_READ_HEADERS CHANGEDOCUMENT_READ_HEADERS | Change Document Object Class: <name space>CL_<change document object name>_CHDO cl_chdo_read_tools ... For the detailed solution , scroll down below to "Change document logging" |
Event Blocks | |
LOAD-OF-PROGRAM INITIALIZATION AT SELECTION-SCREEN START-OF-SELECTION, etc.. | Not allowed because 1. Program object is not allowed to be created 2. No dynpro allowed therefore no selection screen. |
Excel upload to itab | |
Function module: GUI UPLOAD TEXT_CONVERT_XLS_TO_SAP ALSM_EXCEL_TO_INTERNAL_TABLE Class: cl_fdt_xl_spreadsheet | Class: xco_cp_xlsx xco_cp_xlsx_selection xco_cp_xlsx_read_access ... For the detailed solution , scroll down below to "Excel upload to itab" |
Exchange rate | |
Table: TCURR V_TCURR | Class: cl_exchange_rates(only update and conversion) ... For reading the exchange rate, scroll down below to "Exchange rate" |
Forms and printing | |
Tcode: SE71~SE77(SAP Script) SMARTFORMS, SMARTSTYLES(Smartforms) SFP(Adobe forms) Function module: OPEN_FORM START_FORM WRITE_FORM END_FORM CLOSE_FORM Call Function '<Smartform/Adobe form FM>' | Tool: Adobe LiveCycle Designer(for designing form layout) Services: Forms Service by Adobe(for rendering PDF forms built with Adobe LiveCycle Designer) Class: cl_print_queue_utils(writing print queues) Fiori app: Maintain print queues ... For the detailed solution , scroll down below to "Forms and printing" |
Fiori programming model | |
Gateway service builder SEGW BOPF framework | RESTful ABAP Programming model (RAP) |
HTTP Service | |
Tcode: SICF Interface: IF_HTTP_EXTENSION | ABAP object: Create HTTP service and implement logic in underlying ABAP class |
Identity Management | |
Table: AGR_USERS USR01 USR03 Tcode: PFCG SU01 SU10 | CDS View: I_IAMBusinessUserBusinessRole(Business Role assignment to Business User) I_IAMBusinessRole(Business Role) I_IAMBusinessUserLogonDetails (Business user login info) I_BusinessPartner(Employee general data) I_WorkplaceAddress(Employee address data) Class: cl_iam_business_role_factory cl_iam_business_user_factory Fiori app: Maintain Business User Maintain Business Roles |
XML handling | |
Function module: SMUM_XML_PARSE SMUM_XML_CREATE SMUM_XML_CREATE_X TEXT_CONVERT_XML_TO_SAP Tcode: XSLT_TOOL | Class: cl_demo_xml_access cl_sxml_string_reader cl_sxml_string_writer cl_sxml_table_reader cl_sxml_table_writer |
Job scheduling | |
Tcode: SM36 SM37 Function module: JOB_OPEN JOB_CLOSE JOB_SUBMIT BP_JOB_DELETE BP_JOB_READ SHOW_JOBSTATE | Fiori app: Application Jobs Application Job Templates Maintain Job Users Class: cl_apj_dt_create_content(Creating job catalog and template) cl_apj_rt_api(Start, change, delete job programmatically) ... For the detailed solution , scroll down below to "Job scheduling" |
Large object handing(storing as MIME) | |
1.Use MIME Repository: Tcode: SMW0 Class: CL_MIME_REPOSITORY_API CL_WB_MIME_REPOSITORY 2.Store as XSTRING in custom table: OPEN DATASET, TRANSFER, CLOSE DATAET(from application server) Function module: GUI_UPLOAD(upload from local) SCMS_BINARY_TO_XSTRING(conversion to xstring) | ABAP RAP with Large object handing CDS annotations: @Semantics.largeObject @Semantics.mimeType ... For the detailed solution , scroll down below to "Large object handling" |
Lock object | |
Function module: ENQUEUE_E_TABLE DEQUEUE_E_TABLE DEQUEUE_ALL | Class: cl_abap_lock_object_factory |
Loop group level processing | |
LOOP AT lt_tab ASSIGNING FIELD-SYMBOL(<tab>). AT NEW field1.ENDAT. ENDLOOP. | LOOP AT lt_table ASSIGNING FIELD-SYMBOL(<lw_table>) GROUP BY ( field1 = <lw_table>-field1 ). LOOP AT GROUP <lw_table> ASSIGNING FIELD-SYMBOL(<lw_field1>).ENDLOOP. ENDLOOP. |
Number range | |
Tcode: SNRO Table: NRIV Function module: NUMBER_GET_NEXT NUMBER_CHECK | Class: cl_numberrange_objects(maintain number range object) cl_numberrange_intervals(maintain number range interval) cl_numberrange_runtime(get next number, check number)Fiori app: Manage number range intervals |
Parallel processing | |
CALL FUNCTION … STARTING NEW TASK | Class: cl_abap_parallelFor the detailed solution , scroll down below to "Parallel processing" |
Regex | |
DATA:lv_input TYPE string VALUE 'ABCDE12345'. REPLACE ALL OCCURRENCES OF REGEX '[A-Z]' IN lv_input WITH space. | Class: cl_abap_matcher cl_abap_regex xco_cp_regular_expression or DATA:lv_input TYPE string VALUE 'ABCDE12345'. REPLACE ALL OCCURRENCES OF PCRE '[A-Z]' IN lv_input WITH space. |
RFC | |
Tcode: SE37 SM59 | ABAP object: For Outbound - Create outbound service with service type RFC - Create communication scenario for this outbound service For Inbound - Create function module and set the processing type as RFC - Create Communication Scenario and set the created RFC there as inbound service - Create Communication Arrangement for the Communication Scenario. - Client can now trigger the API created by Communication Arrangement to process the logic inside the function module. Class: cl_rfc_destination_provider(create instance of RFC destination) |
Search string | |
DATA: text TYPE string VALUE `ABCDEFG`. SEARCH text FOR 'CD' IN CHARACTER MODE. | DATA: text TYPE string VALUE `ABCDEFG`. FIND 'CD' IN text IN CHARACTER MODE. |
SOAP Service | |
Tcode: SOAMANAGER SPROXY Function module based web service creation | ABAP object: Create outbound service with service type SOAP Create communication scenario for this outbound service Class: cl_soap_destination_provider(create instance of SOAP destination) *Inbound SOAP service creation is not supported |
System date, time, timezone | |
sy-datum sy-uzeit sy-zonlo | cl_abap_context_info=>get_system_date( ) cl_abap_context_info=>get_system_time( ) cl_abap_context_info=>get_user_time_zone( ) |
System fields | |
Everything else than those specified on the right | sy-batch, sy-dbcnt, sy-fdpos, sy-index, sy-index , sy-mandt, sy-mandt, sy-msgno, sy-msgty, sy-msgv1234, sy-subrc, sy-sysid, sy-tabix, sy-uname |
Translation | |
SAP GUI based translation maintenance | Class: xco_cp_i18n Fiori app: Maintain translations ... For the detailed solution , scroll down below to "Translation" |
Transport request | |
Table: E070 E071 | Class: xco_cp_cts xco_cp_transport |
UI | |
SAP GUI/WebGUI Write statement ALV | ADT output console Fiori app generate by ABAP UI service Fiori app generate by ABAP2UI5(open source) ... For the detailed solution , scroll down below to "UI" |
UNIX timestamp | |
No easy way to convert UNIX timestamps without calculations. | Class: xco_cp=>sy->unix_timestamp( ) |
Units of Measurement | |
Table: T006* Function Module: UNIT_CONVERSION_SIMPLE UNIT_GET MC_UNIT_CONVERSION CONVERSION_EXIT_CUNIT_INPUT Tcode: CUNI | Class: cl_uom_maintenance(Units of Measurement) cl_uom_dim_maintenance(Dimension) cl_uom_conversion CDS View: I_UnitOfMeasure |
"ABAP memory using buffer
DATA:buffer TYPE xstring,
lt_input_bf TYPE STANDARD TABLE OF I_UnitOfMeasure,
lt_output_bf TYPE STANDARD TABLE OF I_UnitOfMeasure.
SELECT * FROM I_UnitOfMeasure INTO TABLE @lt_input_bf.
EXPORT input = lt_input_bf TO DATA BUFFER buffer.
IMPORT input = lt_output_bf FROM DATA BUFFER buffer.
managed implementation in class ZCL_BLOB_TEST unique;
strict ( 1 );
with draft;
define own authorization context
{
'ZAUTH_OBJ';
}
define behavior for ZI_BLOB_TEST alias BLOB_TEST
persistent table zblob_test
draft table ziblob_test_d
etag master LocalLastChangedAt
lock master total etag LastChangedAt
authorization master ( global )
IF requested_authorizations-%create EQ if_abap_behv=>mk-on.
* check create authorization
AUTHORITY-CHECK OBJECT 'ZAUTH_OBJ' ID 'ACTVT' FIELD '01'.
result-%create = COND #( WHEN sy-subrc = 0 THEN
if_abap_behv=>auth-allowed ELSE
if_abap_behv=>auth-unauthorized ).
ENDIF.
IF requested_authorizations-%update EQ if_abap_behv=>mk-on.
* check update authorization
AUTHORITY-CHECK OBJECT 'ZAUTH_OBJ' ID 'ACTVT' FIELD '02'.
result-%update = COND #( WHEN sy-subrc = 0 THEN
if_abap_behv=>auth-allowed ELSE
if_abap_behv=>auth-unauthorized ).
ENDIF.
"Add 2 days from a date considering factory calendar
DATA(lo_holidaycalendar) = cl_fhc_calendar_runtime=>create_factorycalendar_runtime( iv_factorycalendar_id
= 'SAP_CA' ). "Canada
lo_holidaycalendar->add_workingdays_to_date(
EXPORTING
iv_start = '20221230'
iv_number_of_workingdays = 2
RECEIVING
rv_end = DATA(lv_end) "Result is 20230103
).
DATA(lo_holidaycalendar) = cl_fhc_calendar_runtime=>create_holidaycalendar_runtime(
EXPORTING
iv_holidaycalendar_id = 'SAP_CA' ). "Canada
"Check if the data is a holiday in Canada
lo_holidaycalendar->is_holiday(
EXPORTING
iv_date = '20230101'
RECEIVING
rv_holiday = DATA(lv_result)
).
"Get holiday information for 20230101
DATA: lv_date TYPE lo_holidaycalendar->ty_fhc_date VALUE '20230101'.
DATA(lo_holidays) = lo_holidaycalendar->get_holiday(
EXPORTING
iv_date = lv_date
).
lo_holidays->get_text(
EXPORTING
iv_language = sy-langu
RECEIVING
rs_text = DATA(ls_text)
).
DATA:lt_xzcd_test TYPE zcl_zobj_cd_test_chdo=>tt_zcd_test,
lt_yzcd_test TYPE zcl_zobj_cd_test_chdo=>tt_zcd_test,
lv_username TYPE if_chdo_object_tools_rel=>ty_cdusername.
DATA(lv_sys_datum) = cl_abap_context_info=>get_system_date( ).
DATA(lv_sys_time) = cl_abap_context_info=>get_system_time( ).
DATA(lv_user) = cl_abap_context_info=>get_user_formatted_name( ).
lv_username = lv_user.
APPEND INITIAL LINE TO lt_xzcd_test ASSIGNING FIELD-SYMBOL(<lw_xzcd_test>).
<lw_xzcd_test>-employeeid = '0000000001'.
<lw_xzcd_test>-role = 'Developer'. "New value
APPEND INITIAL LINE TO lt_yzcd_test ASSIGNING FIELD-SYMBOL(<lw_yzcd_test>).
<lw_yzcd_test>-employeeid = '0000000001'.
<lw_yzcd_test>-role = 'Solution designer'. "Old value
zcl_zobj_cd_test_chdo=>write(
EXPORTING
objectid = 'ZOBJ_CD_TEST'
utime = lv_sys_time
udate = lv_sys_datum
username = lv_username
* planned_change_number =
object_change_indicator = 'U'
* planned_or_real_changes =
* no_change_pointers =
xzcd_test = lt_xzcd_test
yzcd_test = lt_yzcd_test
upd_zcd_test = 'U'
IMPORTING
changenumber = DATA(lv_changenumbner)
).
METHOD if_chdo_enhancements~authority_check.
"No Auth check performed. Allow all
rv_is_authorized = 'X'.
ENDMETHOD.
cl_chdo_read_tools=>changedocument_read(
EXPORTING
i_objectclass = 'ZOBJ_CD_TEST'
IMPORTING
et_cdredadd_tab = DATA(lt_cdredadd_tab)
).
TYPES:
BEGIN OF ts_row,
Column1 TYPE string,
Column2 TYPE string,
END OF ts_row,
tt_row TYPE STANDARD TABLE OF ts_row WITH DEFAULT KEY.
DATA:lt_rows TYPE tt_row.
DATA(lo_xlsx) = xco_cp_xlsx=>document->for_file_content( iv_file_content = <Your file that is in XSTRING format> )->read_access( ).
DATA(lo_worksheet) = lo_xlsx->get_workbook( )->worksheet->for_name( iv_name = 'Sheet1' ).
DATA(lo_selection_pattern) = xco_cp_xlsx_selection=>pattern_builder->simple_from_to( )->get_pattern( ).
lo_worksheet->select( lo_selection_pattern
)->row_stream(
)->operation->write_to( REF #( lt_rows )
)->if_xco_xlsx_ra_operation~execute( ).
mo_http_destination = cl_http_destination_provider=>create_by_cloud_destination(
i_service_instance_name = CONV #( iv_service_instance_name )
i_name = 'ADS_SRV'
i_authn_mode = if_a4c_cp_service=>service_specific
).
mv_client = cl_web_http_client_manager=>create_by_http_destination( mo_http_destination ).
"Get the base64 encoded PDF content
DATA(lo_json) = /ui2/cl_json=>generate( json = lv_rendered_pdf ).
IF lo_json IS BOUND.
ASSIGN lo_json->* TO FIELD-SYMBOL(<data>).
ASSIGN COMPONENT `fileContent` OF STRUCTURE <data> TO FIELD-SYMBOL(<field>).
ASSIGN <field>->* TO FIELD-SYMBOL(<pdf_base64>).
ENDIF.
"Upload the xstring to z table, so the content can be viewed with RAP generated report
DATA: lt_input TYPE STANDARD TABLE OF zblob_test.
lt_input = VALUE #( ( docnum = '1000000001' filename = 'test.pdf' attachment = lv_pdf_xstring mimetype =
'application/pdf' )
).
INSERT zblob_test FROM TABLE @lt_input.
DATA: lv_print_data TYPE xstring,
lv_err_msg TYPE STRING.
SELECT * FROM zcd_test INTO TABLE @DATA(lt_table).
CALL TRANSFORMATION id SOURCE root = lt_table RESULT XML DATA(lv_xstring).
lv_print_data = lv_xstring.
DATA(lv_qitem_id) = cl_print_queue_utils=>create_queue_item_by_data(
EXPORTING
iv_qname = 'TEST_QUEUE'
iv_print_data = lv_print_data
iv_name_of_main_doc = 'zcd_test'
IMPORTING
ev_err_msg = lv_err_msg
).
out->write( lv_qitem_id ).
CLASS zcl_job_schedule_apj DEFINITION
PUBLIC
FINAL
CREATE PUBLIC .
PUBLIC SECTION.
INTERFACES if_apj_dt_exec_object.
INTERFACES if_apj_rt_exec_object.
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
CLASS zcl_job_schedule_apj IMPLEMENTATION.
METHOD if_apj_dt_exec_object~get_parameters.
" Return the supported selection parameters here
et_parameter_def = VALUE #(
( selname = 'S_ID' kind = if_apj_dt_exec_object=>select_option datatype = 'C' length = 10 param_text
= 'ID' changeable_ind = abap_true )
( selname = 'P_DESCR' kind = if_apj_dt_exec_object=>parameter datatype = 'C' length = 80 param_text = 'Description' lowercase_ind = abap_true changeable_ind = abap_true )
( selname = 'P_SIMUL' kind = if_apj_dt_exec_object=>parameter datatype = 'C' length = 1 param_text =
'Simulate Only' checkbox_ind = abap_true changeable_ind = abap_true )
).
" Return the default parameters values here
et_parameter_val = VALUE #(
( selname = 'S_ID' kind = if_apj_dt_exec_object=>select_option sign = 'I' option = 'EQ' low = '1001'
)
( selname = 'P_DESCR' kind = if_apj_dt_exec_object=>parameter sign = 'I' option = 'EQ' low = 'Application Job Description' )
( selname = 'P_SIMUL' kind = if_apj_dt_exec_object=>parameter sign = 'I' option = 'EQ' low =
abap_true )
).
ENDMETHOD.
METHOD if_apj_rt_exec_object~execute.
"Execution logic when the job is started
TYPES ty_id TYPE c LENGTH 10.
DATA s_id TYPE RANGE OF ty_id.
DATA p_descr TYPE c LENGTH 80.
DATA p_count TYPE i.
DATA p_simul TYPE abap_boolean.
" Getting the actual parameter values(Just for show. Not needed for the logic below)
LOOP AT it_parameters INTO DATA(ls_parameter).
CASE ls_parameter-selname.
WHEN 'S_ID'.
APPEND VALUE #( sign = ls_parameter-sign
option = ls_parameter-option
low = ls_parameter-low
high = ls_parameter-high ) TO s_id.
WHEN 'P_DESCR'.
p_descr = ls_parameter-low.
WHEN 'P_SIMUL'.
p_simul = ls_parameter-low.
ENDCASE.
ENDLOOP.
"Implement core process you want to execute with this job
".......................
".......................
".......................
ENDMETHOD.
ENDCLASS.
CLASS zcl_job_template_apj DEFINITION
PUBLIC
FINAL
CREATE PUBLIC .
PUBLIC SECTION.
INTERFACES if_oo_adt_classrun.
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
CLASS zcl_job_template_apj IMPLEMENTATION.
METHOD if_oo_adt_classrun~main.
DATA(lo_apj_create) = cl_apj_dt_create_content=>get_instance( ).
" Create job catalog
lo_apj_create->create_job_cat_entry(
iv_catalog_name = 'Z_TESTJOB_CATALOG'
iv_class_name = 'zcl_job_schedule_apj'
iv_text = 'Job catalog text'
iv_catalog_entry_type = cl_apj_dt_create_content=>class_based
iv_transport_request = 'H01K900008'
iv_package = 'ZSANDBOX'
).
out->write( |Job catalog entry created successfully| ).
" Create job template
DATA lt_parameters TYPE if_apj_dt_exec_object=>tt_templ_val.
NEW zcl_job_schedule_apj( )->if_apj_dt_exec_object~get_parameters(
IMPORTING
et_parameter_val = lt_parameters
).
lo_apj_create->create_job_template_entry(
iv_template_name = 'Z_TESTJOB_TEMPLATE'
iv_catalog_name = 'Z_TESTJOB_CATALOG'
iv_text = 'Job template text'
it_parameters = lt_parameters
iv_transport_request = 'H01K900008'
iv_package = 'ZSANDBOX'
).
out->write( |Job template created successfully| ).
ENDMETHOD.
ENDCLASS.
CLASS zcl_paralell1 DEFINITION
PUBLIC
FINAL
CREATE PUBLIC .
PUBLIC SECTION.
TYPES ty_t_time TYPE STANDARD TABLE OF cl_abap_context_info=>ty_system_time WITH DEFAULT KEY.
INTERFACES if_abap_parallel.
METHODS get_time RETURNING VALUE(rt_time) TYPE ty_t_time.
METHODS get_wp_number RETURNING VALUE(rv_wp_number) TYPE char3.
PROTECTED SECTION.
PRIVATE SECTION.
DATA gt_time_1 TYPE TABLE OF cl_abap_context_info=>ty_system_time.
DATA gv_wp_number TYPE char3.
ENDCLASS.
CLASS zcl_paralell1 IMPLEMENTATION.
METHOD if_abap_parallel~do.
DO 3 TIMES.
WAIT UP TO 2 SECONDS.
DATA(lv_system_time) = cl_abap_context_info=>get_system_time( ).
APPEND lv_system_time TO gt_time_1.
ENDDO.
gv_wp_number = '001'.
ENDMETHOD.
METHOD get_time.
rt_time = gt_time_1.
ENDMETHOD.
METHOD get_wp_number.
rv_wp_number = gv_wp_number.
ENDMETHOD.
ENDCLASS.
CLASS zcl_paralell2 DEFINITION
PUBLIC
FINAL
CREATE PUBLIC .
PUBLIC SECTION.
TYPES ty_t_time TYPE STANDARD TABLE OF cl_abap_context_info=>ty_system_time WITH DEFAULT KEY.
INTERFACES if_abap_parallel.
METHODS get_time RETURNING VALUE(rt_time) TYPE ty_t_time.
METHODS get_wp_number RETURNING VALUE(rv_wp_number) TYPE char3.
PROTECTED SECTION.
PRIVATE SECTION.
DATA gt_time_2 TYPE TABLE OF cl_abap_context_info=>ty_system_time.
DATA gv_wp_number TYPE char3.
ENDCLASS.
CLASS zcl_paralell2 IMPLEMENTATION.
METHOD if_abap_parallel~do.
DO 3 TIMES.
WAIT UP TO 2 SECONDS.
DATA(lv_system_time) = cl_abap_context_info=>get_system_time( ).
APPEND lv_system_time TO gt_time_2.
ENDDO.
gv_wp_number = '002'.
ENDMETHOD.
METHOD get_time.
rt_time = gt_time_2.
ENDMETHOD.
METHOD get_wp_number.
rv_wp_number = gv_wp_number.
ENDMETHOD.
ENDCLASS.
DATA(lo_parallel) = NEW cl_abap_parallel( ).
DATA(lo_instance_1) = NEW zcl_paralell1( ).
DATA(lo_instance_2) = NEW zcl_paralell2( ).
lo_parallel->run_inst(
EXPORTING
p_in_tab = VALUE #( ( lo_instance_1 ) ( lo_instance_2 ) )
IMPORTING
p_out_tab = DATA(lt_out_tab)
).
LOOP AT lt_out_tab ASSIGNING FIELD-SYMBOL(<ls_out_tab>).
IF <ls_out_tab>-inst IS INSTANCE OF zcl_paralell1.
lo_instance_1 = CAST #( <ls_out_tab>-inst ).
out->write( 'System time for instance 1:' ).
LOOP AT lo_instance_1->get_time( ) ASSIGNING FIELD-SYMBOL(<lv_instance_1>).
out->write( <lv_instance_1> ).
ENDLOOP.
out->write( |WP number: { lo_instance_1->get_wp_number( ) }| ).
ENDIF.
IF <ls_out_tab>-inst IS INSTANCE OF zcl_paralell2.
lo_instance_2 = CAST #( <ls_out_tab>-inst ).
out->write( 'System time for instance 2:' ).
LOOP AT lo_instance_2->get_time( ) ASSIGNING FIELD-SYMBOL(<lv_instance_2>).
out->write( <lv_instance_2> ).
ENDLOOP.
out->write( |WP number: { lo_instance_2->get_wp_number( ) }| ).
ENDIF.
ENDLOOP.
CLASS ztest_class DEFINITION
PUBLIC
FINAL
CREATE PUBLIC .
PUBLIC SECTION.
INTERFACES: if_oo_adt_classrun.
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
CLASS ztest_class IMPLEMENTATION.
METHOD if_oo_adt_classrun~main.
out->write( 'Hello world!' ).
ENDMETHOD.
ENDCLASS.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
12 | |
10 | |
7 | |
5 | |
4 | |
4 | |
3 | |
3 | |
2 | |
2 |