JRussell
7th November 2002, 13:32
Hi,

I am trying to limit the display of records. I have a session (A) where I select a value for a field. Depending on this field I want only those records that have this field as part of its index to be displayed.

Eg.

Session (A)parent
fieldA=machine

Session (B) child
display recs where "machine" equals part of the index.

The index has two parts: Machine Element,Reason code.

I export the value of machine to the child session(B). However I am unsure how to handle searching the child table to get the right results.

EG of data in child:

Machine Element, Reason, Desc
Mc1, R1, Mc1r1 combo
Mc1, R2, Mc1r2 combo
Mc2, R1, Mc2r1 combo

So if I enter "mc2" in parent session, I only want the Mc2 R1 combo record displayed.

My select statement looks like this:

select wawti712.*
from wawti712
where wawti712.mcelem = :mcelement
and (wawti712.reasonco >= "aaa") OR (wawti712.reasonco <="zzz")
selectdo
endselect

The correct recs are not selected and displayed because of the reason part of the index I think

Can anyone advise?
Thanks

jaapzwaan
7th November 2002, 14:32
In BaanERP, try these functions in your before.program:
query.extend.where (http://www.baanboard.com/programmers_manual_baanerp_help_functions_sql_query_extensions_query_extend_where)

The Baan IV variant is less flexible: it is a string that can be set:
query.extension

So it is either


query.extend.where("wawti712.mcelem = " & quoted.string(imported_mcelem))


or


query.extension = "wawti712.mcelem = '" & imported_mcelem & "'"


(I hope there are no quotes in the imported_mcelem. In ERP you can solve this with the function qouted.string, which is not available in Baan IV.

Regards,
Jaap Zwaan

evesely
7th November 2002, 15:51
Another option is to use the store.occ.max() and store.occ.min() (http://www.baanboard.com/programmers_manual_baanerp_help_functions_db_operations_store_occ_maxmin) functions.

Grace Li
8th November 2002, 16:58
Change OR to AND. Does it work?

nick_rogers
8th November 2002, 21:05
Hi there is an easier way. Make the subsession that is zoomed to a session with the maintable as wawti712. Then in the maint.table.io section -

after.read:
if wawti712.mcelem <> exported.machine.value
skip.io("")
endif

This will only display the records with the wanted value