2010 Dec 29 10:42 AM
Scenario:
staff has a balance of 36 availale with him and has entry in Infotype 2001 (for dates 13/12/2010 - 17/12/2010 - ).i..e, 5 week days
Now if the staff takes another leave on next working day i.e., 20/12/2010, system needs to deduct the weekend in between, ie. 18/19/2010
For this purpose i have written a code, where follwoing peace of cdoe is creaeting an abrupt situation.
i'm using the follwoing code.
[code]
REFRESH ABSENCE1.
in itab_pa2001 i get the original records from the system so need to get existing recrod from system
and limit the itab_pa2001 to only the week end record
THIS IS WORKING
LOOP AT ITAB_PA2001.
CALL FUNCTION 'BAPI_ABSENCE_GETDETAILEDLIST'
EXPORTING
EMPLOYEENUMBER = ITAB_PA2001-PERNR
TIMEINTERVALLOW = ITAB_PA2001-BEGDA
TIMEINTERVALHIGH = ITAB_PA2001-ENDDA
IMPORTING
RETURN = RETURN
TABLES
ABSENCE = ABSENCE1.
IF RETURN-TYPE NE 'E' OR RETURN-TYPE NE 'A'
OR RETURN-TYPE NE 'W'.
LOOP AT ABSENCE1.
ENDLOOP.
DELETE ITAB_PA2001 WHERE
BEGDA = ABSENCE1-VALIDBEGIN
AND ENDDA = ABSENCE1-VALIDEND.
ENDIF.
REFRESH ABSENCE1.
ENDLOOP.
REFRESH ABSENCE1.
CLEAR ABSENCE1.
now itab_pa2001 only having the week end record follwoign code creates it
LOOP AT ITAB_PA2001.
STATUS = 'TRUE'.
CALL FUNCTION 'BAPI_ABSENCE_CREATE'
EXPORTING
EMPLOYEENUMBER = ITAB_PA2001-PERNR
VALIDITYBEGIN = ITAB_PA2001-BEGDA
VALIDITYEND = ITAB_PA2001-ENDDA
ABSENCETYPE = ITAB_PA2001-SUBTY
IMPORTING
RETURN = RETURN.
IF RETURN-TYPE EQ 'E' OR RETURN-TYPE EQ 'A' OR RETURN-TYPE EQ 'W'.
WRITE : RETURN-MESSAGE.
NEW-LINE.
ENDIF.
ENDLOOP. [code]
what happens
Balance before was 36
now it is 36 - 5 + 2 = 33.
i.e., 36 - days of old entry + days of new entry.
is using 'BAPI_ABSENCE_GETDETAILEDLIST' and 'BAPI_ABSENCE_CREATE' incorrect.
2010 Dec 29 4:20 PM
when you delete some absences in the past, often the 2006 is not updated properly
for this purpose you have to run program RPTBPC10
this will correct the balances
2011 Apr 05 11:23 AM
Found the solution
can not use
'BAPI_ABSENCE_GETDETAILEDLIST'
and
'BAPI_ABSENCE_CREATE' in sequence
as the internal table p2001 called in 'BAPI_ABSENCE_GETDETAILEDLIST' does not get refreshed fro the next call to 'BAPI_ABSENCE_CREATE' as they are in the same function group.
using "BAPI_PTMGRATTABS_MNGCREATION" instead of 'BAPI_ABSENCE_CREATE'.
bilal