outra9e
3rd July 2002, 12:16
Once again I am having problems with a function that I have written:

here it is....
****************field******************
field.tdsls901.sord:
before.input:
import("tdsls040.orno",tdsls901.sord)
check.input:
if not tdsls901.sord.0 then
so.is.zero()
endif

****************function***************
function so.is.zero()
{
if so.used.check() then
set.input.error("tdsls90003")
endif
}



function domain tcbool so.used.check()
{
SELECT tdsls901.sord
FROM tssma912
WHERE tdsls901.sord = :tdsls901.sord
selectdo
return(true)

endselect
return(false)

}
I am getting compilation errors...

Any ideas?

Cheers:confused:

FransG
3rd July 2002, 13:29
What compilation errors do you get? Is the problem in the following part:

****************field******************
field.tdsls901.sord:
before.input:
import("tdsls040.orno",tdsls901.sord)
check.input:
if not tdsls901.sord.0 then
so.is.zero()
endif
if not tdsls901.sord.0 then ???? The .0 part???

outra9e
3rd July 2002, 13:34
Im sorry

initially I had ...

instead of;
If not tdsls901.sord.0 then

I had;
If :tdsls901.sord <> 0 then

but either way it was giving me errors,

see attached...

Cheers

Youp2001
3rd July 2002, 14:32
The correct syntac should be:

check.input:
if not tdsls901.sord then
so.is.zero()
endif

In your example you write tdsls901.sord.o which is a variable that is probably not declared. In the other example you use :tdsls901.sord. The : is only used in queries to make a difference between variables read in your query and variables from outside the query so,

tiitm001.item = "anyitem"

select tiitm001.item
from tiitm001
where tiitm001.item = :tiitm001.item

The : means the program variable should be used so in this case value "anyitem". If the : is not used in the query the value read by the query itself will be used so the where-clause is also true.

Hope this helps.

Youp

grzegorz
3rd July 2002, 15:03
Maybe the problem is in select .. FROM wrong table?

outra9e
3rd July 2002, 15:38
Guys

I originally had the function working.

What it did was to look in the table and if the SO number that had been selected was already present then it threw up an error message.

What I then did was add the functionality for this not to happen if the SO number was 0 because 0 can be used more than once, here is the original code...

****************field******************
field.tdsls901.sord:
before.input:
import("tdsls040.orno",tdsls901.sord)
check.input:
if so.used.check() then
set.input.error("tdsls90003")
endif

****************function***************

function domain tcbool so.used.check()
{
SELECT tdsls901.sord
FROM tssma912
WHERE tdsls901.sord = :tdsls901.sord
selectdo
return(true)

endselect
return(false)

}

alejandro
3rd July 2002, 15:54
function domain tcbool so.used.check()
{
SELECT tdsls901.sord
FROM tssma912
WHERE tdsls901.sord = :tdsls901.sord
selectdo
return(true)

endselect
return(false)

}



You cannot select a field from a different table
tdsls901.sord field is not in table tssma912

MariaC
3rd July 2002, 16:01
Try this:

field.tdsls901.sord:
before.input:
import("tdsls040.orno",tdsls901.sord)
check.input:
if not (tdsls901.sord = 0) then
so.is.zero()
endif

grzegorz
3rd July 2002, 16:05
Once again,

if you have code, as you wrote :

If :tdsls901.sord <> 0 then
^^^
the : is really unexpected. Symbol :tdsls901.sord has no sense out of select statement.

If it is not the problem, please send once again the current code with line numbers and error report.

outra9e
3rd July 2002, 16:50
Guys

Once again thank you for all your help, here is the code that has worked for your interest...
***************** field section ****************

field.tdsls901.sord:
before.input:
import("tdsls040.orno",tdsls901.sord)
check.input:
if tdsls901.sord <> 0 then
so.is.zero()
endif

***************** function section ****************

function so.is.zero()
{
if so.used.check() then
set.input.error("tdsls90003")
endif
}



function domain tcbool so.used.check()
{
SELECT tdsls901.sord
FROM tdsls901
WHERE tdsls901.sord = :tdsls901.sord
selectdo
return(true)

endselect
return(false)

}

*******************************************
:cool: :D :cool: