Homelab, Linux, JS & ABAP (~˘▾˘)~
 

[ABAP] Validate pernr

DATA ls_return TYPE bapireturn.

CALL FUNCTION 'BAPI_EMPLOYEE_CHECKEXISTENCE'
  EXPORTING
    number = 99999999
  IMPORTING
    return = ls_return.
IF ls_return-type = 'E'.
  MESSAGE ls_return-message TYPE ls_return-type.
ENDIF.

On newer systems there is also class CL_HRPA_MAINTAIN_EMPLOYEE with method PERSONNEL_NUMBER_EXISTS.
Or class CL_HRPA_MAINTAIN_EMPLOYEE_UTIL and method EXIST_EMPLOYEE.

[ABAP] User ↔ Employeenumber

Class:
– CL_HCMFAB_EMPLOYEE_API
Methods:
– GET_USERID_FROM_EMPLOYEENUMBER
– GET_EMPLOYEENUMBER_FROM_USER

How to use the class:

TRY.
    DATA(lv_pernr) = cl_hcmfab_employee_api=>get_instance( )->get_employeenumber_from_user( sy-uname ).
  CATCH cx_hcmfab_common.
ENDTRY.

TRY.
    DATA(lv_uname) = cl_hcmfab_employee_api=>get_instance( )->get_userid_from_employeenumber( lv_pernr ).
  CATCH cx_hcmfab_common.
ENDTRY.