cancel
Showing results for 
Search instead for 
Did you mean: 

List of Customers of current logged on user.

rashantha
Participant
0 Kudos

Hello I am trying to obtain a list of all customers based on the logged user.

I would like this in a query.

OUSR has the user_code, but what is the SAP call to see who the current user is.

SELECT T0.USER_CODE FROM OUSR T0 WHERE T0.USERID = $[USER]

Accepted Solutions (0)

Answers (3)

Answers (3)

rashantha
Participant
0 Kudos

SELECT T0.USER_CODE FROM OUSR T0 WHERE T0.USERID = $[USER]

So I found out that this only works if used directly from Tools > Queries > User Queries

or in FSM

If you pull Query from the Search or Execute from Query Manager it will not work.

Such a basic function missing imho in 9.3

LoHa
Active Contributor
0 Kudos

Hi Rashanta,

you r right. Meanwhile in V10 it is possible to start this (using $[USER]) from the Query Manager without going through the menu.

If you develop a FMS for a document, it is still necessary to click on the document and then go through the menu-path to your query to test it. Otherwise SAP is not able to fill the placeholder like $[$4.0.0] correctly in the query.

regards Lothar

LoHa
Active Contributor
0 Kudos

Yes, sure.

rashantha
Participant
0 Kudos

Error in Query.[Tuesday 2:20 PM] Rashantha De Silva

1). [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Incorrect syntax near 'USER'. 2). [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Statement 'Blanket Agreement' (OOAT) (s) could not be prepared.

LoHa
Active Contributor
0 Kudos

Hi Rashanta,

when you use

SELECT * FROM OUSR WHERE USERID = $[USER]

you'll get all infos stored in OUSR

The Name is

SELECT U_Name FROM OUSR WHERE USERID = $[USER]

regards Lothar

rashantha
Participant
0 Kudos

Does $[USER] grab the current logged in user?

rashantha
Participant
0 Kudos

Does this work in SAP B1 9.3?