edgar_luna_h
12th May 2005, 12:09
Hello,

We are facing a problem with a multi-occ form, this form has a check box and it is needed to save the current record after the input on this checkbox.

For one record is working using the code below, but the problem is that the following records are not saved at all (I could imagine due to the commit.transaction is de-active the choice "Modify").

And if we tried to start again the "Modify" with execute(modify.set) is giving an error of "Recursion is not yet implemented"

This is the code:
|* Check box field
field.check.box:
after.input:
execute(update.db)

|* Choice Update.db
choice.update.db:
after.choice:
commit.transaction()

Would you please help us with this?.
Thanks in advance,
Edgar Luna.

mark_h
12th May 2005, 15:27
I do not think you need the commit transaction in the choice.update.db. Try that.

v_chandra
13th May 2005, 12:06
Hi Edgar

If the records you are trying to update are of main table there is no need for commit.transaction, BAAN will take care of that.

Also could you tell me whether this check box is there for all the occurence ?, and is it a functional requirement ?. Because as i said if the records are based on main table Baan will automatically commit it all when you hit the choice Update.db through front end.

Jordi.Tolra
17th May 2005, 13:58
Hello,

I am an Edgar colleague, aware of Edgar's problem.
In our program the table which we are trying to update is the main table of the session and the check box field is available for all occurrences,; we should allow the users to click at several occurrences at once.

Thanks for checking,

Jordi Tolrà

Youp2001
17th May 2005, 14:10
I have read this threat several times but now I'm getting lost. What functionality do you want to achieve?

From the reply of Jordi I understand that it should be possible for the user to check the checkbox for several records and after that only those records with a checkbox should be saved. Correct?

In that situation it is not logical to call the update.db in the after.input section, because every time the user checks the checkbox the system will do an update of all occurrences (so it is not possible to check multiple lines before the update takes place).

It is correct that the commit.transaction is not needed as the update.db will take care of that (part of the standard program flow).

If it should be possible to check the checkbox for several lines, why can't you use the standard program logic of Baan and let the system decide when to update the records??

I think you need to supply some more info so other readers understand what you are trying to achieve.

Regards, ,

Youp

v_chandra
17th May 2005, 14:44
Hi


First of all if possible send the screen dump to visualise it better.

Could you answer these few questions :

1. Functionality is that while entering records first time (Insert mode) only the checked
records should be saved and the others should not be. ? Then in that case why
the records are being entered.

2. And What if in add/ edit mode user unchecks the box. should it get deleted or
something?

Basically try to get more functional details about the session. Then it will be easier to provide right solution

Evert-Jan Bosch
18th May 2005, 11:50
If the field "check.box" is not a table field, you must call the function update.occ() to let the 4GL engine know that there is something changed and that the record must be saved to the database. May be that is the solution for your problem?

Some help info about the function:
The 4GL engine automatically detects changes a user makes to a field. However, it cannot detect changes to field values made in the program script. When you modify a field of the main table in the program script, you must call update.occ() to lock the record (delayed lock) and to switch on the update.status flag of the 4GL engine. This ensures when that the database is next updated, the modifications are saved to the database. The database update action can be initiated either by the user or within the script (use execute(update.db)).

Before the update.db command is executed, the user can undo the changes with the recover.set command. If you do not want users to be able to undo changes, you can force an immediate update by calling execute(update.db) in the script.

You can use this function only in 4GL scripts, and only in choice and field sections of those scripts.

Example
functions:
function extern void form.command.X()
{
tiitm001.abcd = 9999
update.occ() | Sets flag to indicate change
execute(update.db)
}

Jordi.Tolra
18th May 2005, 14:15
Hello,

I tried with update.occ(), although the field that we are updating is a table field, and it didn't work.

About the functionallity, we are not inserting records(this is done by a previous process), what we want is update the checkbox field of the existing records. I attach an screen dump of the session: what we want is update the field Compl. What happens is that if we mark the field for several occurrences, when we save, only the first occurence is saved.

I hope I 've been clearer now.


Thanks

Jordi

Youp2001
18th May 2005, 15:35
The functionality you sounds like standard Baan functionality for a multi-occ session.

If the check box is a field in the main table, the user can just check the fields he wants. Any form action (paging through records / groups / end session etc) will automatically cause an update of the records in the table. All changes to the script to achieve this can be removed in my opinion.

Youp

Jordi.Tolra
19th May 2005, 18:10
Hello Youp,
you're rigth, I removed the code and now it works, it saves all the ocurrences at once.
Our problem now is that everytime that we check the field in one occurrence we need to update another table; and this should be done before we check the field in another occurrence.

Regards

Jordi

v_chandra
20th May 2005, 06:45
Hello Jordi

To update the other table you can write the function depending on your functionality in the when.field.changes section of the check.box.field, for both Yes/ No value. In my opinion that will be the current occurence. But remember the check box field is not yet updated in its table till the user saves the record.

Regards
Vinod

Evert-Jan Bosch
20th May 2005, 15:04
Updating other tables in when.field.changes is not a good idea.
What to do when the user does not press the save button but cancels the session? Then you have updated the other table, but the main table itself is not updated...

Evert-Jan Bosch
20th May 2005, 15:13
May be following idea will work?

Functional
May be it is possible to save the record when you change the (mouse) pointer from one occurrence to another occcurrence. At moment of saving the record the other table must be updated as well. In this way you keep the record and the other table in one transaction. And the other table is updated before you change the checkbox of another record.

Technical
Consists of 2 parts:
1. In field.all section, before.input store the current occurrence number (tools var actual.occ). Whenever the number changes execute a save action: execute(update.db). I'm not very happy with this solution. May be others have better ideas?
2. In after.choice of update.db section program the update to the other table. No retry point or commits must be programmed in that section.

Note: when no solution can be found for multi occ edit, you can always make it a single occ session :)

Hope this will help you.
Is the technical explanation detailed enough?

Hitesh Shah
24th May 2005, 19:20
I think u have 2 choice.

1. Write the code 2 update the other table in after.rewrite section without db.retry.point and commit transaction() . If u write execute(update.db) in code , ur record pointer will get lost. So I wont recommend u to use the , execute(update.db) in a field section

2. Alternately , u can update the other table in after.update.db.commit section with retries and commit .

Think the first option is best.

Evert-Jan Bosch
25th May 2005, 11:51
Yes, I advised the wrong section.
after.rewrite is the right place.