2006 Aug 01 1:03 PM
Hi Experts,
I have a report program that has a default selection screen (1000) and ALV output. First selection screen is displayed and on execution ALV is shown.
My requirement is, if the user is not authorized to run this report then selection screen should be skipped and instead display a error page. This error page is nothing but some write statements in ABAP displaying error icon and error info.
Currently I have written the authorization check in the INITIALIZATION event. Here I am setting a flag if the user is not authorized followed by "write" statements showing error info.
But when I run the report, error info is not displayed and instead selection screen loads even though the user is not authorized. I have written the selection screen code in the TOP include.
So what shall I do? How to skip the selection screen?
Are there any other better ways to handle my case?
Thanks
Gopal
2006 Aug 07 4:14 PM
Hey,
Perform the authorization check either in At-Selection-Screen-Output OR Initialization.
If the check fails use the code below to suppress the screen and display the error text.
SUPPRESS DIALOG.
WRITE 'Not authorized'.
LEAVE TO LIST-PROCESSING.
-Kiran
Please reward useful answers
2006 Aug 01 1:07 PM
i suggest you to use error messages instead of list.
example: MESSAGE e398(00) with 'You are not' 'Authorised' 'to run this report'.
2006 Aug 01 1:12 PM
Hi you can Try this.
at selection-screen output.
if cond is true.
message e000(zs) with 'Eroorr'.
endif.
2006 Aug 01 1:34 PM
Hi,
I cannot use error message because I have a specific requirement of showing error page as list.
One more thing I have to show this report in web using ITS. In ITS, error message triggered in INITIALIZATION are suppressed. This is a limitation of ITS.
So I cannot use error message.
2006 Aug 01 1:26 PM
Hi,
You can create the authorization groups in table TPGP and assign it to the attributes of the report, you need to create the user profile and attach this in the profile so that only the authorized users would be able to run the report,
Check this out,
Rgds,
2006 Aug 01 1:33 PM
Hi ,
do one thing .
<b>AUTHORITY_CHECK_TCODE</b>first check authorization by using this FM , if he has the Autho. then Display Selection Screen or else. start getting the data w/o any inputs.
like this .
report.
check<b> AUTHORITY_CHECK_TCODE</b>
if yes .
selection screen.
else.
get data from tables and display data.
Regards
prabhu
2006 Aug 01 1:36 PM
Hi Prabhu,
This will not work! I have already tried.
I can not call a selection screen in else condition. I have declared it in TOP include. In any case whatever selection screen I have declared in the TOP include is triggered.
Message was edited by: gopalkrishna baliga
Message was edited by: gopalkrishna baliga
2006 Aug 01 1:39 PM
so what ? u can put condition in that Top itself ? Is there any probs?
Regards
prabhu
2006 Aug 02 4:52 AM
Hi Prabhu,
If you declare your selection screen in the TOP include then this is triggered and displayed irrespective of you making any call to selection screen in AT SELECTION-SCREEN OUTPUT or INITIALIZATION.
This is the problem.
Thanks
Gopal
2006 Aug 01 1:41 PM
hi,
When user is not authorized to execute the report, for all the fields on selection screen, make screen-active = 0 and just display error messages you want to display as text elements on the screen.
If user is authorized, then make screen-active = 0 for the error messages displayed on the selection screen.
Regards,
Sailaja.
2006 Aug 02 5:14 AM
Hi Sailaja,
I have tried your solution. But it is also not working. Blank Selection screen is still displayed. I can see the 'Execute' button as well.
But I cannot see my error message?
thanks
Gopal
2006 Aug 01 1:54 PM
Hey try this
Inside Initialization.
AUTHORITY-CHECK OBJECT 'Z_REPO_EXE' "Object name
ID 'REPID'
FIELD sy-repid.
IF sy-subrc NE 0.
MESSAGE e030 WITH
'No authorization to execute Report'(001).
ENDIF.
Hope this will solve your problem
Message was edited by: vinodh balasubramaniam
2006 Aug 02 7:27 AM
Got it.
CODE:
REPORT zzsorttry .
SELECTION-SCREEN BEGIN OF SCREEN 1001.
PARAMETERS : p_vbeln TYPE vbak-vbeln.
SELECTION-SCREEN END OF SCREEN 1001.
DATA : flag.
INITIALIZATION.
*C-- Put your authorization check here.
IF 1 = 1.
flag = 1.
LEAVE TO LIST-PROCESSING .
ELSE.
CALL selection-screen 1001.
ENDIF.
START-OF-SELECTION.
IF flag IS NOT INITIAL.
CLEAR flag.
WRITE: 'User', sy-uname , 'not authorized to use this report'.
ENDIF.
2006 Aug 02 8:58 AM
Hi ,
You can write the code to check the Authorization in
"LOAD-OF-PROGRAM" Event.
Eg.
LOAD-OF-PROGRAM.
"Check Authorization here.
If Aythorized.
continue.
Else.
message e000 with 'Not Authorized'.
stop.
endif.
Hope this answer helps you. If yes then please mark this answer as helpful.
Regards
Ashwani.
2006 Aug 07 4:01 PM
Hi Ashwini,
Your code is not working. Selection screen is still displayed. When I press the "Execute" button the it shows the error info.
Did you check ur code before sending?
Moreover I cannot "Message", "Stop" and "Exit". These are not permissible in this event.
I get runtime error if I use either of the above statements.
Also "Continue" can be used only in loops.
However I have tried:
LOAD-OF-PROGRAM.
Check the user's authorization.
AUTHORITY-CHECK code
IF sy-subrc NE 0.
v_auth = 1.
write: 'Not authorized'.
ENDIF.
This code still shows the selection-screen first.
2006 Aug 07 4:20 PM
Maybe this sample program will give you an idea. It is a recursive call to the same program. Using the SUBMIT statement you can bypass the selection screen.
report zrich_0001.
data: repid type sy-repid.
data: switch type c.
parameters: p_check.
parameters: p_switch no-display.
initialization.
import switch from memory id 'ZSWITCH'.
if switch = space.
switch = 'X'.
export switch to memory id 'ZSWITCH'.
submit (sy-repid).
endif.
start-of-selection.
if switch = 'X'.
* Authority check here.
if sy-subrc = 0.
free memory id 'ZSWITCH'.
write:/ 'You are not authorized'.
else.
free memory id 'ZSWITCH'.
switch = space.
endif.
endif.
check switch = space.
free memory id 'ZSWITCH'.
write:/ 'You are authorized, and here is your report'.
Regards,
Rich Heilman
2006 Aug 07 4:14 PM
Hey,
Perform the authorization check either in At-Selection-Screen-Output OR Initialization.
If the check fails use the code below to suppress the screen and display the error text.
SUPPRESS DIALOG.
WRITE 'Not authorized'.
LEAVE TO LIST-PROCESSING.
-Kiran
Please reward useful answers
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |