Friday, 18 October 2019

A Neanderthal guide to configuration of Fiori my Inbox App with SAP business workflow

This article contains information about the configuration of Fiori my inbox App with workflow on a gateway central hub deployment.

In a standard work item that appears in your inbox, there is always a workflow id and step id assigned to it. This workflow id and step id when viewed in T-Code SWDD appears as a workflow activity with a task id assigned to the workflow activity. This task id should be noted as it will be later maintained in the scenario definition on the front end server.

Backend configuration


For the backend configuration, we would look to maintain both the workflow id and step id for the standard workflow we want to configure for fiori. In this case we would be configuring workflow for purchase requisition. Sometimes we might not have the workflow id but have the business object (BOR) instead. If this is the case we could execute transaction SWE2 to search for the corresponding workflow id.

Go to transaction SWDD and enter the workflow template to view its steps. We can then identify the workflow activities we need to find it step id. For some instances there might be different work flow processes with it corresponding sub workflow. The sub workflow will have activities with its corresponding task id also.

SAP ABAP Tutorial and Material, SAP ABAP Online Exam, SAP ABAP Learning, SAP ABAP Study Materials

Transaction SWDD showing the Purchase Requisition workflow template

We will need to navigate to Maintain Task Names and Decision Options via T-Code SPRO. This where the workflow id and step id for the workflow activity will be maintained and be given the ability to approve or reject using the decision keys. For the scenario where there is a workflow process and  its sub workflow, the workflow id and step id for both  workflow process and  its sub workflow would be maintained in Task names and decision option. The sub workflow activities would be further maintained with decision keys i.e (Approve, reject or release).

SAP ABAP Tutorial and Material, SAP ABAP Online Exam, SAP ABAP Learning, SAP ABAP Study Materials

Navigation to Task names and Decision Options via SPRO

Enhancement Implementation for Workflow


To be able to handle the approval for every work item in my fiori inbox we must be able to somehow access workflow id and step id of the work item. And to achieve this, we would create an enhancement implementation in an enhancement spot of name /IWWRK/BADI_WF_BEFORE_UPD_IB. This  enhancement spot reads release codes and FIORI rejection and approval comments.

For Implementation – Make sure to add correct filter values

For below we have WS90100004 (PR Approval Workflow) with Step id 28 and 59 as decision tasks for different levels based on workflow logic.

WS90100006 and Task 5 is rejection workflow which triggers Rejection Notification to the PR creator.

SAP ABAP Tutorial and Material, SAP ABAP Online Exam, SAP ABAP Learning, SAP ABAP Study Materials

Enhancement implementation created in the enhancement spot

“Enter the code shown in between the Method and End Method.
"1. Variables
DATA abs_object TYPE swr_obj_2.
DATA abv_retcode TYPE sy-subrc.
DATA abt_container TYPE TABLE OF swr_cont.
DATA abs_container_line TYPE swr_cont.
DATA abt_msg_lines type sapi_msg_lines.
DATA abt_msg_struc type sapi_msg_struc.
DATA FORMNUMBER TYPE SWXFORMABS-FORMNUMBER.
DATA abs_formabs TYPE swxformabs.

"2. Get Workitem Details
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            = abv_retcode
   LEADING_OBJECT_2       = abs_object
TABLES
*   OBJECTS                =
   MESSAGE_LINES          = abt_msg_lines
   MESSAGE_STRUCT         = abt_msg_struc
*   OBJECTS_2              =
          .
"3. Get Document Number
MOVE abs_object-instid TO formnumber.

*4. Get Decision Based on the Workitem ID
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                    = abv_retcode
*   IFS_XML_CONTAINER              =
*   IFS_XML_CONTAINER_SCHEMA       =
TABLES
   SIMPLE_CONTAINER               = abt_container
   MESSAGE_LINES          = abt_msg_lines
   MESSAGE_STRUCT         = abt_msg_struc
*   SUBCONTAINER_BOR_OBJECTS       =
*   SUBCONTAINER_ALL_OBJECTS       =.

"5. Get Application Data
select single * from swxformabs into abs_formabs where formnumber = formnumber.

"6. Set Decision Value
CASE iv_decision_key.
  WHEN 0001. "Approved
    abs_container_line-value = 'A'.
    abs_formabs-procstate = 'A'.
  WHEN 0002. "Rejected
    abs_container_line-value = 'R'.
    abs_formabs-procstate = 'R'.
ENDCASE.

"7. Set Result Value Based on Decision
abs_container_line-element = '_WI_RESULT'.
"Update Container rows
MODIFY abt_container INDEX 3 FROM abs_container_line TRANSPORTING value.”
“8. 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                        = abv_retcode
TABLES
   SIMPLE_CONTAINER                   = abt_container
   MESSAGE_LINES          = abt_msg_lines
   MESSAGE_STRUCT         = abt_msg_struc
   .

"9. Update App Data
abs_formabs-approvdate = sy-datum.
abs_formabs-approvby = sy-uname.
update swxformabs from abs_formabs.

*10. 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                     = 
“8. 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                        = abv_retcode
TABLES
   SIMPLE_CONTAINER                   = abt_container
   MESSAGE_LINES          = abt_msg_lines
   MESSAGE_STRUCT         = abt_msg_struc
   .

"9. Update App Data
abs_formabs-approvdate = sy-datum.
abs_formabs-approvby = sy-uname.
update swxformabs from abs_formabs.

*10. 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                     = 
“abv_retcode
*   NEW_STATUS                      =
TABLES
*   SIMPLE_CONTAINER                = abt_container
   MESSAGE_LINES          = abt_msg_lines
   MESSAGE_STRUCT         = abt_msg_struc
   .

*11. 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                   = abv_retcode
*   NEW_STATUS                    =
TABLES
   MESSAGE_LINES          = abt_msg_lines
   MESSAGE_STRUCT         = abt_msg_struc”

FRONT END CONFIGURATION


For this configuration we would need to  check the task id in the backend and maintain it in the scenario definition in the front end.

SAP ABAP Tutorial and Material, SAP ABAP Online Exam, SAP ABAP Learning, SAP ABAP Study Materials

Navigation to scenario definition via SPRO

SAP ABAP Tutorial and Material, SAP ABAP Online Exam, SAP ABAP Learning, SAP ABAP Study Materials

Create PR_RELEASE scenario identifier

Make sure to use the System Alias as assigned to the TaskProcessing Service in transaction /iwfnd/maint_services and assign it to Custom Release Task, in our case its TS90100009.

SAP ABAP Tutorial and Material, SAP ABAP Online Exam, SAP ABAP Learning, SAP ABAP Study Materials

Remember the task id from the workflow activity in the backend, the task definition for scenario is where we would maintain the task id.

This completes the configuration of Fiori my inbox App for Purchase requisition.

1 comment:

  1. If you are looking for the SAP C_HRHPC_1905 Dumps Visit Exams4sure once. Exams4sure is the best and authentic place to prepare and pass the exam on the first attempt. There are a lot of website providing C_HRHPC_1905 Questions Answers but no one gives you authentic C_HRHPC_1905 Practice Questions. Exams4sure experts team are highly qualified and compiled best C_HRHPC_1905 Study Material for your Success. Try our C_HRHPC_1905 Braindumps PDF demo free. Teachers recommended Exams4sure for the better exam results. We never compromised our quality. Get 40% discount today visit us to avail this offer.

    Why Choose Exams4sure:

    3 Months Free Updates
    World-wide Valid
    Real Exam Simulation
    40% Discount
    C_HRHPC_1905 Real Exam Questions
    100% Client Satisfaction
    24/7 Customer Support

    Get your C_HRHPC_1905 Dumps today.

    ReplyDelete