cancel
Showing results for 
Search instead for 
Did you mean: 

SQL para mostrar o usuário logado no momento no B1

Former Member
0 Kudos

Oi

Estou precisando comparar em uma consulta SQL se o usuário que criou um determinado documento é o usuário que está logado no momento. Existe alguma forma no SQL, alguma função que mostre quem é o usuário logado no momento?

Obrigada,

Luciana Amorim

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Luciana, você consegue buscar o usuário atual usando a string: $[USER]

Answers (2)

Answers (2)

Former Member
0 Kudos

Boa tarde,

Testei a solução da nota número 672983 no B1 9.0 e não funcionou, alguém sabe como fazer?

Former Member
0 Kudos

Oi

A obtenção do usuário que está criando o documento é possível através uma busca formatada.

A nota SAP 672983 descreve isso.

Mas obter através de uma query quem esta logado numa estação isso não é possível uma vez que esse valor não se encontra numa tabela enquanto o usuário trabalha de uma forma global no sistema.

Paulo Calado

SAP Business One Forums Team

Former Member
0 Kudos

Paulo onde encontro essa nota?

fbio_bilicki
Active Contributor
0 Kudos

Boa noite, você encontra no link abaixo.

Guarde o link, só mude o numero da nota no final do link pra outras notas.

https://websmp206.sap-ag.de/sap/bc/bsp/spn/smb_searchnotes/display2.htm?note_langu=E&note_numm= 672983

Masss, infelizmente não funciona mais (testei no SAP 8.81 PL10 e agora uso o SAP 8.82 PL5).

Abs

Fabio.

========================================================================

Symptom


How can the current User or the current Posting Period be displayed in the application.

 

Cause


Consulting

 

Solution


In order to display the current User or\and Posting Period in a query the following syntax has to be used:

For the current User logged in :
$[user]
For the current Posting Period:
$[PERIOD]

With those indexes the system retrieves the internal key of the  requested value. In order to retrieve the descriptive value the following queries can be used:

For the current User:
SELECT T0.U_NAME FROM OUSR T0 WHERE INTERNAL_K = $[USER]

For the current Posting Period:
SELECT T0.Name FROM OFPR T0 WHERE T0.AbsEntry = $[PERIOD]

As the retrieve value is the current one the value returned is different if the query is run by different users or during different posting periods.
That is to say that if the query is first run when user A is logged then  the query result is A. If the query is run when user B is logged the result is B.
When the Posting Period changes the value retrieved is also changed.

Note: the above query cannot be executed from the Query Generator or Query Manager but from Tools-> Queries->User Queries.

 

Other terms


Formatted Search, FMS, User Queries, user, Posting Periods, SAP Business One

   

       

Header Data

  
Released on 07.03.2010 09:30:41   
Release status Released for Customer   
Component SBO-GEN-FMS Formatted Search  
Other Components

SBO-SH-GEN-FMS Formatted Searches

Priority   Recommendations/additional info   
Category   Consulting   

  

      

Validity

Software Component

Version

SAP BUSINESS ONE

2007 A

2007 B

6.2

6.5

Former Member
0 Kudos

Prezados,

Testei a solução proposta na nota número 672983 nas versões 8.81 PL09 e 8.82 PL06 e tudo funcionou normalmente.

Abraços a todos,

Ricardo Vieira