‎2009 May 05 11:26 AM
Hi Everyone,
I would like to ask if this is possible, and if yes, then how:
I would like create a selection screen where the user will select a certain UNAME from the drop down list. This selection field will have possible values taken from SU01 user names. But here's the twist; the selection field should not allow users to type on it or select a blank value. The user is obliged to select from the drop down list. Is this possible? If yes, please tell me how to do this or you may share some links for me to follow.
Thank you very much in advance.
Regards,
RE
‎2009 May 05 3:14 PM
Hi Reymar,
Using listbox automatically restricts user with the input, he/she can only pick a value. Furthermore, simply adding OBLIGATORY addition will force selection by user on this field. Check this code:
TYPES: t_c30(12) TYPE c.
PARAMETERS: pa_uname TYPE t_c30 AS LISTBOX VISIBLE LENGTH 40 USER-COMMAND f_code OBLIGATORY .
DATA: BEGIN OF it_users OCCURS 0,
bname TYPE usr01-bname,
name_textc TYPE user_addr-name_textc,
END OF it_users.
"fill the table only once
INITIALIZATION.
SELECT usr01~bname user_addr~name_textc INTO CORRESPONDING FIELDS OF TABLE it_users
FROM usr01 INNER JOIN user_addr
ON usr01~bname = user_addr~bname.
"on F4 (input help) return user id (BNAME)
AT SELECTION-SCREEN ON VALUE-REQUEST FOR pa_uname.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'BNAME'
value_org = 'S'
TABLES
value_tab = it_users
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
"<- here just react accordingly, user id is stored in pa_uname
ENDIF.
The list will show only user names (not ids), but when you pick one, his/her id will be returned to PA_UNAME. If you want to see both user name and id, in standard toolbar of any SAP window choose last icon ( Customize Local Layout->Options->Expert-> select Show all keys in dropdown lists ). But please be aware that this setting is global one, hence is applicable to all lists accross the system.
Regards
Marcin
‎2009 May 05 11:28 AM
‎2009 May 05 2:50 PM
List Box will not allow user to enter any values and you can some logic in PAI.
FIELD fld MODULE chek_empty
‎2009 May 05 3:14 PM
Hi Reymar,
Using listbox automatically restricts user with the input, he/she can only pick a value. Furthermore, simply adding OBLIGATORY addition will force selection by user on this field. Check this code:
TYPES: t_c30(12) TYPE c.
PARAMETERS: pa_uname TYPE t_c30 AS LISTBOX VISIBLE LENGTH 40 USER-COMMAND f_code OBLIGATORY .
DATA: BEGIN OF it_users OCCURS 0,
bname TYPE usr01-bname,
name_textc TYPE user_addr-name_textc,
END OF it_users.
"fill the table only once
INITIALIZATION.
SELECT usr01~bname user_addr~name_textc INTO CORRESPONDING FIELDS OF TABLE it_users
FROM usr01 INNER JOIN user_addr
ON usr01~bname = user_addr~bname.
"on F4 (input help) return user id (BNAME)
AT SELECTION-SCREEN ON VALUE-REQUEST FOR pa_uname.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'BNAME'
value_org = 'S'
TABLES
value_tab = it_users
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
"<- here just react accordingly, user id is stored in pa_uname
ENDIF.
The list will show only user names (not ids), but when you pick one, his/her id will be returned to PA_UNAME. If you want to see both user name and id, in standard toolbar of any SAP window choose last icon ( Customize Local Layout->Options->Expert-> select Show all keys in dropdown lists ). But please be aware that this setting is global one, hence is applicable to all lists accross the system.
Regards
Marcin