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

dropdown based on authorization

Former Member
0 Likes
1,953

Hello Experts,

I have a requirement where I have to display only those values in dropdown list for which current user is authorized.

All other values should not be displayed. There is authorization object maintained to check if user is authorized or not.

How can I acheive this requirement? How to populate dropdown list based on authorization?

7 REPLIES 7
Read only

Former Member
0 Likes
1,575

Onkar,

When the user hits the drop down button, a sy-ucomm is set. When sy-ucomm is drop down button event, then check the authorization for the user.

You should have a table filled with values that needs to be displayed for the drop down. Based on the authorization delete the unwanted values and show only the rest.

V.

Read only

former_member205488
Active Participant
0 Likes
1,575

Hello Onkar!

Could you specify where you want to place the dropdown field(selection-screen, classic dynpro, web-dynpro view) ?

Read only

0 Likes
1,575

Dropdown field is on selection-screen

Read only

0 Likes
1,575

Get the authorization in the initialization event and in the event at selection-screen on fieldname, based on the auth, remove the values from the table if required and then send the rest back to the screen.

V.

Read only

0 Likes
1,575

Based on the Authorization you can filter values right?

Then use FM VRM_SET_VALUES in

AT SELECTION-SCREEN on VALUE-REQUEST FOR <PARAMETER> or <SELECT-OPTION>-LOW OR <SELECT-OPTION>-HIGH



Sample code :


data : BEGIN OF VRM_VALUE,

          KEY(40) TYPE C,

          TEXT(80) TYPE C,

        END OF VRM_VALUE.

data : itab like TABLE OF VRM_VALUE.

Parameters : p_test type char3 AS LISTBOX VISIBLE LENGTH 10.

AT SELECTION-SCREEN on VALUE-REQUEST FOR p_test.

   VRM_VALUE-key = '1'.

   VRM_VALUE-text = 'First'.

   append VRM_VALUE to itab.

   CALL FUNCTION 'VRM_SET_VALUES'

     EXPORTING

       id                    = 'P_TEST'

       values                = itab

    EXCEPTIONS

      ID_ILLEGAL_NAME       = 1

      OTHERS                = 2

             .

   IF sy-subrc <> 0.

* Implement suitable error handling here

   ENDIF.

Read only

0 Likes
1,575

Well, it would look like this:

REPORT ztest.

TYPE-POOLS: vrm.

PARAMETERS p_field TYPE tv_type AS LISTBOX VISIBLE LENGTH 20.

*//assume p_field is your dropdown field of type tv_type

*//ts_type_text is a structure with fields key of type tv_type

*//and text which you get from text table

INITIALIZATION.


     DATA lt_list  TYPE vrm_values.

     DATA ls_list LIKE LINE OF lt_list.

     DATA lt_values TYPE TABLE OF ts_type_text.

     DATA ls_value TYPE ts_type_text.


*//select values into lt_values from value table


LOOP AT lt_values INTO ls_value.


*//authority-check for value ls_value-key using corresponding auth.object


CHECK sy-subrc = 0.


ls_list-key = ls_value-key.

ls_list-text = ls_value-text.

APPEND ls_list TO lt_list.


ENDLOOP.


CALL FUNCTION 'VRM_SET_VALUES'

       EXPORTING

         id     = 'P_FIELD'  

         values = lt_list.

Read only

former_member355261
Participant
0 Likes
1,575

Hello,

You will have to use FM GET_AUTH_VALUES to get authorizations for specific user in a a table of type US335.

Then I suppose that you have a table declared as follows :

DATA: IT_LIST TYPE VRM_VALUES.

You will have to delete uneeded values from that table based on the table provided by the FM.

regards