Eddie Monster
8th August 2003, 18:52
I am trying to create a session that allows our HR department to track Vacation hours by Salaried Employee. I have created a table (tiosd000) that stores:
tiosd000.emno - employee number (indexed)
tiosd000.year - year vacation is taken (indexed)
tiosd000.date - date vacation is taken (indexed)
tiosd000.evac - employee vacation taken
tiosd000.epto - employee paid time off taken
tiosd000.flag - flag to prevent modifcation of record after initial entry
Here is my code to date:
|******************************************************************************
| Written by: Eric Edder
| Request: TR 964
|
| This session processes employee Vacation and Paid Time Off (PTO) balances.
| There are two different session, one for hourly employees and the other for
| salary employees (this session). Hourly employees vacation/PTO balances are
| updated based on hours accounting records coded with the indirect tasks for
| Personal Time and Vacation. Salaried employees are updated separately by HR
| data entry.
|
|****************************** DECLARATION SECTION ***************************
declaration:
table ttccom001 | Employee Master
table ttiosd000 | Salaried Employee Vacation/PTO
| Selection Criteria
| Working Storage
|****************************** PROGRAM SECTION ***************************
|****************************** ZOOM FROM SECTION ***************************
|****************************** FORM SECTION ***************************
form.1:
init.form:
get.screen.defaults()
|****************************** CHOICE SECTION ***************************
choice.update.db:
before.choice:
tiosd000.flag = 1 | Sets flag from 0 to 1. In the Form Field
| section it is set not to allow input into
| the field if this flag is 1. This prevents
| the user from changing the data and not having
| the Vacation/PTO balances modified to follow.
|****************************** FIELD SECTION ***************************
field.tiosd000.emno:
after.input:
get.emno.data()
field.tiosd000.epto:
after.input:
execute(update.db)
|****************************** MAIN TABLE SECTION ***************************
main.table.io:
after.read:
get.emno.data()
after.write:
recalculate.vacation.pto()
|****************************** FUNCTION SECTION ***************************
functions:
|******************************************************************************
| This function pulls the employee name, vacation balance and PTO balance from
| the employee master and displays them on the form.
|******************************************************************************
function get.emno.data()
{
select tccom001.nama, tccom001.evac, tccom001.epto
from tccom001
where tccom001.emno = :tiosd000.emno
selectdo
display("tccom001.nama")
display("tccom001.evac")
display("tccom001.epto")
endselect
}
|******************************************************************************
| This function deducts the Vacation/PTO from the balance in the employee
| master and then updates the employee master with the new value.
|******************************************************************************
function recalculate.vacation.pto()
{
select tccom001.evac, tccom001.epto
from tccom001
for update
where tccom001.emno = :tiosd000.emno
selectdo
tccom001.evac = tccom001.evac - tiosd000.evac
tccom001.epto = tccom001.epto - tiosd000.epto
db.update(ttccom001,db.retry)
commit.transaction()
endselect
}
|****************************** END OF SCRIPT ***************************
I am using a type 3 form so that users can see the total vacation balance left as well as the detail transactions showing when vacation was taken. The problem I have is this. The users want the vacation balance to be updated as they enter records. If you enter a line of data the first time after the form opens, the employee master (tccom001) is updated with the vacation taken after you tab past the last multi-occ field for that record. After that it doesn't update at all no matter how many records you put in. I've looked in the Library for Form commands to see if there is something there. Either there isn't or I don't understand some of those commands and thier functionality (very possible). Any suggestions or help would be greatly appreciated.
Thanks in advance!
tiosd000.emno - employee number (indexed)
tiosd000.year - year vacation is taken (indexed)
tiosd000.date - date vacation is taken (indexed)
tiosd000.evac - employee vacation taken
tiosd000.epto - employee paid time off taken
tiosd000.flag - flag to prevent modifcation of record after initial entry
Here is my code to date:
|******************************************************************************
| Written by: Eric Edder
| Request: TR 964
|
| This session processes employee Vacation and Paid Time Off (PTO) balances.
| There are two different session, one for hourly employees and the other for
| salary employees (this session). Hourly employees vacation/PTO balances are
| updated based on hours accounting records coded with the indirect tasks for
| Personal Time and Vacation. Salaried employees are updated separately by HR
| data entry.
|
|****************************** DECLARATION SECTION ***************************
declaration:
table ttccom001 | Employee Master
table ttiosd000 | Salaried Employee Vacation/PTO
| Selection Criteria
| Working Storage
|****************************** PROGRAM SECTION ***************************
|****************************** ZOOM FROM SECTION ***************************
|****************************** FORM SECTION ***************************
form.1:
init.form:
get.screen.defaults()
|****************************** CHOICE SECTION ***************************
choice.update.db:
before.choice:
tiosd000.flag = 1 | Sets flag from 0 to 1. In the Form Field
| section it is set not to allow input into
| the field if this flag is 1. This prevents
| the user from changing the data and not having
| the Vacation/PTO balances modified to follow.
|****************************** FIELD SECTION ***************************
field.tiosd000.emno:
after.input:
get.emno.data()
field.tiosd000.epto:
after.input:
execute(update.db)
|****************************** MAIN TABLE SECTION ***************************
main.table.io:
after.read:
get.emno.data()
after.write:
recalculate.vacation.pto()
|****************************** FUNCTION SECTION ***************************
functions:
|******************************************************************************
| This function pulls the employee name, vacation balance and PTO balance from
| the employee master and displays them on the form.
|******************************************************************************
function get.emno.data()
{
select tccom001.nama, tccom001.evac, tccom001.epto
from tccom001
where tccom001.emno = :tiosd000.emno
selectdo
display("tccom001.nama")
display("tccom001.evac")
display("tccom001.epto")
endselect
}
|******************************************************************************
| This function deducts the Vacation/PTO from the balance in the employee
| master and then updates the employee master with the new value.
|******************************************************************************
function recalculate.vacation.pto()
{
select tccom001.evac, tccom001.epto
from tccom001
for update
where tccom001.emno = :tiosd000.emno
selectdo
tccom001.evac = tccom001.evac - tiosd000.evac
tccom001.epto = tccom001.epto - tiosd000.epto
db.update(ttccom001,db.retry)
commit.transaction()
endselect
}
|****************************** END OF SCRIPT ***************************
I am using a type 3 form so that users can see the total vacation balance left as well as the detail transactions showing when vacation was taken. The problem I have is this. The users want the vacation balance to be updated as they enter records. If you enter a line of data the first time after the form opens, the employee master (tccom001) is updated with the vacation taken after you tab past the last multi-occ field for that record. After that it doesn't update at all no matter how many records you put in. I've looked in the Library for Form commands to see if there is something there. Either there isn't or I don't understand some of those commands and thier functionality (very possible). Any suggestions or help would be greatly appreciated.
Thanks in advance!