Skip to Content

Scenario:SL and CL  leaves are accrued monthly basis and when the leave applied if over and above the entitlements (say 1 days is accrued for two months jan and feb) and leave –SL is applied for 2 days,one day need to be deducted from SL quota and remaining one day needs to be deducted from EL quota.whilst quota deduction can be handled in standard configuration ,the challenge is to have absence created in 2001 (EL –one day need to be created in 2001 subtype)

BADI was implemeneted to map the requirement

BADI tcode SE18/SE19

Thanks to his ABAP mate

my abap mate coded something like below

Report  ZTEST.
tables: p2001.
DATA RETURN TYPE BAPIRETURN1.
DATA RETURN1 TYPE BAPIRETURN1.
DATA personaldatakey TYPE BAPIPAKEY.
DATA: leave_bal TYPE TABLE OF bapiabwkon,” with header line.

wa LIKE LINE OF
leave_bal,

Lt type
PRELP.

import
leave_bal1 TO leave_bal FROM MEMORY ID ‘leavebal’.

import
new_innnn TO Lt FROM MEMORY ID ‘new_innnn’.

p2001pernr = ‘100097’.

p2001
SUBTY = ‘0100’.

p2001
endda = ltendda .“”‘20130409’.

p2001
begda = ltbegda.“”‘20130409’.

p2001
AWART = ‘AL’.

*CALL FUNCTION ‘BAPI_EMPLOYEE_ENQUEUE’
*  EXPORTING
* NUMBER        = ‘100097’
* IMPORTING
* RETURN        = RETURN1

.

CALL FUNCTION ‘HR_PSBUFFER_INITIALIZE’.

call function ‘HR_INFOTYPE_OPERATION’

EXPORTING


infty         =
‘2001’

number       
= ‘100097’

SUBTYPE       =
‘AL’
* lockindicator = ‘X’

validityend   =
ltendda

validitybegin = ltbegda

record        = p2001

  DIALOG_MODE            = ‘2’

  NOCOMMIT               =
‘X’

operation     =
‘INS’
* nocommit      = nocommit

objectid     =
‘ ‘

tclas         =
‘A’ “(tclas = ‘B’ for applicant data)

IMPORTING


return       
= return

key          
= personaldatakey

EXCEPTIONS

others       
= 0.
case returntype.

when ‘E’ or ‘A’.

exit.

when others.

commit work.

MESSAGE
‘Record Created’ type ‘S’.
*    LEAVE TO TRANSACTION ‘PA30’.

IF NEW_INNNNINFTY = ‘2001’ and IPSYSTIOPER = ‘INS’ AND SYUCOMM IS INITIAL.” AND NEW_INNNN-SUBTY = ‘SLWR’.

DATA RETURN1 TYPE BAPIRETURN1.

DATA: leave_bal1 TYPE TABLE OF bapiabwkon,” with header line.

wa1 LIKE LINE OF leave_bal1,

bal type bapiabwkonENTITLE,

leavetype type bapiabwkonQUOTATYPE.

clear return1.

CALL FUNCTION ‘BAPI_EMPLOYEE_ENQUEUE’

EXPORTING

NUMBER = ‘100097’

IMPORTING

RETURN = RETURN1.

break abc_abap2.

CALL FUNCTION ‘REMAINING_TIMEQUOTA’

EXPORTING

employeenumber = NEW_INNNNPERNR

LANGUAGE       = SYLANGU

date           = NEW_INNNNBEGDA

TABLES

  timequota      = leave_bal1.

if leave_bal1[] is not INITIAL.

if NEW_INNNNsubty eq ‘SL’.

leavetype = ’02’.

elseif NEW_INNNNsubty eq ‘MAL’.

leavetype = ’10’.

endif.

loop at leave_bal1 into wa1 where QUOTATYPE eq leavetype and QUOTABEG leNEW_INNNNbegda and QUOTAEND ge NEW_INNNNendda.

bal = bal + ( wa1entitle wa1deduct ).

endloop.

if bal le 0.

export leave_bal1 from leave_bal1 to memory id ‘leavebal’.

export new_innnn from new_innnn to MEMORY id ‘new_innnn’.

submit ztest and RETURN.

endif.

endif.

CALL FUNCTION ‘BAPI_EMPLOYEE_DEQUEUE’

EXPORTING

NUMBER = ‘100097’

IMPORTING

RETURN = RETURN1.

endif.

ENDCASE.

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply