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: 
Read only

How to skip selection screen? Please help!

gopalkrishna_baliga
Participant
0 Likes
4,044

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

1 ACCEPTED SOLUTION
Read only

Former Member
2,710

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

16 REPLIES 16
Read only

Former Member
0 Likes
2,710

i suggest you to use error messages instead of list.

example: MESSAGE e398(00) with 'You are not' 'Authorised' 'to run this report'.

Read only

0 Likes
2,710

Hi you can Try this.

at selection-screen output.

if cond is true.

message e000(zs) with 'Eroorr'.

endif.

Read only

0 Likes
2,710

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.

Read only

Former Member
0 Likes
2,710

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,

Read only

Former Member
0 Likes
2,710

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

Read only

0 Likes
2,710

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

Read only

0 Likes
2,710

so what ? u can put condition in that Top itself ? Is there any probs?

Regards

prabhu

Read only

0 Likes
2,710

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

Read only

Former Member
0 Likes
2,710

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.

Read only

0 Likes
2,710

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

Read only

Former Member
0 Likes
2,710

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

Read only

Former Member
0 Likes
2,710

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.

Read only

0 Likes
2,710

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.

Read only

0 Likes
2,710

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.

Read only

0 Likes
2,710

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

Read only

Former Member
2,711

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