SQL Server administration and T-SQL development, Web Programming with ASP.NET, HTML5 and Javascript, Windows Phone 8 app development, SAP Smartforms and ABAP Programming, Windows 7, Visual Studio and MS Office software
Development resources, articles, tutorials, code samples, tools and downloads for SAP HANA and ABAP, HANA Database, SQLScript, SAP UI5, Screen Personas, Web Dynpro, Workflow

Get Fullname of SAP user using ABAP Function Module

ABAP developers frequently require to print user names on reports or SAP Smart Form documents. Programmers can use ABAP function module SO_USER_READ_API1 to read SAP user fullname by passing the SAP user code instead of using a SAP user name table. Passing SAP username as import parameter to the SO_USER_READ_API1 function module will return users full name (first name, middle name and last name) in the export structure.

Here is a sample ABAP program showing how to use SO_USER_READ_API1 ABAP function module to read SAP user fullname.

If the SAP user code is not provided, the below sample ABAP report will return the full name of the user who is running the program.

DATA ls_user TYPE soudnamei1.
DATA ls_userdata TYPE soudatai1.

ls_user-sapname = 'YILMAZ-E'. " SAP User default is sy-uname

* Read SAP user fullname
CALL FUNCTION 'SO_USER_READ_API1'
 EXPORTING
  user = ls_user
* PREPARE_FOR_FOLDER_ACCESS = ' '
 IMPORTING
  user_data = ls_userdata
 EXCEPTIONS
  user_not_exist = 1
  parameter_error = 2
  x_error = 3
  OTHERS = 4.
IF sy-subrc <> 0.
* Implement suitable error handling here
ELSE.
 WRITE ls_userdata-fullname. " Fullname of the SAP user
ENDIF.
Code

Above ABAP program will write first name and the last name of the SAP user whose SAPuser code is passed as import parameter to the SO_USER_READ_API1 ABAP function module and returned in fullname field of the user_data export structure.

ABAP codes to read fullname of SAP user using SO_USER_READ_API1 function module



SAP HANA and ABAP

Install SAP Free
CRM Companies List
Web Based CRM Software


Copyright © 2004 - 2021 Eralper YILMAZ. All rights reserved.