mvanta
10th July 2019, 15:34
Hello all.
We try to create a script to limit the selection option of the user on a session.
we have a field that is zooming in tcemm170 and returns the company number. We want to give to the user the option to select either the logistic or the financial company.

we have the financial company from the code comp=get.compnr() and the logistic from the sql below,
extern domain tcncmp comp

select tfgld003.bcmp
from tfgld003
where tfgld003._compnr=:comp and tfgld003.indt=0
selectdo
endselect

But when trying to use query.extend.where.in.zoom we get no result and a lot of errors.
for example if we try this code,
query.extend.where.in.zoom( "tcemm170.comp= :comp" )
we get the error,
Process 431 - Error : SQLState HYL04: External variable 'comp' not found (301) (rcdset.onfinddata() in object ottstpstandard)
We are about to give up!
Please advice,

Maria

Ajesh
10th July 2019, 17:57
try doing something like



query.extend.where.in.zoom( "tcemm170.comp in (select tfgld003.bcmp from tfgld003 where tfgld003.indt = 0 )" )



Is there a need to use get.compnr() as by default the table would look in the current company?

mvanta
10th July 2019, 19:03
Thank you for your help and for answering!
:-)
It works but it returns only one of the companies, the logistic.
We need to have as well get.compnr() because the user should have 2 options:either the financial or the logistic.
We could get the financial from this sql,
select tcemm170.comp
from tcemm170
where tcemm170.comp = :comp
selectdo
endselect

but how we could combine it to your code?

Regards,
Maria

Ajesh
11th July 2019, 12:12
I think the better option is to build a customized session, txemm1170m00 and in before.program of that session, use



before.program:
import("sess.name",sess.name)
log.comp = get.compnr()
select tfgld003.bcmp:fin.comp
from tfgld003
where tfgld003.indt=0
selectdo
endselect
if sess.name = "XXXXX" then |Where XXXX is your specific session
query.extend.where( "tcemm170.comp = :log.comp or
tcemm170.comp = :fin.comp")
endif

mvanta
11th July 2019, 12:24
Thank you very much for your time!
we will try your suggestion but I think we will get the same error we got before,
Process 431 - Error : SQLState HYL04: External variable 'comp' not found (301) (rcdset.onfinddata() in object ottstpstandard)
weird because comp is declared!

Maria

Ajesh
11th July 2019, 13:35
If you use in

query.extend.where instead of query.extend.where.in.zoom

i mean in the new session which you will create, in before.program, comp should not give an error. I have used it before.

mvanta
11th July 2019, 14:20
Thank you a lot!!!

Regards,
Maria

BaanInOhio
11th July 2019, 19:32
You have to send the converted string to query.extend.where.in.zoom since the zoom session may not know how to handle 'comp'.

query.extend.where.in.zoom("tcemm170.comp=" & str$(comp))

This will append "tcemm170.comp=100" to the end of the query for the zoom session if the 'curr' variable is returned as 100 in the select.

Use 'quoted.string' when building an extension with a string variable. In this example, 'currency' is a string filled before the call.

query.extend.where.in.zoom("tcemm170.fcua=" & quoted.string(currency))