Skip to Content

Fiori MyInbox Shopping Cart Approve/Reject Functionality

Hi Experts,

We configured MyInbox in front end(GATEWAY) and able to see the MyInbox in web.

We added 'Approve/Reject' buttons for Shopping Cart with

Workflow ID WS40000017 and StepID 0000000211 and we are able to see the buttons.

In the Back End(SRM Client) implemented the badi /IWWRK/BADI_WF_BEFORE_UPD_IB

with below code

DATA ls_object TYPE swr_obj_2.
DATA lv_objtype TYPE swr_struct-object_typ.
DATA lv_objkey TYPE swr_struct-object_key.
DATA lv_retcode TYPE sy-subrc.
DATA lt_container TYPE TABLE OF swr_cont.
DATA ls_container_line TYPE swr_cont.
DATA lt_msg_lines TYPE sapi_msg_lines.
DATA lt_msg_struc TYPE sapi_msg_struc.

*GET workitem ID

CALL FUNCTION 'SAP_WAPI_GET_OBJECTS'
EXPORTING
workitem_id = is_wi_details-wi_id
LANGUAGE = SY-LANGU
USER = SY-UNAME
* BUFFERED_ACCESS = ‘X’
IMPORTING
* LEADING_OBJECT =
return_code = lv_retcode
leading_object_2 = ls_object
TABLES
* OBJECTS =
message_lines = lt_msg_lines
message_struct = lt_msg_struc
* OBJECTS_2 =

.


*Get decision result

CALL FUNCTION 'SAP_WAPI_READ_CONTAINER'
EXPORTING
workitem_id = is_wi_details-wi_id
* LANGUAGE = SY-LANGU
* USER = SY-UNAME
* BUFFERED_ACCESS = ‘X’
IMPORTING
return_code = lv_retcode
* IFS_XML_CONTAINER =
* IFS_XML_CONTAINER_SCHEMA =
TABLES
simple_container = lt_container
message_lines = lt_msg_lines
message_struct = lt_msg_struc
* SUBCONTAINER_BOR_OBJECTS =
* SUBCONTAINER_ALL_OBJECTS =

.

DATA: l_action TYPE bbp_wfl_action.

*SET decision VALUE TO the container.

CASE iv_decision_key.
WHEN 0001. "Approved
ls_container_line-value = 'A'.
l_action = 'F'. "Approver: In Approval Process: Approve Completely
WHEN 0002. "Rejected
ls_container_line-value = 'R'.
l_action = 'H'. "Approver: In Approval Process: Reject Completely
ENDCASE.

* “_WI_RESULT IS what the workflow keys off TO determine

* “which path TO follow – Approve OR REJECT path

ls_container_line-element = '_WI_RESULT'.

* “Modify the workflow’s container DATA – we are updating the row that
* “holds _WI_RESULT
MODIFY lt_container INDEX 3 FROM ls_container_line TRANSPORTING value.

* UPDATE container

CALL FUNCTION 'SAP_WAPI_WRITE_CONTAINER'
EXPORTING
workitem_id = is_wi_details-wi_id
language = sy-langu
actual_agent = sy-uname
do_commit = 'X'
* IFS_XML_CONTAINER =
* OVERWRITE_TABLES_SIMPLE_CONT = ‘ ‘
* CHECK_INBOX_RESTRICTION = ‘ ‘
IMPORTING
return_code = lv_retcode
TABLES
simple_container = lt_container
message_lines = lt_msg_lines
message_struct = lt_msg_struc
.

* Complete the task

CALL FUNCTION 'SAP_WAPI_WORKITEM_COMPLETE'
EXPORTING
workitem_id = is_wi_details-wi_id
actual_agent = sy-uname
language = sy-langu
* SET_OBSOLET = ‘ ‘
do_commit = 'X'
* DO_CALLBACK_IN_BACKGROUND = ‘X’
* IFS_XML_CONTAINER =
* CHECK_INBOX_RESTRICTION = ‘ ‘
IMPORTING
return_code = lv_retcode
* NEW_STATUS =
TABLES
* SIMPLE_CONTAINER = lt_container
message_lines = lt_msg_lines

message_struct = lt_msg_struc

.

*Set confirm

CALL FUNCTION 'SAP_WAPI_WORKITEM_CONFIRM'
EXPORTING
workitem_id = is_wi_details-wi_id
actual_agent = sy-uname
language = sy-langu
do_commit = 'X'
* CHECK_INBOX_RESTRICTION = ‘ ‘
IMPORTING
return_code = lv_retcode
* NEW_STATUS =
TABLES
message_lines = lt_msg_lines
message_struct = lt_msg_struc
.


DATA: l_swwwihead TYPE swwwihead,
l_sc_number TYPE crmt_object_id_db,
l_obj_guid TYPE bbp_guid.


SELECT SINGLE * INTO l_swwwihead
FROM swwwihead
WHERE wi_id = is_wi_details-wi_id.

l_sc_number = l_swwwihead-wi_text+21(11).

CALL FUNCTION 'BBP_PD_ALL_GET_OBJECT_GUID'
EXPORTING
iv_object_id = l_sc_number
iv_object_type = 'BUS2121'
IMPORTING
ev_object_guid = l_obj_guid
.

CALL FUNCTION 'BBP_PDH_WFL_DB_UPDATE'
EXPORTING
iv_object_id = l_sc_number
iv_object_type = 'BUS2121'
iv_action = l_action
* iv_obj_changed =
* iv_empl_review =
iv_workitem_id = is_wi_details-wi_id
iv_user = sy-uname
iv_guid = l_obj_guid
* IV_IN_DIALOG =
* IV_CHANGES_ACCEPT =
* IV_WF_OBJECT_SCENARIO =
* IV_USERTYPE =
.
DATA: l_subrc TYPE sy-subrc.
DATA: ls_return LIKE LINE OF ct_return.
IF l_subrc EQ 0.
ls_return-type = 'S'.
CONCATENATE 'Shopping Cart' l_sc_number 'has been approved' INTO ls_return-message SEPARATED BY space.
APPEND ls_return TO ct_return.
ELSEIF l_subrc <> 0.
CONCATENATE 'Shopping Cart' l_sc_number 'is not approved' INTO ls_return-message SEPARATED BY space.
ls_return-type = 'E'.
APPEND ls_return TO ct_return.
ENDIF.

But Shopping is not approved/Rejected. Instead there is an error as below


Please suggest if any thing I am missing in the code of BADI.

Regards,

Rafi

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

0 Answers