Skip to Content

First Name and Last Name for a give user (sy-uname)

Hi All,

I need a function module or some way to retrieve the First and Last name for a given system user (sy-uname).

Please advice.

Thanks & Regards,

Saurabh

Add comment
10|10000 characters needed characters exceeded

8 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Aug 03, 2006 at 12:17 PM

    hi,

    use FM <b>USER_NAME_GET</b> will get you the user name collect the same in to a variable and use split statement

    paste this source code and create a FM based on this it works the way in which you want ....

    CLEAR: FULL_NAME , NAME_FIRST, NAME_LAST.
    
     
    
       SELECT SINGLE PERSNUMBER
    
              INTO CORRESPONDING FIELDS OF USR21
    
              FROM USR21
    
              WHERE BNAME = NAME.
    
     
    
       IF SY-SUBRC IS INITIAL.
    
         SELECT NAME_FIRST NAME_LAST NAME_TEXT PERSNUMBER ADDR_COMP
    
                INTO CORRESPONDING FIELDS OF ADRP
    
                FROM ADRP
    
                WHERE PERSNUMBER = USR21-PERSNUMBER
    
                AND DATE_FROM =< SY-DATUM
    
                AND DATE_TO >= SY-DATUM.
    
           NAME_FIRST = ADRP-NAME_FIRST.
    
           NAME_LAST  = ADRP-NAME_LAST.
    
           FULL_NAME  = ADRP-NAME_TEXT.
    
           PERSNUMBER = ADRP-PERSNUMBER.
    
         ENDSELECT.
    
         IF SY-SUBRC IS INITIAL.
    
           SELECT SINGLE SMTP_ADDR
    
                  INTO CORRESPONDING FIELDS OF ADR6
    
                  FROM ADR6
    
                  WHERE ADDRNUMBER = ADRP-ADDR_COMP
    
                  AND   PERSNUMBER = ADRP-PERSNUMBER.
    
         ENDIF.
    
         IF SY-SUBRC IS INITIAL.
    
           EMAIL_ADDRESS = ADR6-SMTP_ADDR.
    
         ENDIF.
    
       ENDIF.
    
     
    
       IF FULL_NAME = ' '.
    
         FULL_NAME = NAME.
    
       ENDIF.

    Message was edited by: Santosh Kumar P

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 03, 2006 at 12:14 PM

    Hi,

    Try this FM

    DATA : l_uname LIKE sy-uname,

    l_adresse TYPE j_5h0_adr,

    l_nachname TYPE j_5h0_adr-nachname,

    l_vorname TYPE j_5h0_adr-vorname.

    l_uname = sy-uname.

    CALL FUNCTION 'J_5H0_USERADRESSE_SAP'

    EXPORTING

    user = l_uname

    IMPORTING

    adresse = l_adresse

    EXCEPTIONS

    no_pers_addr = 1

    OTHERS = 2.

    IF sy-subrc <> 0.

    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

    ELSE.

    l_nachname = l_adresse-nachname. "last name

    l_vorname = l_adresse-vorname. "first name

    Thanks,

    Thirumal

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 03, 2006 at 12:14 PM

    check the table USR03.

    but in my system, data is not maintained for all the users in this table.

    Use the function module,

    SUSR_SHOW_USER_DETAILS

    Message was edited by: Srikanth Kidambi

    Message was edited by: Srikanth Kidambi

    Add comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 03, 2006 at 12:17 PM

    You can use database view USER_ADDR.

    Regards.

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 03, 2006 at 12:19 PM

    The information is stored in table ADRP..you can surely read that using the sy-uname.

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 03, 2006 at 12:20 PM

    Hi Saurabh,

    You can use the FM SUSR_USER_ADDRESS_READ with parameter USER_NAME.

    This will return the fields you need.

    Regards,

    Anil Nallamotu

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 03, 2006 at 12:23 PM

    Hi Saraph,

    use

    CALL FUNCTION 'BAPI_USER_GET_DETAIL'

    EXPORTING

    USERNAME = SY-UNAME

    IMPORTING

    ADDRESS = ADDRESS

    TABLES

    RETURN = RETURN.

    Regards, Dieter

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 03, 2006 at 12:24 PM

    chk this

    REPORT ABC LINE-SIZE 255.

    DATA : ADDRESS LIKE ADDR3_VAL.
    
    CALL FUNCTION 'SUSR_USER_ADDRESS_READ'
      EXPORTING
        USER_NAME    = SY-UNAME
      IMPORTING
        USER_ADDRESS = ADDRESS.
    
    
    WRITE : ADDRESS-NAME_FIRST , ADDRESS-NAME_LAST.

    Add comment
    10|10000 characters needed characters exceeded