!!Get Employee ALA_LAST

!Functionality:
The purpose of this function is to capture the latest previous evaluated leave lines for the month as of the date specified. This will be to return the any of the [AC_CODE] values as seen in the Previous Evaluations tab of [IALA]


!Parameters:
|EEM_ID        |''Required''. Employment ID in which the pay info is to be recovered
|LEAVE_TYPE    |''Required''. Leave type code from [IAPT]
|AC_CODE       |''Required''. AC_CODE as defined on [IAAC] (ie, A050, A700, A900, etc.)
|WHEN          |''Optional''. The as of date to be used (DD-MON-YYYY). Only the 'MON' portion of the date will be used. This date will be converted to the last day of the month for the query (The month from the Sysdate will be used if left blank).


!Returns: 
Numeric

!Errors:  
* When No Data is found than 0 will be returned
* When the provided [LEAVE_TYPE_CODE] is not found -99996 will be returned
* When the provided [AC_CODE] is not found -99997 will be returned
* When there is an un-trapped exception than -99999 will be returned

!Example: 

FUNCTION ALA_LAST(~,'VACATION','A700','01-Jan-2017')

Using the EEM_ID as the ~ parameter, this will return the value from the last leave line to be processed in the month of January, linked to the leave type 'VACATION' and the AC_CODE A700. 


!Notes
* The [EEM_ID] will be used to check leave lines details for the value of the specified AC code for the leave type as of the listed date.
* Only leave lines without [TIME_CODE] will be picked up
* Only Leave lines with an [ACCRUAL_STATUS] not in 3-In Payroll, 1-Requested or 2-Requested Processed will be picked up

----