Skip to Content
Author's profile photo Former Member

Query Report Tips Part 2 – Mandatory Selection Field And Authorization Check

A small tip on how to set a selection field as mandatory. This is useful when the query report might run on huge database or certain selection field is required in order to get meaningful results.

I show an example below.

In SQ02, click on Extras icon on top, and then go to Selections tab. Click on create button to create a new selection criterion and fill in like below. The extras field need to fill in “OBLIGATORY NO-EXTENSION NO INTERVALS”.

/wp-content/uploads/2012/04/temp_93238.jpg

This is what you may see in the report selection. Notice that the field is also set as a single field. If you still want multiple selection field, in the extras, put in parameter “OBLIGATORY” will do.

/wp-content/uploads/2012/04/temp2_93251.jpg

To add authorization check, as shown in the 1st screen shot, after you create the selection field as mandatory, click on the code icon to write below codes:  

AUTHORITY-CHECK OBJECT ‘V_VBAK_VKO’
            ID ‘VKORG’ FIELD SALESORGLOW
            ID ‘ACTVT’ FIELD ’03’.
if sysubrc ne 0.
   MESSAGE ‘You are not authorized to Sales Office/Sales Area.’ Type ‘E’.
endif.

AUTHORITY-CHECK OBJECT ‘S_TCODE’
            ID ‘TCD’ FIELD ‘VA03’

if sysubrc ne 0.
   MESSAGE ‘You are not authorized to Tcode VA03.’ Type ‘E’.
endif.

Assigned Tags

      11 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Jelena Perfiljeva
      Jelena Perfiljeva

      Doh! One would think that as an ABAPer I should've guessed myself what 'Extras' is for, but those checkboxes threw me off. It would've been awfully nice of SAP to just provide the checkboxes for this though. Oh well...

      Thank you for sharing, it was very helpful!

      Author's profile photo ' MoazzaM '
      ' MoazzaM '

      Hi Alan

      I never thought this would be so easy. Once I had to do this and I didn't know this technique so I did this by creating selection screen and then putting some ABAP code 🙂

      This is an easy way to make some field mandatory but what if we need to put some authority check logic as well based on this field? Then do we have to stick with ABAP coding?

      Thank$

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      That is easy.

      In the 1st screen shot, after you create the selection field as mandatory, click on the code icon to write below codes:  

      AUTHORITY-CHECK OBJECT 'V_VBAK_VKO'
                  ID 'VKORG' FIELD SALESORG-LOW
                  ID 'ACTVT' FIELD '03'.
      if sy-subrc ne 0.
         MESSAGE 'You are not authorized to Sales Office/Sales Area.' Type 'E'.
      endif.

      AUTHORITY-CHECK OBJECT 'S_TCODE'
                  ID 'TCD' FIELD 'VA03'

      if sy-subrc ne 0.
         MESSAGE 'You are not authorized to Tcode VA03.' Type 'E'.
      endif.

      Author's profile photo ' MoazzaM '
      ' MoazzaM '

      Thank you Alan Love. I will try this.

      Thank$

      Author's profile photo Suman Sardar
      Suman Sardar

      Hi Alan,

      I am sure this should be known to some guys in the forum but never thought that this could be so useful informative.After reading your post I am sure so many members will be benefited.Thanks for sharing small but powerful tips.

      Thanks,

      Suman$

      Author's profile photo Srinu S
      Srinu S

      Thanks Alan for sharing helpful tool. 🙂

      Srinu.

      Author's profile photo Former Member
      Former Member

      thanks for sharing

      Author's profile photo Suhaib Bin Aziz
      Suhaib Bin Aziz

      Hey Alan,

      Its good to know this.. thanks for posting such interesting thing on...

      thanks

      Best Regards,

      Suhaib Bin Aziz

      Author's profile photo Mehmet Ozgur Unal
      Mehmet Ozgur Unal

      Hi Alan ;

      Very useful document, thanks for sharing.

      But, is there a control for using of * ? Some genious users benefit from * not to restrict selection.

      Regards.

      M.Ozgur Unal 

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Refer to this thread: http://scn.sap.com/thread/589500

      Author's profile photo PRASOON AK
      PRASOON AK

      Hi,

         Very useful information. Thanks for sharing.

      Regards,

      AKPT