06-29-2009 9:04 AM
Dear all,
I have been able to make a field mandatory on a selection screen. This is field username. However, the system does not check if the user exists.
What I have done is made a copy of the program behind LX16: RLINV015
Now I have ZLX16 and ZRLINV015
I know the SAP users are found in tabel USR02, so I have added this table under data definition where the other tables are mentioned.
How do I enforce that only existing usernames are entered?
Thanks,
Nick
06-29-2009 9:23 AM
Hi,
Using this, you are not only provided with input help where you can pick the user from the list, but also your are checking user existence manually and if not found system prompts to correct the entry.
TABLES: usr02.
PARAMETERS: pa_user TYPE usr02-bname.
AT SELECTION-SCREEN.
SELECT SINGLE bname FROM usr02 INTO usr02-bname
WHERE bname = pa_user.
IF sy-subrc ne 0.
MESSAGE 'No such user in the system, please correct your entry' TYPE 'E'.
ENDIF.
Regards
Marcin
06-29-2009 9:08 AM
You have to check explicitely in AT SELECTION SCREEN event, if you declare a parameter with obligatory option, it only checks whether the fild is not empty it wont check with possible values with table.
06-29-2009 9:20 AM
Hi Nick,
check the code,
At selection-screen on <ur fld name>.
select single * from usr02 into <workarea> where bname = <fld name value >
if sy-subrc ne 0.
error msg.
else.
proceed with further actions.
endif.
06-29-2009 9:23 AM
Hi,
Using this, you are not only provided with input help where you can pick the user from the list, but also your are checking user existence manually and if not found system prompts to correct the entry.
TABLES: usr02.
PARAMETERS: pa_user TYPE usr02-bname.
AT SELECTION-SCREEN.
SELECT SINGLE bname FROM usr02 INTO usr02-bname
WHERE bname = pa_user.
IF sy-subrc ne 0.
MESSAGE 'No such user in the system, please correct your entry' TYPE 'E'.
ENDIF.
Regards
Marcin
06-29-2009 12:37 PM
Marcin,
I really appreciate your answer, it brought me somewhere. However, the code I pasted is addeing a new field, whereas I really need the user name in field LINK-UNAME, otherwise my inventory document is not getting the user name.
I have tried the following to achieve this:
AT SELECTION-SCREEN.
SELECT SINGLE bname FROM usr02 INTO link-uname
WHERE bname = pa_user
This was however not doing the job.
Do you have any more suggestions?
Thanks,
Nick
06-29-2009 12:49 PM
No problem. What I understand is that you want user name back in LINK-UNAME field, but validate it on selection screen, right? So this should help.
PARAMETERS: pa_user TYPE usr02-bname. "for validation
tables: link, "first declare work area for LINK table
usr02. "USR02 used for fetching data (as LINK-UNAME and USR02-BNAME has different type)
AT SELECTION-SCREEN.
SELECT SINGLE bname FROM usr02 INTO usr02
WHERE bname = pa_user. "here validation first
if sy-subrc ne 0.
message ...
else.
"user correct, transport your data
LINK-UNAME = USR02-BNAME.
endif.
Regards
Marcin
06-29-2009 1:14 PM