‎2015 Jul 22 1:36 PM
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?
‎2015 Jul 22 2:19 PM
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.
‎2015 Jul 22 2:29 PM
Hello Onkar!
Could you specify where you want to place the dropdown field(selection-screen, classic dynpro, web-dynpro view) ?
‎2015 Jul 22 3:08 PM
‎2015 Jul 22 3:15 PM
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.
‎2015 Jul 22 3:20 PM
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.
‎2015 Jul 22 3:24 PM
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.
‎2015 Jul 22 2:31 PM
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