Tuesday, May 6, 2008

Sample ABAP Program of Function Module to Convert Work Center into Personnel Number

FUNCTION z_get_pernr_from_wc.
*"----------------------------------------------------------------------
*"*"Local interface:
*" IMPORTING
*" VALUE(I_WORK_CENTRE) TYPE ARBPL
*" EXPORTING
*" VALUE(E_PERSONNEL_NO) TYPE PERNR
*"----------------------------------------------------------------------
* Author: Sheila Titchener - www.iconet-ltd.co.uk
* Date: July 2005
* Description: Convert Work Centre into Personnel Number
*"----------------------------------------------------------------------
DATA: l_hroid TYPE hrobjid,
l_sobid TYPE sobid.

SELECT SINGLE hroid FROM crhd
INTO l_hroid
WHERE objty = 'A'
AND arbpl = i_work_centre.

CHECK sy-subrc = 0.

SELECT SINGLE sobid FROM hrp1001
INTO l_sobid
WHERE objid = l_hroid
AND sclas = 'S'.

CHECK sy-subrc = 0.

SELECT SINGLE sobid FROM hrp1001
INTO l_sobid
WHERE otype = 'S'
AND objid = l_sobid
AND sclas = 'P'.

CHECK sy-subrc = 0.

e_personnel_no = l_sobid.

ENDFUNCTION.

No comments:

Blog Archive