ABAP 将SAP用户ID转换成用户名

时间:2021-04-10 08:04:57

FORM frm_coverted_name USING usrid TYPE sy-uname
                       CHANGING name TYPE adrp-name_text.
    DATA: l_name_last TYPE adrp-name_last,
          l_name_first TYPE adrp-name_first,
          l_persnumber TYPE usr21-persnumber.
    
    SELECT SINGLE persnumber INTO l_persnumber
      FROM usr21
      WHERE bname eq usrid.
    
    SELECT SINGLE name_last INTO l_name_last
         FROM   adrp      
         WHERE  persnumber eq l_persnumber.
      SELECT SINGLE name_first INTO l_name_first
         FROM   adrp      
         WHERE  persnumber eq l_persnumber.
      CONCATENATE l_name_last l_name_first INTO name.
ENDFORM.