Skip to Content

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.

To report this post you need to login first.

11 Comments

You must be Logged on to comment or reply to a post.

  1. 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!

    (0) 
  2. ' 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$

    (0) 
    1. Alan Love 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 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.

      (0) 
  3. 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$

    (0) 
    1. 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 

      (0) 

Leave a Reply