cancel
Showing results for 
Search instead for 
Did you mean: 

How to handle Workflow in the userexits

durgaprasanth_vemula
Participant
0 Kudos

1) I had used the user Decision(TS00008267) with the two Decision Text

a)sale view reqd 

b)sale view not reqd

And also i created a Agent by using Rule in this User Decision.So that  workitems will trigger.

Based on the above two Decision Text two lines will be generated i.e One line is for sale view reqd and another line is for

sale view not reqd

1)In the sales view Req - I created a Activity i.e (custom ) where it opens the MM01 tcode.

2)sale view not reqd - I created a process Control by putting the funciton Cancel Workitem

this type of design i had done for all the views in MM01 by one after and onfter in SWDD

Based on the above Sales Agent will get the workitem and he logs the tcode SBWP tcode and execute the workitem and he will click on button 'Sales View req' and it open the MM01 tcode and once he creates the Sales View  and it goes to next agent to the Storage Agent and he creates Storage Agent and this will continue all the views in MM01 and I had designed in SWDD by created Workflow. And it is working fine.

Now the new requirment is the workitem comes to SalesAgent i.e in his inbox but SalesAgent will not log in SBWP tcode and but direcly navigates to MM01 and creates the Sales View but it should trigger the workflow and could you please tell me how to handle this

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Your approval step should have a "terminating" event. Terminating events are used when users process objects directly in their transactions and not through SBWP. So, when a Sales agent is created in MM01, an event that terminates the current approval step should be triggered.

durgaprasanth_vemula
Participant
0 Kudos

If i implement this Terminating Event in the Approval Step i.e User Decision step and it will work both i.e SBWP and asl well as directly navigating in MM01

I created a Event Salesviewcreate(Custom event) in SWO1 and in the userexit i added the code

   CALL FUNCTION 'SAP_WAPI_CREATE_EVENT'
    EXPORTING
      OBJECT_TYPE             =  'ZBS1001006'
      OBJECT_KEY              =  objkey
      EVENT                   =  'SALESVIEWCREATED'
     COMMIT_WORK             = 'X'
*     EVENT_LANGUAGE          = SY-LANGU
*     LANGUAGE                = SY-LANGU
*     USER                    = SY-UNAME
*     IFS_XML_CONTAINER       =
*   IMPORTING
*     RETURN_CODE             =
*     EVENT_ID                =
*   TABLES
*     INPUT_CONTAINER         =
*      MESSAGE_LINES           = lt_msglines
*     MESSAGE_STRUCT          =
            .
  if sy-subrc eq 0.
    commit work.
     endif.

I added this Event 'SALESVIEWCREATED'  in my Activity under the Terminating Event.

when ever i hit save button in MM01 and  it  Navigates to function module 'SAP_WAPI_CREATE_EVENT' which i added in Userexit and it will come out from MM01 with out Saving it .

After this function module executed it will not be saving what i added in MM01

sudhahar_ramachandran
Active Participant
0 Kudos

Do not put commit work as 'X'. check if its creating the event. else, try calling this event triggering WAPI only in update task.

durgaprasanth_vemula
Participant
0 Kudos

The Requirment is whether Agent logged in SBWP and execute the workitem and another one he directly logged into MM01 in both scenarios it should work

1.When the Agent logged in the SBWP transaction and executes the workitem and navigates to the MM01 and created the sales View and hit save button and i used the below code in the UserExit

   CALL FUNCTION 'SAP_WAPI_CREATE_EVENT'
  EXPORTING
    OBJECT_TYPE             = 'ZBS1001006'
    OBJECT_KEY              =  objkey
    EVENT                   = 'SALESVIEWCREATED'
*   COMMIT_WORK             = 'X'
*   EVENT_LANGUAGE          = SY-LANGU
   LANGUAGE                = SY-LANGU
   USER                    = SY-UNAME
*   IFS_XML_CONTAINER       =
* IMPORTING
*   RETURN_CODE             =
*   EVENT_ID                =
TABLES
*   INPUT_CONTAINER         =
    MESSAGE_LINES           = SWR_MESSAG1
*   MESSAGE_STRUCT          =

and when execution comes to this function module in the Userexit of MM01 and when this function module is executed and MM01 is not getting saved.but when i look at the SWEL it is giving as Terminating Event is triggered.but My MM01 transaction is not getting saved.it is coming out from MM01 with out saving it .

2.Now Agent logged directly to MM01 and try to create the SalesView and hit save button and after executing of function module and SWR_MESSAG1 is showing as "Event created - no receiver found"

and i did not put commit as 'X'

And also could you please tell me what is  WAPI only in update task. how to handle this

durgaprasanth_vemula
Participant
0 Kudos

Now the issue is only  if the Agent logged directly to MM01

Now Agent logged directly to MM01 and try to create the SalesView and hit save button and after executing of function module and SWR_MESSAG1 is showing as "Event created - no receiver found"

I had resolved the problem by loging to SBWP and executing the workitem and i am able to save the MM01 transaction.

resolved by keeping as    COMMIT_WORK   = space

CALL FUNCTION 'SAP_WAPI_CREATE_EVENT'
  EXPORTING
    OBJECT_TYPE             = 'ZBS1001006'
    OBJECT_KEY              =  objkey
    EVENT                   = 'SALESVIEWCREATED'
   COMMIT_WORK             = space
*   EVENT_LANGUAGE          = SY-LANGU
   LANGUAGE                = SY-LANGU
   USER                    = SY-UNAME
*   IFS_XML_CONTAINER       =
* IMPORTING
*   RETURN_CODE             =
*   EVENT_ID                =
TABLES
*   INPUT_CONTAINER         =
    MESSAGE_LINES           = SWR_MESSAG1
*   MESSAGE_STRUCT          =

Now Agent logged directly to MM01 and try to create the SalesView and hit save button and after executing of function module and SWR_MESSAG1 is showing as "Event created - no receiver found"

anjan_paul
Active Contributor
0 Kudos

Hi,

Use the fm SWE_EVENT_CREATE_FOR_UPD_TASK to trigger event

durgaprasanth_vemula
Participant
0 Kudos

When the Agent logged directly in MM01 and it is not working.If the Agent logged through SBWP and it is working fine

Agent logged directly in MM01 and getting  "Event created - no receiver found"

anjan_paul
Active Contributor
0 Kudos

Hi,

Which fm you are using to trigger event.