...
In this method, you can define the ABAP logic to retrieve the required details from the SAP object that needs to be passed to OneList.
Method Parameters
Parameter Type | Parameter Name | Description | Data Type |
---|---|---|---|
Importing | IT_TASK_ID | OneList Task ID being actioned (SAP workflow work item ID) | TT_OL_TASK_ID |
Exporting | ET_OBJ_DETAIL | Table of object details | /IQX/OL_TASK_DETAIL_TT |
Exception | /IQX/CX_ONELIST_ADAPTER | Raised exception during adapter execution |
...
Code Block |
---|
METHOD get_object_details. CONSTANTS: lc_classname TYPE swr_obj_2-typeid VALUE 'BUS2012', lc_catid TYPE swr_obj_2-catid VALUE 'BO'. DATA: ld_return_code TYPE sy-subrc, lw_leading_object_2 TYPE swr_obj_2, lt_objects_2 TYPE STANDARD TABLE OF swr_obj_2, ls_po_object TYPE /iqx/ol_task_detail_st, ls_po_detail TYPE /iqx/ol_purchase_order_st, ld_wi_number TYPE sww_wiid, ld_po_number TYPE bapiekko-po_number, ld_oid TYPE os_guid, ld_objkey TYPE swotobjid-objkey, ld_classname TYPE bapibds01-classname, ld_classtype TYPE bapibds01-classtype, ld_username TYPE username, ls_address TYPE bapiaddr3, lt_return TYPE STANDARD TABLE OF bapiret2. "Work item number ld_wi_number = it_task_id. "Get object attached to WorkItem CALL FUNCTION 'SAP_WAPI_GET_OBJECTS' EXPORTING workitem_id = ld_wi_number IMPORTING return_code = ld_return_code leading_object_2 = lw_leading_object_2 TABLES objects_2 = lt_objects_2. IF lw_leading_object_2 IS INITIAL. IF lines( lt_objects_2 ) > 0. DELETE lt_objects_2 WHERE catid <> lc_catid. READ TABLE lt_objects_2 INTO lw_leading_object_2 WITH KEY catid = lc_catid. ENDIF. ENDIF. CHECK lw_leading_object_2 IS NOT INITIAL. ld_po_number = lw_leading_object_2. "Get PO detail ls_po_detail = me->get_po_detail( id_po_number = ld_po_number ). "Only carry on IF PO details having data. CHECK ls_po_detail IS NOT INITIAL. "Get task header ls_po_object = me->get_task_header( id_wi_number = ld_wi_number ). "Set object Id ls_po_object-object_type = lw_leading_object_2-typeid. ls_po_object-object_id = lw_leading_object_2-instid. "Get requestor IF ls_po_detail-created_by IS NOT INITIAL. ld_username = ls_po_detail-created_by. CALL FUNCTION 'BAPI_USER_GET_DETAIL' EXPORTING username = ld_username IMPORTING address = ls_address TABLES return = lt_return. READ TABLE lt_return WITH KEY type = 'E' BINARY SEARCH TRANSPORTING NO FIELDS. IF sy-subrc <> 0. CONCATENATE ls_address-firstname ls_address-lastname INTO ls_po_object-requestor SEPARATED BY space. ENDIF. ENDIF. "Serialize po detail to JSON string ls_po_object-json = /iqx/cl_onelist_json_util=>data_to_json( ia_data = ls_po_detail ). "Get PO action ls_po_object-actions = me->get_po_action( ). "Get PO document attachments ld_objkey = ld_po_number. ld_classname = lc_classname. ld_classtype = lc_catid. ls_po_object-documents = me->get_bds_documents( id_classname = ld_classname id_classtype = ld_classtype id_objkey = ld_objkey ). "Return detail object et_obj_detail = ls_po_object. ENDMETHOD. |
Info | ||
---|---|---|
| ||
The object detail retrieved from SAP should be serialized into a JSON string which gets passed back to OneList. It is important that the OneList configuration is set up to consume and deserialize the JSON structure accordingly. |