Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Changing sy-uname during an execution

Former Member
0 Kudos

Hello everybody,

can anybody help me?

i want to change the value of sy-uname at runtime. Is it possible??

i know that you can write in the code sy-uname = 'user_sap'.But does it work??

Thank you

8 REPLIES 8

matt
Active Contributor
0 Kudos

No, you can't. It doesn't work.

matt

Former Member
0 Kudos

It is a system defined field.

You cannot change it, it is automatically populated..

Regards,

Lalit Mohan Gupta.

Former Member
0 Kudos

So , the only way to solve this is making a function in which you make this?¿

I have heard it could be a solution!Has anybody heard something about this function?

0 Kudos

Sounds like you're trying to cheat one way or the other. SY-UNAME is supposed to hold the logged on user, what could be a reason to force a different value?

Thomas

Former Member
0 Kudos

I´m not trying to cheat anyone!!

I have some users that do not have access to modify it 0003 but i want them to be allowed to modify this infotype only through my program.That is the reason why i want to change sy-uname.

0 Kudos

talk to you basis team and provide access to them...

0 Kudos

Alright, so this is rather an authorization issue. If you describe the problem in detail in forum , they might have a better solution than changing sy-uname.

Thomas

uwe_schieferstein
Active Contributor
0 Kudos

Hello

You could create a local RFC destination with your SAP user as RFC user. Then you create a RFC-enabled fm which executes your report, e.g.:

CALL FUNCTION 'Z_EXEC_MYREPORT_RFC'.

  CALL TRANSACTION 'Z_MYREPORT'.
" Or:
  SUBMIT z_myreport ...

ENDFUNCTION.

You may create a simple dummy report which just call this fm via RFC. This way you could change the current SY-UNAME. However, I am not sure whether the users can open new screens using your SY-UNAME. If so then this workaround is not useful.

Alternatively, you may encapsulate only the DB access to the infotype within the RFC-enabled fm.

Regards

Uwe