RobertP
12th January 2023, 14:42
We currently have 3 custom tables:
A - grand parent
B - parent
C - child
Main session (based on A) has 2 satellite sessions - List of B and List of C
Not every B has C. B could have multiple C.
[ A similar example is baan4 purchase/sales orders. A - Sales Order B - Positions (per A), C - Deliveries (per B) ]
The satellite sessions work fine listing ALL B and C separately. But, if user has selected a record in SAT B, then I would like to apply a filter in SAT C (based on selected record).
[ In the example of sales orders (A) , if user has selected position 30 (in SAT B) and then clicks SAT C, the displayed deliveries should be filtered according selected SO Pos 30 ]
I'm not [yet] familiar with advanced MMT handling, so clear instructions and/or example would be appreciated.
OmeLuuk
12th January 2023, 15:49
I think what you want is possible, but you will have to work with import/export variables to the driver (session based on A).
I have a situation where one session handles two sets of data depending on session name (use same script). In before program you can set correct query.extends based on imported variables. Satellite C can have something like
before.program:
query.extend.select("tableA.*, tableB.* ")
query.extend.from("tableA, tableB ")
if is.mmt.satellite() then
import("tableA.fld1", tableA.fld1)
import("tableB.fld2", tableB.fld2)
endif
if prog.name$ = "driveC" then
if not isspace(tableB.fld2) then | mmt mode
query.extend.where("tableC.fld1=tableA.fld1 and tableC.fld2=tableB.fld2")
else | stand alone mode
query.extend.where("tableC.fld1=tableA.fld1")
endif
endif
On changes you in DriverB you can update the variable in the parent, and when switching to DriverC again import the variables, perform a rebuild.query with the new values and execute a FindFirst.
mark_h
12th January 2023, 17:25
Like Omeluuk said it is possible. In 4c4 I recall in one place what we did on something like this was create a new session and attach it to like b. Then while in B you could highlight a line do tools zoom and see a filtered list based off order and line. Just a matter of getting all the components setup and passing variables in 4c4.
mark_h
12th January 2023, 17:26
Of course now that I posted my solution might not be too good for LN and MMT type sessions.
RobertP
12th January 2023, 18:46
Thanks Omeluuk and Mark_h
The problem is a bit more complex now. Keeping it simple. When MMT session "A" is started, the 2 SAT sessions are automatically started.
Now that they are started, I actually have 2 situations:
1 - As described above, user selects record in SAT B. Clicks the form SAT C. It is initialized. Here I can add the import as you said (I think - not sure if comms between SATS are even possible.. a bit lost here) to the before program. But, now if user clicks back to SAT B, selects a different record, then clicks back to SAT C.... how to reinitialize SAT C? Using satellites seems way to awkward. If these were forms, then I'd have the option to use before/after form sections. I wish there were similar sections before/after satellite
2 - [Solved - See below] Here is an even more simple situation. In SAT C user makes a change which causes an update to table B. However, when user clicks back to SAT B, the records have not been refreshed automatically, so old values are still displayed. Again, what's missing is 4gl sections for handling clicking between SAT's.
Do you have any further input on this?
Thanks again.
RobertP
12th January 2023, 19:13
FYI, I'd rather not consider BMS (and prcm.XXXXXXX) solutions/functions. Just too complex.
RobertP
12th January 2023, 19:28
I have an update on #2 - refreshing SAT B when changes made on SAT C.
In SAT C session I added the following code.
choice.update.db:
after.choice:
synchronize.satellite()
refresh.parent(-1)
Parent session A is updated and SAT B is also refreshed automatically. this is progress.
Situation #1 is still pending.
OmeLuuk
18th January 2023, 17:10
Situation #1 is still pending.Did you check for the maintable:after.form.read:
add.sync.fields.nokey(session.child1, field.here, field.there, field.here, field.there)
add.sync.fields.nokey(session.child2, field.here, field.there, field.here, field.there)
After a field changed in MMT:after.display:
synchronize.satellite()In the satellite I use something like choice.find.data:
before.choice:
if prog.name$ = satellite and ppmmmyyy.key1 <> key.variable and is.mmt.satellite() then
query.extend.where("ppmmmyyy.key1=:key.variable")
rebuild.query()
choice.again()
endifand in the zoom.from.all:
on.entry:
if import("var1", var1) = 1 and import("var1", var1) = 1 then
use.vars.to.do.something()
execute(find.data)
endif Then try debugging and see what is happening when switching from sattellite 1 to 2 and back. I think you will go pass the zoom.from.all section where you can also fix the query by executing the find data section.