cancel
Showing results for 
Search instead for 
Did you mean: 

How to compare User name in PO Chnage

Former Member
0 Kudos

Hi Friends,

I have scenario is that..When ever PO changed by somebody, I want to compare the Users that, if PO creator and changer both are different then i want to send a mail to creator..

I have developed the workflow..by taking two container elements, one for Creator and other for Changer..

In binding EVENT_creator is always is USSAPUSER. but i want only SAPUSER.. Where do i get???

Naveen

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Thanks for your replies.

compared it by sy-uname with orginal user.

bpawanchand
Active Contributor
0 Kudos
I have developed the workflow..by taking two container elements, one for Creator and other for Changer..
In binding EVENT_creator is always is USSAPUSER. but i want only SAPUSER.. Where do i get???

It is right that always in the WFINITIATOR will have the US along with the user name because US is the OBJECT type and its OBJID is username so either in event creator or WFinitiator in both container the object type and its OBJID is concatenated and stored.

you can easily get the Changed user too, when ever workitem is executed by any user then his user name is stored in the WIACTUAL_AGENT event in this the value is stored along with US

so try to get the workitem actual agent into the workflow conatiner now by using Container OPeration step compare both the user.

IF you try to import WIACTUAL_AGENT into WF then i think there is no need to remove the US from the event creator or wf initiator.

simply you can compare WFINITIATOR eq WIACTUAL_AGENT

NOte WIACTUAL_AGENT will not be in teh workflow container so decalre a element in teh workflow and make appropriate binding beteween teh wrktiem

surjith_kumar
Active Contributor
0 Kudos

Hi,

For your Requirement you can control via BAdi.

1) While saving the PO check the current user id and Previous User id are same or not

2) If NOT same using the function Module SO_NEW_DOCUMENT_SEND_API1 you can send a mail to creator

3) Other wise, you can also display a error message if the another person change the PO

Regards,

Surjith

vijy_mukunthan
Active Contributor
0 Kudos

Hi Naveen

For comparing the users do this way

SWC_GET_ELEMENT CONTAINER 'WF_INITIATOR' WF_INITIATOR.
 SWC_GET_ELEMENT CONTAINER 'CHANGER'      CHANGER.

WF_INITIATOR = WF_INITIATOR+2(10).
CHANGER       = CHANGER+2(10).

IF WF_INITIATOR = CHANGER.

 WRITE THE LOGIC 

ELSE.

write the logic.

Endif.

Regards

vijay

former_member193382
Active Contributor
0 Kudos

Hi Naveen,

You can do this as below.

You will have the user name who changed the PO in workflow container WF_INITIATOR.

And the user who created the PO his name will be available in the PO table field ERNAM.

You can get this name through a custom attribute in workflow and you will then be able to compare it.

You can pass the value USSAPUSER to your method container and there you can suppress US and send SAPUSER to workflow container.

Hope it helps.

Regards,

Raj

Former Member
0 Kudos

Hi Raj,

Thanks for your reply... Can i know how to suppress the 'US'. and how to pass the value USSAPUSER to method.. can u explain briefly about this.. I have done the rest of the scenario.

Naveen

former_member193382
Active Contributor
0 Kudos

Hi,

As you said, you get the value USSAPUSER in Event_Creator. You bind this to workflow container WFINITIATOR. Now in a task, you create another container similar to WFINITIATOR and do the binding between the workflow container & task container. Now read this container in your method container using SWC_GET_ELEMENT CONTAINER 'wf_initiator' WF_INITIATOR.

Then use INITIATOR = WF_INITIATOR2(7). (Not sure about the syntax. Please check).

Now value in INITIATOR will be SAPUSER.

Pass this to your task container using

SWC_SET_ELEMENT CONTAINER 'INITIATOR' INITIATOR.

Similarly pass it from task to workflow container.

Regards,

Raj