Skip to Content
avatar image
Former Member

Who's the user logged in

I find this query:

SELECT T0.U_NAME FROM OUSR T0 WHERE T0.INTERNAL_K = $[USER]

but when I go to save it on a user query SAP traslate the query in :

SELECT T0.U_NAME FROM OUSR T0 WHERE T0.INTERNAL_K = 1


I need the information of the user logged in SAP becouse of depending of the user I need to change a result of the user query.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    Oct 25, 2016 at 05:02 AM

    Hi Ercole

    You can use following query to get current user for your query, and then use the value in variable for your query. Also the translation will return value because value of INTERNAL_K for manager is 1. It will change according to logged in user.

    Just save below query in query manager and execute query via Tools>Queries>User queries

    declare @User as nvarchar(50)
    set @User =(SELECT T0.U_NAME FROM OUSR T0 WHERE T0.INTERNAL_K = $[USER])

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 24, 2016 at 12:20 PM

    You can use @variable function to get user who logged in. Use @variable('BOUSER') at universe level.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 24, 2016 at 03:27 PM

    Thank you but I have not undestand how to use the "@variable('BOUSER')" in a user query.

    I try this but doesn't work : SELECT T0.U_NAME FROM OUSR T0 WHERE T0.INTERNAL_K = @variable('BOUSER')

    I attached an .JPG to show you what I have done.

    Thank you in advance.cattura.jpg

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Nov 02, 2016 at 09:05 AM

    Hello Gaurav, thank You a lot. The problem is solved exactly.

    Can you say me where I can find the list of VARIABLE that I can use in user query of SAP.

    Add comment
    10|10000 characters needed characters exceeded