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

ABAP HR

Former Member
0 Likes
755

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.

5 REPLIES 5
Read only

alejandro_bindi
Active Contributor
0 Likes
720

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.

Read only

0 Likes
720

Hi Bindi,

I am working on the smart form so can I use the BAPI inside smartform loop.

Thank you,

Admir

Read only

0 Likes
720

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.

Read only

0 Likes
720

Thank you Experts. Points were rewarded.

Read only

Former Member
0 Likes
720

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).