en@frrom
2nd July 2009, 15:06
I have a multi occ maintain session with main table. In the check.input section of one of the fields, I check if the value is not yet inputted for that view field (group). Problem is that the user might add several records at once without saving them one by one. The standard program will save all the records in buffer only when hitting the save button (or a different command is activated which triggers a db.insert/dal.new). When I query the (main) table, it will obviously not give me the newly entered records, since they are not yet updated to the table. I do however need to check against their value as well.

Is it possible to "approach" the buffered records before they are being saved?

And if not, is there any way to force Baan to save each record on the fly; I.e. upon hitting the 'tab' key on the last input field, just before moving to the next new record, forcing the system to save the record.

I know I could force the latter in the field section of the last or first input field of the record, but I am looking for a more elegant and neat solution.


Thanks in advance!


Regards,
Eli Nager

mark_h
2nd July 2009, 15:22
In Baan 5 doesn't it run the check input for each field as it is entered(saved or not saved)? On my 4c4 sessions I use the check input for this all the time.

en@frrom
2nd July 2009, 15:29
Hi Mark,

I think you didn't understand my issue. I will try to explain better.

While inserting records, let's say I am inserting 3 new records without saving in between. These three records are then meanwhile stored in the buffer for update (or abort). Now, upon inserting the 3rd record, I want to check my input value against all the previously entered values; both the ones already saved and the ones waiting in the buffer to be saved. How can I approach those records.

For instance, let's say that I am inputting a series by machine, yet I am not allowed to insert any previously inserted series. It is basically the functionality of an index field for which standard Baan then checks agains all records - both the ones saved already and the ones buffered - if the unique key has been entered already. Only in my case it does not concern an index key (and no, I can not add the key to the index...).

Thanks,
Eli

mark_h
2nd July 2009, 15:33
Gotcha - I understand now. Let me go look for some code that might help.

en@frrom
2nd July 2009, 15:37
Thanks, you're the best!

george7a
2nd July 2009, 15:44
So you want the field to be unique but not a key, right? In other systems it is easier to do so, it is just a check-box next to the field. I am still searching for it in Baan ;)

mark_h
2nd July 2009, 15:45
Not sure if this helps, but the code below is one way of determining the next line number using the table and the fields on the form. Yes - if you have one record on the form you would end up searching it twice(once from the table and the second time from the filled occurance search). Maybe you can adapt this to do what you are looking. In your case you would take the current occurance and bounce it against the table and then against the other records on the current display.


field.tdudi010.line:
before.input:
if update.status = add.set or update.status = modify.set then
tdudi010.line = get.line()
attr.input = false
endif


function long get.line()
{
line = 0
select max(tdudi010.line):line
from tdudi010
where tdudi010._index1 = {:tdudi010.orno}
selectdo
selectempty
endselect
search.last.used.seqn.on.screen()
line = line + 1
return(line)
}
function search.last.used.seqn.on.screen()
{
| This will allow you to search the screen fields not
| yet saved
long i
for i = 1 to (filled.occ - 1)
do.occ(i ,check.last.used.sern)
endfor
}
function check.last.used.sern()
{
if tdudi010.line > line then
line = tdudi010.line
endif
}

en@frrom
2nd July 2009, 15:47
So you want the field to be unique but not a key, right? In other systems it is easier to do so, it is just a check-box next to the field. I am still searching for it in Baan ;)

Something like that. It actually concerns a date field. Each record contains a start date and an end date (similar to BP's, BOM lines, etc). When the user enters a start date, I want to check if the entered start date falls within a previously entered start-end date range. If yes, an error appears.

en@frrom
2nd July 2009, 15:50
Not sure if this helps, but the code below is one way of determining the next line number using the table and the fields on the form. Yes - if you have one record on the form you would end up searching it twice(once from the table and the second time from the filled occurance search). Maybe you can adapt this to do what you are looking. In your case you would take the current occurance and bounce it against the table and then against the other records on the current display.


field.tdudi010.line:
before.input:
if update.status = add.set or update.status = modify.set then
tdudi010.line = get.line()
attr.input = false
endif


function long get.line()
{
line = 0
select max(tdudi010.line):line
from tdudi010
where tdudi010._index1 = {:tdudi010.orno}
selectdo
selectempty
endselect
search.last.used.seqn.on.screen()
line = line + 1
return(line)
}
function search.last.used.seqn.on.screen()
{
| This will allow you to search the screen fields not
| yet saved
long i
for i = 1 to (filled.occ - 1)
do.occ(i ,check.last.used.sern)
endfor
}
function check.last.used.sern()
{
if tdudi010.line > line then
line = tdudi010.line
endif
}


Mark, thanks for digging this code up for me. I have thought of that workaround, but I don't like it so much. I wondered if there was not a standard Baan way to trigger it. After all, like I said, standard Baan does perform this functionality when it concerns fields which are part of an index...

mark_h
2nd July 2009, 15:59
Yeah - there probably is a better way, but I have not found it. Hopefully George can figure it out. I have another session with a start and end date where I just make sure they do not overlap. For the dates I only check the saved record in the table. Then when they hit the say I do some other checking which generates an error if they overlap.

george7a
2nd July 2009, 16:04
I think the proper place to do this is in the fieldname.check() (http://www.baanboard.com/programmers_manual_baanerp_help_functions_dal_fieldname_check) DAL function. As it is written in the documentation: "Use this hook to program logical integrity rules for a specified field".

Hitesh Shah
2nd July 2009, 18:34
In Baan IV we do this using do.all.occ / do.occ / on.old.occ , on.main.table functions . Are these or similar functions not available ur version .

amitmmokashi
3rd July 2009, 07:39
Hi Eli,
I think you can build some logic using the standard function activate.search(). This has to be done in the on.input section of the field.

Regards,
Amit

sajjadnb
7th July 2009, 09:46
Hi Eli,
try using the function enable.save.on.occ.change() in the after.form.read: section of ur program script, this will save an occurrence at the time the u selects or moves to another occurrence.
Further u can use fieldname.check() DAL function to check the value from the table.

hope this helps.

Regards
Sajjad Baig

en@frrom
7th July 2009, 10:26
Hi Sajjad,

Thanks for your suggestion. The function enable.save.on.occ.change() would be exactly what I looked for, except that it does not seem to exist? (at least for Baan V) I get compilation errors when using the function...

Regards,
Eli

Hitesh Shah
7th July 2009, 19:19
save.rcd.main and restore.rcd.main (http://www.baanboard.com/baanboard/showpost.php?p=101896&postcount=4) available in Baan IV and possibly in ur version also may help.