maneesh_jain
7th July 2008, 18:24
Hi,

I am reading table tfacr200 in one of the funcions in my script. From this function, I call another function and in the second function, I need to read tfacr200 again with some different conditions. What should be the right syntax so that I don't mess up the first selectdo? So, my code is like:

function1()
{
select field1, field2
from tfacr200
where tfacr200_index2 = {:val1, val2...}
selectdo
function2()
endselect
}

function2()
{
select field3, field4
from tfacr200
where tfacr200_index1 = {:val3, val4...}
selectdo
endselect
}

kbabu1
8th July 2008, 13:54
eg:

function1()
{
domain XXXXX field3
domain YYYYY field4

select field1, field2
from tfacr200
where tfacr200_index2 = {:val1, val2...}
selectdo
function2(var3, var4, fieldd3, field4)
endselect
}

function2(domain <domain> var3, domain <domain> var4, ref domain XXXXX o.field3, ref domain YYYYY o.field4, ...)
{
select <tablefield3>:field3, <tablefield4>:field4
from tfacr200
where tfacr200_index1 = {:val3, :val4...}
selectdo
endselect
}

mark_h
8th July 2008, 15:42
Or use an alias in the second select statement.

a_choudhury
8th July 2008, 19:19
You can use the function on.main.table() to read the same table.

shah_bs
15th July 2008, 19:12
This is valid for BAAN IVc3 at least. You should have this include file in your system. Do as follows:

First, add the command in for the include:

#include "itfgld0038" |Store/restore buffer


Then in your function2(), do as follows:

function2()
{
itfgld0038.dim.rcd(ttfacr200) |- This creates a record buffer
itfgld0038.store.rcd.fields(ttfacr200) |- This saves the current record
|- -- this is what was read in function1()

|---- Here, if required, initialize the program variables of the
|---- fields you need.

select field3, field4
from tfacr200
where tfacr200_index1 = {:val3, val4...}
selectdo
|---- Here, if required, save the fields you need in the program variables.
endselect

itfgld0038.restore.rcd.fields(ttfacr200) |- This restores the current record
}