manish2111
22nd January 2009, 19:31
Hello everybody...i m using BaaN IVc4---
I need a help -- We have implemented HR Module in BaaN. I am facing a poblem in Maintain Leave Transaction .. any one can give me logic..
suppose i m having 2 leave balance....then BaaN should allow only for 2 days leave to take...but now it is accepting more than 2 leave. Because now system is when the boss will approve then only leave balance will be deducted otherwise leave balance will remain same. If boss has not approved then leave balance will remain same. And in this case users can apply leave for any days because in leave balance it shows 2.

so, what i want to give logic is--- if users have applied leave and that is pending then SUM total pending leave and if this pending leave is < Total Leave Bal. then only allow else not allow.
e.g. Total CL = 5
users have applied CL for 2 days
Again applied CL for 2 days
if next time he is applying for CL for 2 days then it should not allow.
So i want to calculate if (2+2) < 5 then allow else not allow
So how to calculat in BaaN this (2+2).
Plz help me..... thanks in advance.

Hitesh Shah
23rd January 2009, 15:58
This kind of validation changes in baan can be done easily if u have source code . If u dont have any source codes , u can do in a new session with AFS wrapper or any other tool like QKEY / RUSH etc . This board is replete with ample documentation and help on this topics.

NvpBaaN
25th January 2009, 23:34
You probably are storing the leave data in some Baan tables, with the status (like Pending or Approved). When user is applying for leave, check for all leave records for that user. You may get different records with different status. For records with status = Approved, add the approved leave to a variable (example prev.leaves). For records with status = Pending, add the applied number of days to another variable (example pending.approval). For calculating the available balance, use the total leaves - prev.leaves - pending.approval.

So, with your example, it would look like:

total.leaves = 5
[users have applied CL for 2 days - Assume status = Approved for this leave]
prev.leaves = 2
[Again applied CL for 2 days - Assume status = Pending]
pending.approval = 2
[Again he is applying for CL for 2 days]
avbl.leaves = total.leaves - prev.leaves - pending.approval
= 5 - 2 -2
= 1
Since avbl.leaves < leaves he is applying now, don't allow him to apply.

Hope this helps.

manish2111
27th January 2009, 18:23
Hi Everybody..
Thanks for help..
But can you help me...
I have a table where I am storing total no. of leaves taken
Lets say lttcd492 in field lttcd492.lvdy
Now I want to add as below..
2 CL applied on 01-01-09 in lttcd492.lvdy (Status is Pending)
again 3 CL applied on 12-01-09 it also stores in lttcd492.lvdy (Status is Pending)
Now I want to get total no. of days as Pending.
So how to add 2+3. Can you give me script because both are storing in same field with different date, so i m not getting how to add ??
Thanks in advance!!!!!!!!!!

Hitesh Shah
27th January 2009, 18:44
U can do so with above functions .

If u get a tools training in Baan 4GL ,that can help u substantially doing such tasks.

manish2111
28th January 2009, 12:36
Kindly see the below what i wrote but it is not working.
It is calculating only first record.
Lets say if I have applied for CL two times i.e. two records are available.
1st time- 2 days
2nd time - 3 days
Then it is considering only 2 days but it should consider 2+3 = 5days.
Kindly see my script and if any modification required kindly give me.
Thanks in advance.

main.table.io:
read.view:
on.main.table(calculate.total)
leave.bal = lttcd010.bday - leave.pend
**************************************************
function calculate.total()
{
select sum(lttcd492.lvdy) :leave.pend
from lttcd492
where lttcd492._index1 = {:lttcd492.psno}
and lttcd492.lcod = :lttcd492.lcod
and lttcd492.lvfr = :lttcd492.lvfr
and lttcd492.lvto = :lttcd492.lvto
and lttcd492.apty <> lttcd.apty.ngtv
and lttcd492.cncl <> ltyesno.yes
and lttcd492.irst = lttcd.sanc.pend
as set with 1 rows
selectdo
selectempty
leave.pend = 0
endselect
}
*************************************************
if lttcd492.lvdy >= leave.bal then
v.msg = "You don't have sufficient balance to apply leave"
set.input.error("lttcd49001",v.msg)
endif
*************************************************

wiggum
28th January 2009, 15:53
I guess that from and to date (lttcd492.lvfr & lttcd492.lvto) are part of index 1. With you conditions you select only the record where both fields are exact the same as the current record.

manish2111
29th January 2009, 09:19
hi everybody..
Yes, now i m getting.
but the problem is..
we have three type of leave CL, SL, PL
But how to calculate total pending leave as per leave code.
SUM of CL pending
SUM of SL pending
SUM of PL pending
Here I am getting the SUM of Pending leave of that leave code what is my first leave code as pending in my table.
Plz tell me how to get as per above mentioned code, how i can get SUM of pending leave as per leave code for all leave code.

Thanks in advance.

manish2111
29th January 2009, 19:53
Hi everybody.
now everything is fine. except one thing ???
I am using on.main.table, in this case it SUM all CL Pending when session starts and it stores the Total CL Pending = 4(e.g.) out of total Leave = 7
Means Leave Bal. = 7-4 = 3
But lets say after starting the session I have applied for 3 leaves i.e. now Total Leave Bal. = 3-3 = 0.
But as this is the same session so it has still stored 3 CL Bal. and still it is allowing to apply more 3 leave and so on.
When I exit and reopen the session then this time Leave Bal. = 3-3 = 0. So it will not allow.
So what should i do, so that this problem should not come. That is say earlier Leave Bal. = 3 and we applied for more 3 leave so after saving the record leave bal. should be 0 (ZERO) not 3. plz help me.
Thanks in advance.

wiggum
30th January 2009, 12:46
Recalculate the leave balance in the section after.update.db.commit

manish2111
31st January 2009, 11:07
I have recalculated the leave balance in the section after.update.db.commit
But for first record leave.bal is not getting calculated, but for second leave.bal is calculating as per below.
after.update.db.commit:
leave.bal = cl_bal - leave.pend
what should I write then ??
Thanks in advance.

manish2111
2nd February 2009, 12:18
I have recalculated the leave balance in the section after.update.db.commit
But for first record leave.bal is not getting calculated, but for second leave.bal is calculating as per below.
after.update.db.commit:
leave.bal = cl_bal - leave.pend
what should I write then ??
Thanks in advance.