cancel
Showing results for 
Search instead for 
Did you mean: 

send message to sbwp

06-05-2009 6:32 AM
3306 views 24 comments Go to solution
0 Likes
SAP Managed Tags
Subscribe

Dear Experts,

while saving a transaction(t-code),i have to generate a message to sbwp of the user with 3 radio buttons(3 managers) and user will select particular manager in sbwp and submit.

on submission, the message will go to the particular manager and manager should have the option of accept or reject.if he selects accept, then a message should be sent to other two managers that it was accepted.If Reject was selected then a mail needs to be sent to the user that it was rejected.

Now can anyone tell me,how should i do this.

Kind Regards

Sajid

0 Likes

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Likes

This can be accomplished by ABAP Program only just try to find an User Exit and put the coding there.

Thanks

Arghadip

Former Member
0 Likes

Dear Experts,

I have to do this for F-47 tcode and i have found the appropriate userexit where i have to put my code.

Now what i want to know is,what code should i write over there to accomplish my task.

Kind Regards

Sajid.

Former Member
0 Likes

Hi

For F-47 , you can go for enhancement spot , and follow the logic told before.

If u need the correct Exit , then try the Link : [F-47 exit ||]

vijy_mukunthan
Active Contributor
0 Likes

Hi Sajid

You can do this workflow flow itslef no need to go to EXIT. When ever some thing is done in F-47 trigger a workflow with a custom screen presenting the details of the 3 managers. When the initiator selects the any manager presented on the screen. You capture which manager he is selecting based on that create a user decision step with appropratiate manager. Do the same process for all.

Regards

vijay

Former Member
0 Likes

Dear Experts,

I have found the enhancement spot, and i have written the following code to call the workflow

CALL FUNCTION 'SAP_WAPI_CREATE_EVENT'
  EXPORTING
    OBJECT_TYPE             = 'BKPF'
    OBJECT_KEY              =  var_obj_key      "'100000140000152009'
    EVENT                   = 'CREATED'
*   COMMIT_WORK             = 'X'
*   EVENT_LANGUAGE          = SY-LANGU
*   LANGUAGE                = SY-LANGU
   USER                    = SY-UNAME
*   IFS_XML_CONTAINER       =
 IMPORTING
   RETURN_CODE             = RETURN_CODE
   EVENT_ID                = EVENT_ID
* TABLES
*   INPUT_CONTAINER         =
*   MESSAGE_LINES           =
*   MESSAGE_STRUCT          =          .

In my workflow, i have defined a container Receiver to whom the mail should be sent.I have binded this with &_EVT_RECEIVER_ID& in the start conditions Create Event of BKPF object.

In the above code i also need to specify to which manager(Reciever) the mail should be sent. How can i specify that?

I suppose i have to pass the values in input_contyainer.But how can i do it (any sample code)?

Regards

Sajid

Edited by: shaik sajid on Jun 8, 2009 7:02 AM

Former Member
0 Likes

You have to populate the Manager's User Id in the INPUT CONTAINER parameter.

Additionally I think it would be a better idea to use SAP_WAPI_START_WORKFLOW Function module since you are using enhancement point to trigger workflow

Check this code for Event.

Please note that in your requirement you have to create custom event and create a parameter Manager which is multiline and then use it.

FUNCTION zwf_process_trip.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     VALUE(I_EMP_NUMBER) TYPE  PERNR_D
*"     VALUE(I_EMP_TRIP) TYPE  REINR
*"----------------------------------------------------------------------
  INCLUDE <cntn01> .

  DATA:i_emp_details TYPE STANDARD TABLE OF p0001,  "Employee Details
       wa_request    TYPE p0001,                    "Workarea for Employee details
       v_country_grp TYPE molga,                    "Country SubGrouping
       v_object_key  TYPE sweinstcou-objkey.        "Key for the buisness object ZWOBUSTRIP

  CONSTANTS: c_bo_trip     TYPE swo_objtyp VALUE 'ZWOBUSTRIP',
             c_event_trip  TYPE swo_event  VALUE 'TripCreate',
             c_infy_type_1 TYPE infty      VALUE '0001'.

* Event Container declaration
  swc_container i_event_cont.
  swc_create_container i_event_cont.

* Reading the INFO TYPE 0001 to obtain the
* Employee details
  CALL FUNCTION 'HR_READ_INFOTYPE'
    EXPORTING
      pernr           = i_emp_number
      infty           = c_infy_type_1
      begda           = sy-datum
      endda           = sy-datum
    TABLES
      infty_tab       = i_emp_details
    EXCEPTIONS
      infty_not_found = 1
      OTHERS          = 2.

* SY-SUBRC check is not required as the error
* handelling will be done by WorkFlow rule
* resolution.

  CLEAR wa_request.
  READ TABLE i_emp_details INTO wa_request INDEX 1.

  IF sy-subrc = 0.

*   Retrieving the Country SubGrouping for the employee
    SELECT SINGLE molga
      FROM t001p
      INTO v_country_grp
     WHERE werks = wa_request-werks
       AND btrtl = wa_request-persk.

  ENDIF.

* Sending the relevant data to event container

  swc_set_element i_event_cont 'EmpId'     i_emp_number.
  IF sy-subrc <> 0.
* No Processing needed.
  ENDIF.

  swc_set_element i_event_cont 'PersonnelArea'    wa_request-werks.
  IF sy-subrc <> 0.
* No Processing needed.
  ENDIF.

  swc_set_element i_event_cont 'CountryGrouping' v_country_grp.
  IF sy-subrc <> 0.
* No Processing needed.
  ENDIF.

  swc_set_element i_event_cont 'EmpSubGrp'       wa_request-persk.
  IF sy-subrc <> 0.
* No Processing needed.
  ENDIF.

  swc_set_element i_event_cont 'EmpTripId'       i_emp_trip.
  IF sy-subrc <> 0.
* No Processing needed.
  ENDIF.
* Raising the event to trigger the workflow
  v_object_key = i_emp_number.

  CALL FUNCTION 'SWE_EVENT_CREATE'
    EXPORTING
      objtype           = c_bo_trip
      objkey            = v_object_key
      event             = c_event_trip
    TABLES
      event_container   = i_event_cont
    EXCEPTIONS
      objtype_not_found = 1
      OTHERS            = 2.

  IF sy-subrc <> 0.
* No Processing needed.
  ENDIF.


  COMMIT WORK.

ENDFUNCTION.

Thanks

Arghadip

Edited by: Arghadip Kar on Jun 8, 2009 7:13 AM

Edited by: Arghadip Kar on Jun 8, 2009 7:14 AM

Edited by: Arghadip Kar on Jun 8, 2009 7:16 AM

surjith_kumar
Active Contributor
0 Likes

Hi,

The Function Module (SAP_WAPI_CREATE_EVENT) which you used is correct.

Check this [article|https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/e038cc2d-0cde-2a10-e28e-f50025578112].

Regards,

Surjith

Former Member
0 Likes

Dear Arghadip Kar,

thanks for the code.But still there is a small problem.

Workflow is getting started (SBWP->outbox->started workflows) but there is error in the graphic that no agent with status as READY.

Actually i am passing the managers username (to which the mail id should be sent) through the function moduleSAP_WAPI_CREATE_EVENT.

swc_set_element i_event_cont 'RECEIVER' var_receiver.

Receiver is a container in my workflow.

When the workflow executes, a mail will be sent to the manager (Receiver).For this in the user decision step, i have kept the Expression as &RECEIVER&. In the start condition of the business object BKPF i have binded &RECEIVER& with &_EVT_RECEIVER_ID&.

I think in workflow i did wrong somewhere.Can u pls tell me how to correct it as i am new to workflow.

Kind Regards

Sajid

surjith_kumar
Active Contributor
0 Likes

Hi,

but there is error in the graphic that no agent with status as READY

In this expression

&RECEIVER&

you are getting the approver right.

Prefix you have to concatenate with 'US'.

e.g. User id is "JOHN'

assign it as "USJOHN"

Regards,

Surjith

Former Member
0 Likes

Dear Surjith,

I had done that,but still same error.

No Agent.

Regards

Sajid

Former Member
0 Likes

Please check with this FM

SAP_WAPI_WORKITEM_RECIPIENTS

whether any user is assigned to workitem. Please check the agent icon in Workflow Log.

EVT_RECEIVER should be binded with WF_INITIATOR.

Thanks

Arghadip

Former Member
0 Likes

Dear Arghadip,

I executed the FM and No Agents found.

EVT_RECEIVER should be binded with WF_INITIATOR.

I have binded EVT_RECEIVER with RECEIVER so that i have values of manager (Reciever) and user who requested (initiator) so that mail will be sent to manager for user decision and then on his rejection a mail will be sent to initiator.

Now if i bind EVT_RECEIVER with WF_INITIATOR then how will i be able to know who triggered this.

Regards

Sajid

Former Member
0 Likes

Check whether the Task is General Or not. Please go to the respective agent assignment step and change the Task attribute to General.

Thanks

Arghadip

Former Member
0 Likes

Dear Arghadip,

I executed the FM and No Agents found.

EVT_RECEIVER should be binded with WF_INITIATOR.

I have binded EVT_RECEIVER with Receiver so that i have values of both the Manager(Receiver) and Requester (Initiator) because Manager gets a mail for user decision and then on rejection the reuqester will get a mail that it was rejected.

Now if EVT_RECEIVER should be binded with WF_INITIATOR. then how will i know the requestor to whom the mail should be sent.

Regards

Sajid

Former Member
0 Likes

Sorry I was wrong you should bind EVT_CREATOR to WF_INITIATOR from event to workflow. Now can you please tell me what actualy is the issue you are facing.

Thanks

Arghadip

Former Member
0 Likes

The task is of type Generic decision task

Regards

Sajid

Former Member
0 Likes

Please refresh the buffer from SWU_OBUF and then test this issue.

Thanks

Arghadip

Former Member
0 Likes

Dear Arghadip,

the actual issue is, my workflow is unable to determine the reciever.

can u pls send me ur mail id to my id which is in my profile so that i will send u the screen shots of my workflow and may be u can find the exact problem.

Kind Regards

Sajid

Former Member
0 Likes

If the workflow is unable to find the receiver check what is the value in the workflow container. Check whether the binding is done properly. I have some question is it a send mail step or a dialog task that is not being sent.

Thanks

Arghadip

Former Member
0 Likes

Dear Arghadip,

It is a user Decision step (approve / reject) and in its expression i have given &Receiver& and before that in the start conditions i have binded Receiver properly with &_EVT_RECEIVER_ID& of the business object BKPF create event. In my program while trigerring the workflow, i am sending to the container the receiver name.

CONCATENATE 'US' var_receiver into var_receiver.
swc_set_element i_event_cont '_EVT_RECEIVER_ID' var_receiver.

Regards

Sajid

Former Member
0 Likes

I think the EVTRECEIVER_ID will not be populated by the value that you are providing. This is a standard container element and gets populated with the Event receiver which is a Workflow Template. I think the value(Manager) needs to be determined inside the Wflow design.Just write a method and implement this in your Workflow

Thanks

Arghadip

Answers (3)

Answers (3)

Former Member
0 Likes

Hi,

If its a Std SAP Tcode, Then find the appropraite exit/enhancement spot and trigger the WorkFlow using

SAP_WAPI_START_WORKFLOW passing the Radio button selected .

In one of the Steps, call a function to find the 3 managers .

Send USER DECISION to selected manger .

Based on decision , send mail to other 2 mangers/user.

If Custom generated Tcode, then do the above in your PAI.

Hope u find this useful

surjith_kumar
Active Contributor
0 Likes

Hi,

 while saving a transaction(t-code),i have to generate a message to sbwp 
of the user with 3 radio buttons(3 managers) and user will select particular 
manager in sbwp and submit.

For this you have to create a custom Webdynpro Screen

on submission, the message will go to the particular manager and manager
 should have the option of accept or reject.if he selects accept, then a message 
should be sent to other  two managers that it was accepted.If Reject was selected
 then a mail needs to be sent to the  user that it was rejected.

For this you can Create a User Decision having two branches (one for Approved, another for Rejected), below the Approved & Rejection branch create the 'send mail' step with the respective message.

Regards,

Surjith

aditya_avadhanula
Participant
0 Likes

hi

are you talking about transation in general or any particular set of transaction ??