Technical Articles
Delete Infotype Operation
At most times we need to add or delete records from the infotypes or from any other standard tables. Requirements to perform the MOD(Modify), COP(Copy), INS(Insert) , DEL (Delete) operations can be used to manipulate the records in infotypes.
The delete operation for infotype 2003 is performed using three different function modules which is explained in detail below.
Three different function modules are used.
1. ‘HR_EMPLOYEE_ENQUEUE’
Here , we need to pass the pernr and lock the user before performing the operation.
2. ‘HR_INFOTYPE_OPERATION’
Here, we need to pass the pernr , subtype , begin date , end date , the record in 2003 and DEL operation
3. ‘HR_EMPLOYEE_DEQUEUE’
After performing the operation we need to again unlock the user.
The detailed code snippet for deletion operation of 2003 infotype :
Loop at it_pa2003 into wa_pa2003." where pernr = wa_pa2001-pernr.
move-corresponding wa_pa2003 to wa_p2003.
wa_final-begda = wa_p2003-begda.
wa_final-pernr = wa_p2003-pernr.
* WA_FINAL-ST = WA_PA2001-BEGDA.
* WA_FINAL-EN = WA_PA2001-ENDDA.
wa_p2003-infty = '2003'.
call function 'HR_EMPLOYEE_ENQUEUE'
exporting
number = wa_p2003-pernr
importing
return = bapireturn.
call function 'HR_INFOTYPE_OPERATION'
exporting
infty = '2003'
number = wa_p2003-pernr
subtype = wa_p2003-subty
validityend = wa_p2003-endda
validitybegin = wa_p2003-begda
record = wa_p2003
operation = 'DEL'
importing
return = bapireturn.
call function 'HR_EMPLOYEE_DEQUEUE'
exporting
number = wa_p2003-pernr
importing
return = bapireturn.
append wa_final to it_final.
clear : wa_pa2001 , wa_final, wa_pa2003, wa_p2003.
endloop.
If there are any errors the same will be fetched in the bapireturn. Bapireturn will hold the error messages.
Thus after this operation the particular records are modified or deleted based upon the operation performed in the infotypes and standard tables. Since these are master records , they cannot be deleted as and then . With utmost necessity only the infotype operations are to be performed.
I like this blog almost as much as I liked your first one.
After your ENQUEUE function module, you should check your return table to make sure it is successful prior to updating your infotype. If it is already locked you don't want to update it.
Also just because I'm curious, what was your requirement? I ask, because changing SAP tables is risky. You stated that above. Keep in mind, I haven't worked in the HR environment and a long time ago I heard it was very different from normal development.
The post was clean and neat.
There is another function called as
ENQUEUE_EPPRELE to Enqueue and
DEQUEUE_EPPRELE to Dequeue.
This will help us not only to lock and update the data, but also to get the exceptions like foreign_lock and system_failure during the lock
Hi Sowmya
I need to delete duplicate records from PA2006 infotype. Is this procees the same if you want to delete information of PA2006 infotype?
What about if I need to modify Valid from (BEGDA) date from same infotype? What procces I need to do?
Thanks