smi4975
25th February 2010, 17:22
Hi,
I have 2 sessions (tiitm2100m000) and (tiitm2101s000). I'm trying to pass in the values from the main session to the subsession when i click a button.
The following is the code for the same:
Parent session:
Choice.user.0:
on.choice:
if marked then
hold.item = tiitm200.item |**** hold.item is defined as extern
zoom.to$("tiitm2101s000",z.session,"","",0)
else
message("Select a Record First")
endif

Subsession
form.1:
init.form:
if background then
import(hold.item,hold.item) |** hold.item is defined as extern
tiitm201.item = hold.item
endif
display.all()

When i debug both the sessions, i see the value being initialized to hold.item in the parent session, but when it comes to the subsession, it losses the value.
I tried to make my subsession as Main session also with start option add.set and even with refresh.. but neither case it does not work.

Can you please help me out what am i doing wrong?
I read in the other posts that it is not necessary to use export and import in both the sessions.
a. i tried using export("tiitm200.item",hold.item),in the main session but while debugging the variable did not even get the value.
b. I also tried using zoom.from.<session> option also but still no luck

It is a very simple passing of values and not very complicated logic also. i just need to pass 3 other values apart from the one stated and then in the subsesison insert other values and save that is it.

I need to resolve this urgently please help me out...

manish_patel
25th February 2010, 17:45
Please try this way. It should work.

Parent session:
hold.item = tiitm200.item
export("hold.item",hold.item)
zoom.to$("tiitm2101s000",z.session,"","",0)

Subsession:
import("hold.item",hold.item) |** hold.item is defined as extern
tiitm201.item = hold.item

smi4975
25th February 2010, 18:23
I tried your option too.. but still it is not working. The value is assigned in the parent session to hold.item, but it is not reaching the subsession. I tried doing the import in the before.program also but no luck. Does it require any special pre-compiler or setting or anything?

mark_h
25th February 2010, 18:52
Is the hold.item declared as an extern variable? Post the declarations and the code around the zooms. This should certainly work.

mark_h
25th February 2010, 18:58
Code from our production system:

|Parent program
choice.user.1:
on.choice:
zoom.item = tipgc520.item
export("zoom.item",zoom.item)
dummy = zoom.to$("tdexi0560m000",z.session,"tdexi0120s000","",0)

| Child subsession
zoom.from.tdexi0120s000:
on.entry:
import("zoom.item",zoom.item)
tipgc001.item = zoom.item
execute(find.data)


The only difference I see is the event.

smi4975
25th February 2010, 19:11
Here is Code for the Parent Session
declaration:

table ttiitm200 | Baan Items with Catalog codes
table ttiitm001 | Items

extern domain tcitem hold.item

choice.user.0:
on.choice:
if marked then
hold.item = tiitm200.item
export(hold.item,hold.item)
zoom.to$("tiitm2101s000",z.session,"tiitm2101s000","",0)
else
message("Select a Record First")
endif


And here is the code for the subsession
declaration:

table ttiitm201 | Catalogwise BOM
table ttiitm001 | Items

extern domain tcitem hold.item

zoom.from.tiitm2101s000:
on.entry:
import(hold.item,hold.item)
tiitm201.item = hold.item
execute(find.data)
display.all()

Please suggest what is that i'm doing wrong!! Both the forms are type 3..has it got to do anything with that?

mark_h
25th February 2010, 19:18
Okay - put quotes around the first hold.item in export and import. It should be export("hold.item",hold.item) and import("hold.item", hold.item).

BaanInOhio
25th February 2010, 19:27
You don't have to do an EXPORT from the caller AND an IMPORT in the called session. I always perform all interprocess communications in the called (child) sub-session. Any EXTERN variable (including table fields) in the parent session can be imported in to the sub-session using:

before.program:

-or-

zoom.from. ---
on.entry:
import("variable.in.parent", variable.in.child)

The "variable.in.parent" must be EXTERN in the parent session or a table field (extern by default). The variable.in.child does not have to be extern.


Sending updated variables from the child to the parent are done in the child sub-session as well, using:

export("variable.in.parent", variable.in.child)

A conversion (if possible) from parent to child or child to parent is done during the interprocess communication (typically between string and numeric).

I always try to limit my interprocess communication to when both parent and child are active, so an 'export' from parent before the child has started can have unpredictable results.

smi4975
25th February 2010, 19:35
It Worked.. I was so dumb to overlook that double quotes. Thank you so much!!!

mark_h
25th February 2010, 19:42
Your welcome. This is one of the reasons we ask for people to post code. You look at your code so long you miss something like this. I did it a month ago - mine was a missing : in a query. One of the developers here found it for me.