Application Development and Automation 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: 

how to hide one selection-screen option deppending on user?

Former Member
0 Kudos
1,241

Hi,experts how to hide last selection-screen option for some users ( authorization-object )?

it's p-_marc here

8 REPLIES 8

Sandra_Rossi
Active Contributor
1,159

Please [DO NOT post images](https://stackoverflow.com/help/how-to-ask) of code, data, error messages, etc. - copy or type the text into the question.

This question was asked many many times in the forum, LOOP AT SCREEN and MODIFY SCREEN based on SCREEN-GROUP1 (equivalent to MODIF ID). Good luck in searching.

Rajasekhar_Dina
Participant
0 Kudos
1,159

Use Initialization event.

INITIALIZATION.
LOOP AT SCREEN.
IF sy-uname = 'RB_ABAP7'. "RB_ABAP7 is a userid
IF screen-name = 'P_BW_N'.
screen-invisible = 1.
MODIFY SCREEN.
ENDIF.
ENDIF.
ENDLOOP.

0 Kudos
1,159

Never, ever put conditions like that into your code, unless it's a test code in a very early stage

IF sy-uname = 'RB_ABAP7'.

Authorization objects have to be used instead. I've seen such shortcuts backfiring so many times when RB_ABAP7 user leaves the building and the code doesn't work for their replacements.

0 Kudos
1,159

I can't find a user list in authorization-object. How to do it?

RaymondGiuseppi
Active Contributor
0 Kudos
1,159

Create an authorization object with SU21 and use it in PBO logic

AT SELECTION-SCREEN OUTPUT.
  LOOP AT SCREEN.
	IF screen-name = 'P_BW_N'.
	  AUTHORITY-CHECK OBJECT 'Zxxxxx' " created with SU21
		ID 'ACTVT'  FIELD '03'. " define at least 1 field
	  IF sy-subrc <> 0.
		screen-active = 0.
		MODIFY SCREEN.
		IF P_BW_N = abap_true. " prevent dump
		  CLEAR P_BW_N.
		  P_MARA = abap_true.
		ENDIF.
	  ENDIF.
	ENDIF.
  ENDLOOP.

Then Admin will create/adapt roles for users with PFCG.

Hint: Attach your authorization object to transaction defintion with SU24 (administrator would like to thank you)

0 Kudos
1,159

why i need an authorization object if can just create an role and do select with AGR_USERS table?
i don't have an admin and need to do it for myself.

i've created an authorization object and don't undersrand how to add it to pfcg

As i understand role doesn't create automaticly and i need to do it by myself

0 Kudos
1,159

Read some online documentation on Authorization Concept in Abap

Look also at training such as ADM940 Authorization Concept for SAP S/4HANA and SAP Business Suite

Steps

  • Create Authorization - SU21
  • Check in programs - SE80
  • Add to role/profiles - PFCG
  • Add roles to user - SU01

NB: If you link an authorization object with a transaction with SU24, then when you add the transaction to a role with PFCG it will add the authorization to the role.

Sandra_Rossi
Active Contributor
0 Kudos
1,159

How to create authorization objects and how to work with authorizations have been asked and answered many times in the forum too.

What specific issue do you have?