en@frrom
19th August 2003, 15:01
Hello all,
I am new at this forum; urging you for help with the following matter:
I am building a display session with six forms, which is displaying data from one main table, yet with different selection (filtering) per form.
The table is structured with field 'record type' as primary key (index), and for each form, the records from a different record type must be displayed.
The table is a table with total sales-figures per sales-to bp, parent bp, company, etc. per period/year. When entering the first form I will get the records with record type 1, then when tabbing to the second, I will get all record type 2 records and so on for all six forms (-> record types).
I also have to allow a selection for the user on each form to give a range of periods/years which have to be displayed; AND I have to allow an option (form option) to include certain records which are not being selected by default.
How do I program this in such a way, that I will always get my correct data in each form, also when tabbing a lot through the forms?
I never yet worked with query extends. I understood you can only use them in before.program. So I probably have to use variables in my query.extend.where() which are being changed in the before.form of each form? Or maybe there are better ways?
Any help/suggestions would be highly appreciated!!!!
Warans
19th August 2003, 15:30
I have come across on similar situation...
Here is what I suggest for you:
Since record type is the distinguishing feature on each of the forms....
Use the following section in the program script to filter records on each form:
main.table.io:
after.read:
on case form.curr
case 1:
|** Write condition to display record type 1 records
case 2:
|** write condition to display record type 2 records
....
and so on..
endcase
Hope this helps you out well....
Warans
-----------------------------------------------------------------------------------
Winners don't do different things; they do things differently
-Shiv Kera
-----------------------------------------------------------------------------------
en@frrom
19th August 2003, 17:43
Thanks Warans for your reply!
But what syntax am I supposed to write for each form? query.extend.where(.......) ?? And then which commands do I place where in order to get correct display of my data? Do I use rebuild.query()? execute(find.data)? Both? Other commands? Please help me out more.
Thanks a lot in advance!!
EN
en@frrom
19th August 2003, 17:51
Warans,
I tried what i understood from you:
I wrote a quere.extend.where in the main.table.io after.read. Didn't work. Then I added after each query extend a rebuild.query(), but then I got lots of bw errors saying "Undefined SqlId (0) .. can't continue".
Please help me out.
Tia,
En.
lbencic
19th August 2003, 19:57
Do not mix the main.table.io / after.read / skip.io(''") commands (the older method) with the query extensions that you are trying to use.
Not sure if the problem is some syntax - try blanking out the query extend before rebuilding a new one. You can trace that value in the debugger, so make sure it's filled how you want. query.extension is a string array.
It may also be the section you are calling from. This does not need to be called from main table io / after read, and I suspect that it should not go there because the mode is in read state. Probably need a neutral section where the data is not being read. Possibly be better in the form.* sections, you may need to play with that.
Here's syntax that worked for someone else, very similar: link to post on rebuilding queries (http://www.baanboard.com/baanboard/showthread.php?s=&threadid=10017&highlight=query)
Warans
20th August 2003, 09:09
En,
lbencic was absolutely right, we should not mix main.table.io and query extend functionality together...
I did not mean that you need to use query extend when using main.table.io()...
The logic what I suggested was a simple one which you can straightaway try it out. Like your grouping, we have grouped records based on group number in our 5 forms....
Since the distinguishing factor in your case is, record type (which must sure be a field in the main table which you're trying to use..),
Just try this and let me know what you found:
main.table.io:
after.read:
on case form.curr
case 1:
|* I'm assuming record type 1 for form1
if table_id.field_id <> 1 then
skip.io("")
endif
break
case 2:
|** write condition to display record type 2 records
....
and so on..
endcase
Instead of hard-coding like 1 for record type, use appropriate 'DEFINED' constants based on your needs...
Since, I did not know exact details of your table, I have given it in general...you need to build your own logic of distinguishing the record type records on each form.
The code part (if condition) what I have given above is just an assumption; you can write your exact required condition and try it out.
Warans
klixy23
20th August 2003, 13:16
I had a problem like yours and here is my solution. Perhaps it helps you.
|****************************** FORM SECTION ***************************
form.1:
before.form:
query.extension = ""
query.extension = "tisfc001.osta <= tcosta.printed"
rebuild.query()
execute(find.data)
form.2:
before.form:
query.extension = ""
query.extension = "tisfc001.osta > tcosta.printed and tisfc001.osta <= tcosta.ready"
rebuild.query()
execute(find.data)
With change to another form were build a new query in the before.form section and this works for me.
en@frrom
20th August 2003, 13:44
Thanks all for the replies.
Does query.extension work in BaanV, or do I use query.extend.where()? In which sections can the query extensions be used? Because I understood initially that they work only in before.program; but now I see I can simply put them in the form sections and add a rebuild.query() after each modification?
I am going to try to get around with all the bits of info and advice you all gave me so kindly, and will keep u updated with the result.
For now one more thing: I want on each form to select all the relevant records (based on table (index) field record type, but want to point at the record which I was pointing at when leaving the first form. In other words on the first form where I have record number 1 (table field) i am currently holding by record no. 523, then I swtch to other forms. For record type 1 I have the BP, parent-BP, area etc. Now I always want to get the pointer for the current form to the relevant parent-BP, area etc (form 1: per bp, form 2: per parent, form 3: per area etc) based on the pointed record when leaving the first form. So I save the fields in tmp.fields in the after.form.1, but then how do I point tot he relevant record for each form? How do I do that?
Thanks again in advance! It is much appreciated!!
En.
lbencic
20th August 2003, 17:08
Yes, in Baan V use the query.extend.where - heres a link to query.extend.where syntax (http://www.baanboard.com/programmers_manual_baanerp_help_functions_sql_query_extensions_query_extend_where) .
This will fit with klixy's example, but if you use the EXTEND_OVERWRITE mode, you probably don't have to blank the string before you fill it.
For starting at a specific record, I have not tried, but maybe save the record you want before you refresh, then look it back up again and try the make.current() (http://www.baanboard.com/programmers_manual_baanerp_help_functions_form_and_form_field_operations_make_current) commmand, it seems to do what you need and is ok in that section. Let us know if that works :)
en@frrom
20th August 2003, 20:11
I didn't succeed with make.current(). What happened was: when tabbing from first forms to others, I got pointed at the correct field (parent, area etc) but the records with record type 1 -> first form were displayed instead the correct record type.
Maybe I did something wrong? How am I supposed to "look the record back up" as you adviced me?
p.s. I posted a new post just now with a better, more detailed explanation of the structure and requirements for this session, and the problems I encounter, just because I see that I am having many problems with this session :confused: , and this forum - which i've just discovered yesterday - seems amzing help!!
Kind regards,
En.