Hi All,
I have a requirement to restrict an employee such that he can avail a certain leave type(1022) either on thur/sat and also only once in a month. I have enhanced PT_ABS_REQ and put my code in the method IF_EX_PT_ABS_REQ~CHECK_TIME_CONSTR_FOR_SUBTY. I refer to PA2001 to check whether a record for that month already exists or not. Also, i check in the tables PTREQ_ATTABSDATA, PTREQ_HEADER, PTREQ_ITEMS to check if he has already applied for that leave type in that month. If he has already applied/availed the leave in that month error message "Already availed/applied" is displayed and he is not allowed to apply again.
It works fine when the employee creates a new leave request. However, when he tries to change in a request that he has already applied, say he wants to change the date, then my check fails as an entry already exists in the PTREQ tables and the employee is not allowed to change the dates in that month.The error message "Already availed/applied" is displayed.
Is there a workaround for this? I am unable to check if the employee is trying to create a new request or change an existing one. Also, I am unable to fetch the old dates of a request that an employee wants to change, say he has applied for leave for the 1st of April (say its thur) and then wants to change it to 3rd(sat), then im unable to get the old data corresponding to the request on 1st April. I check at runtime, but i only get the changed details corresponding to 3rd April in IF_EX_PT_ABS_REQCHECK_TIME_CONSTR_FOR_SUBTY and also in IF_EX_PT_ABS_REQSIMULATE_VIA_BLOP.
Any idea how I can do this??