cancel
Showing results for 
Search instead for 
Did you mean: 

Make document owner as current login user.

Former Member
0 Kudos

Hi,

My client wants the document owner to always = the user who creates the document.

So, in employee master, I have each user assigned to a user id, but no sale employee attached.

In Document Owner field, I have the follwoing FMS that triggered by Customer No.

SELECT T0.[U_NAME] FROM OUSR T0 WHERE T0.UserId=$[User]

The problem is:

I have 2 users which were wrongly assigned sales employee and now I can not get rid of the Sales Employee.

Eg: Customer = C001 has Sales Person = Anthony.

In Employee Master, Anthony has sales employee assigned as himself. So, when Peter login to SAP, create Sales Order for Customer C001, the Document owner is showing 'Anthony'. I need to show 'Peter'.

Please advise.

I have tried using DTW, Employee Info template with following value, but receive error 'Method ~~~ object'.

RecordKey = 1

EmployeeID = 6 (as seen on Employee screen).

SalesPersonCode = /

Thanks for any help in advance.

Accepted Solutions (1)

Accepted Solutions (1)

former_member583013
Active Contributor
0 Kudos

After reading you message I have the following questions

This statement does not seem right "when Peter logs in to SAP, create Sales Order for Customer C001, the Document owner is showing 'Anthony'. I need to show 'Peter' "

When Peter logs in to SAP, SAP knows that the user is Peter and if you using the following SQL it should only fetch the name of Peter

SELECT T0.[U_NAME] FROM OUSR T0 WHERE T0.UserId=$[User]

Note: It is a good practice to use <b>T0.Internal_K=$[USER]</b> instead of T0.UserId

The problem is SAP expects the User Name to in the format <b>LastName, FirstName</b>

Try this

<i><b>SELECT T0.LastName + ', ' + T0.FirstName FROM [dbo].[OHEM] T0 WHERE T0.UserId = $[USER]</b></i>

Let me know if you need further help on this

Suda

Former Member
0 Kudos

Hi Suda,

Thanks for replying.

The problem occurs because in the Employee master, my client has wrong attached Peter as the sales employee for employee Peter.

Anyway, as confirmed with SAP support, I cannot blank out the Sales Employee in OHEM thru DTW with value "/".

The workaround is as follows:

1. Bring up the employee

2. Click Define New in Sales Person field

3. Press Delete button on the keyboard

4. Click the Update button.

5. The sales person in OHEM for that particular employee is now cleared.

Former Member
0 Kudos

Hey Suda, I've just been trying to make the document owner be the current login user, but the code in this thread triggers an error message.

I go to Query Generator and put <b>SELECT T0.[U_NAME] FROM OUSR T0 WHERE T0.UserId=$[User]</b> in, and it says 'incorrect syntax near User'

Can you please supply me with the right command to make the owner field (now called Document Creator in our system) automatically filled in as the person logged in?

Answers (1)

Answers (1)

former_member583013
Active Contributor
0 Kudos

Groovy,

The $[User] field gets a value when you have a Form Open. If you try to run it from a Query Window it cannot evaluate $[USER] and thats why the error.

The Query is Correct. Just save it and try to invoke it from within a Form and it will work.

Suda