sapdev logo background
sapdev logo sapdev logo
Comments

Retrieve employees address details (own data)




The below code shows how SUSR_USER_ADDRESS_READ and ADDR_PERS_COMP_COMM_GET are used.


  DATA: ld_address LIKE  addr3_val,
        ld_usr03   LIKE  usr03,
        ld_userid  type sy-uname,
        ld_smtp LIKE adsmtp OCCURS 0 WITH HEADER LINE.

  ld_userid = sy-uname.

  CALL FUNCTION 'SUSR_USER_ADDRESS_READ'
    EXPORTING
      user_name                    = ld_userid
*   READ_DB_DIRECTLY             = ' '
    IMPORTING
      user_address                 = ld_address
      user_usr03                   = ld_usr03
    EXCEPTIONS
      user_address_not_found       = 1
      OTHERS                       = 2.


* Get additional user address details (i.e. email) 
  CALL FUNCTION 'ADDR_PERS_COMP_COMM_GET'
    EXPORTING
*     ADDRESS_HANDLE          = ' '
     ADDRESS_NUMBER          = ld_address-addrnumber
*     DATE_FROM               = '00010101'
*     LANGUAGE                = SY-LANGU
*     PERSON_HANDLE           = ' '
     PERSON_NUMBER           = ld_address-persnumber
      table_type              = 'ADSMTP'   "email details
*                   Other valid entries for table_type include:
*                       ADFAX for fax details
*                       ADTEL for telephone details  
*   IMPORTING
*     RETURNCODE              =
    tables
      comm_table              =  ld_smtp
*     ERROR_TABLE             =
   EXCEPTIONS
     PARAMETER_ERROR         = 1
     ADDRESS_NOT_EXIST       = 2
     PERSON_NOT_EXIST        = 3
     INTERNAL_ERROR          = 4
     OTHERS                  = 5.



Check out sap documentation and pattern details for function module susr_user_address_read on website se80.co.uk



comments powered by Disqus