h3nry_99
23rd April 2002, 11:02
Hi All,
Could someone give me sample script for validation on inputing something, ex: item data. So if user input other item than in master item data, message windows pop up and after that the cursor back to that field again. I allready try, but the cursor is still continue allthough we input the wrong data after pop up a message.
Thanks,
Caner.B
23rd April 2002, 11:30
I think that "set.input.error("")" will do the work
below is sample script for this, put this in the check.input section of your field.
select tiitm001.item
from tiitm001
where tiitm001._index1 ={:item}
selectempty
message("No Item Found")
set.input.error("")
endselect
Caner
h3nry_99
23rd April 2002, 12:49
Thanks for respon,
But the cursor still go to the next sequence....So error or not, validation not working....
Other idea ?
Regards,
Smiffy
23rd April 2002, 13:00
You need to use set.input.error(""), but can only use in the check.input section of your field.
Firstly do your validation
If it fails pop up a message
after the message use set.input.error("")
It definitely works. In Baan V, before the main table is updated, check.all.input() is automatically called to re-check all validations for the fields (including multi occurence).
In Baan iv this is not the case, but you can add check.all.input() to your before.write & before.rewrite sections (even though a warning message tells you otherwise)
good luck
NPRao
23rd April 2002, 21:14
In BaaN-5 onwards you have new options in the DAL -
Property hooks are hooks that relate to a specific property (that is, a table field).
Property hooks replace the check.input event sections for fields of the main table. If there is a DAL for an object set, the property hooks are called to perform the necessary field checks. Any check.input sections in the UI script are ignored. So, if a UI script contains check.input sections for fields of the main table, you must replace these by property hooks in the DAL. In the UI script, check.input sections are retained for non-database form fields. Such sections are executed even if a DAL exists.
There are two property hooks:
§Property hook fieldname.check() is called by the standard program when inserting or updating an object
§Property hook fieldname.set.defaults() is called by the B3 through a BOI in case of a DAL_NEW or DAL_UPDATE
fieldname.check()
Syntax
function extern long ppmmmvss.bbbb.check( long has_changed [, long element] )
Description
Use this hook to program logical integrity rules for a specified field. The function name is ppmmmvss.bbbb.check(), where pp is the package code, mmm is the module code, vss is the table number, and bbbb is the field name.
Arguments
has_changed This indicates whether the value of the field has changed. It is set by the standard program and can be tested in the hook. Possible values are:
0 not changed
DAL_NEW change caused by inserting a new object
DAL_UPDATE change caused by updating an existing object
element This is set for array fields only. It indicates the index of the array element that must be checked.
Return values
This hook returns 0 if the value of the field is accepted. It returns a negative value (DALHOOKERROR) if the value is not accepted.
Example
A property hook programmed in DLL tdsls040:
function extern long tdsls040.oqua.check(long has_changed)
{
if tdsls040.stat = tdsls.stat.invoiced and
has_changed then
dal.set.error.message("tdsls44041")
| Order is already invoiced, cannot change
| quantity
return(DALHOOKERROR)
endif
...
return(0)
}
h3nry_99
24th April 2002, 04:36
Dear All,
Thanks for all of you for helping me solving my problem. The command "set.input.error("")" is working after I change the session from after.input to check.input.
Thanks a lots,
ClausStr
24th April 2002, 10:55
one final comment, no need for both message an set.input.error, use message code as an argument to set.input.error() instead.
Syntax
void set.input.error( string messcode(14) [, arg, ...] )
Description
This causes the standard program to display the specified error message and to force input again in the same input field. If you specify an empty string, no error message is displayed.
Arguments
messcode The message code of the required message. This must be defined in the data dictionary. This argument can contain format characters for parameter substitution.
arg ... The messcode argument can contain format characters for parameter substitution. The values which must be substituted are specified in the 2nd, 3rd, ... arguments of the function. The number of these arguments is variable. For details about formatting a string see the sprintf().
Notes
You can use set.input.error() only in check.input event sections of a 4GL script. The error message is displayed after the entire section has been executed. Consequently, you cannot display two error messages with this function. The predefined variable stp.check.input.error indicates whether set.input.error() has been called.
Before a choice.update.db (except at delete) section, all check.input sections of all fields are executed. If one error is set with set.input.error(), the remaining sections are not executed. In a type 4 program, which does not support choice.update.db, you can call the function check.all.input() in a before.choice section. With the predefined variable before.update.check (read-only), you can control if the input check is executed before update or during input.
Context
4GL library function.
You can use this function only in 4GL scripts, and only in check.input subsections of those scripts.
See also
dal.set.error.message
Example
field.pctst900.item:
check.input:
if before.update.check then
set.input.error("pctsts0001") | before update
else
set.input.error("pctsts0002", e) | during input
endif
nizamudeen
24th April 2002, 11:43
you can also use the function INPUT.AGAIN
This function can be called after the input given by the user fails the validation check and the user needs to enter data again.
Regards
Smiffy
24th April 2002, 16:35
When we use set.input.error, we can only get the first 14 characters of a message defined in the data dictionary to be diplayed if we use the message code as an argument. This is not very much use at all. This is why I suggested using the "" option and displaying the message separately.
cheers
gentercz
26th April 2002, 14:44
use to.field( field ) for switching to another field
SYNOPSIS
void TO.FIELD( field )
DESCRIPTION
The function TO.FIELD transfers the control of the standard
program to the specified field after input or display of the
current field. This escapes the order specified in the form
definition. The field can be specified with the field name or
with a number which corresponds with the ordering number defined
in the form definition.
After handling the specified field, control is given to the field
following this field, according the field order.
USE
The function TO.FIELD may only be used in the subsections
after.input, after.display and after.field.
jochen