2007 May 19 12:31 AM
Hi Experts,
I need to display the last and first name of the person who modified the actions in infotype 0000. I got the uname from the table pa0000. I need to get the last name and first name for that user name. Can you please tell me the table or infotype where I can get this information. Is this information present in any infotype.
Thank you,
Admir
Points will be rewarded.
Hi Experts,
I need to display the last and first name of the person who modified the actions in infotype 0000. I got the uname from the table pa0000. I need to get the last name and first name for that user name. Can you please tell me the table or infotype where I can get this information. Is this information present in any infotype.
Thank you,
Admir
Points will be rewarded.
2007 May 19 1:22 AM
You could use BAPI_USER_GET_DETAIL. Check example code:
REPORT ztest.
PARAMETERS: p_usr TYPE usr21-bname DEFAULT sy-uname OBLIGATORY.
DATA: i_bapiret2 TYPE TABLE OF bapiret2 WITH HEADER LINE,
wa_address TYPE bapiaddr3,
g_iderror(20) TYPE c.
CALL FUNCTION 'BAPI_USER_GET_DETAIL'
EXPORTING
username = p_usr
IMPORTING
address = wa_address
TABLES
return = i_bapiret2.
IF i_bapiret2[] IS INITIAL.
MESSAGE s000(su) WITH wa_address-firstname
wa_address-lastname.
ELSE.
LOOP AT i_bapiret2 WHERE NOT id IS INITIAL.
CONCATENATE i_bapiret2-type
i_bapiret2-number
'(' i_bapiret2-id ')'
INTO g_iderror.
CONDENSE g_iderror.
CONDENSE i_bapiret2-message.
WRITE: /,g_iderror,
space,
i_bapiret2-message.
ENDLOOP.
ENDIF.
Please reward points if this helps.
2007 May 19 2:27 AM
Hi Bindi,
I am working on the smart form so can I use the BAPI inside smartform loop.
Thank you,
Admir
2007 May 19 2:54 AM
There shouldn't be a problem...another way of retrieving this data is this...this would be a lot faster than calling the BAPI in a loop (you could even use SELECT/FOR ALL ENTRIES instead of SELECT SINGLE to retrieve all users at once), but i'm not sure if this works in any release since the tables could have changed their names/fields:
SELECT SINGLE v~name_text
FROM v_addr_usr AS v
INNER JOIN usr21 AS u
ON u~persnumber = v~persnumber AND
u~addrnumber = v~addrnumber
INTO g_name_text
WHERE u~bname = p_usr.
IF sy-subrc <> 0.
MESSAGE s001(01).
ELSE.
MESSAGE s000(su) WITH g_name_text.
ENDIF.
I hope this is useful, i must admit i haven't programmed anything in HR functional area yet. But since what you're asking for is just to get name of users I think this solves your problem.
2007 May 20 2:42 PM
2007 May 19 1:33 AM
If the user is just has a user ID but no corresponding HR personnel number, then you can simply go to USR03 or use BAPI_USER_GET_DETAIL. But if the user has a corresponding HR record, then infotype 0105, subtype 0001 will give you the relationship between user id and pernr. Infotype 0002 will then give you the first name(VORNA) and last name(NACHN).
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |