Programmers Guide: Importing variables
Importing variables
The browse list session needs to import one or more variables from the parent session. Based on the imported values, the browse list session reads records from the maintable and displays them.
Automatic import
The 4GL engine automatically imports variables (i.e. the primary key values). This happens in the following 5 situations:
Situation 1
From a parent session with main table X a browse list session is started with main table Y. Table X has a reference (foreign key) to table Y. E.g. X = Business Partner table, Y = Currency table. The currency field in the Business Partner table refers to the Currency table.The 4GL engine imports the browse field(s) from table X and stores them in the primary key fields of table Y.Consequences for programming in UI script: None
Situation 2
From a parent session with main table X a browse list session is started with main table Y. A field in table Y refers to table X. (In most cases, there is an identifying relationship between table X and table Y, e.g. order header (table X) and order lines (table Y).) The 4GL engine imports the primary key fields from table X and stores them in the primary key fields of table Y.
Example
Primary key of table X is order number
Primary key of table Y is order number, position number
The 4GL engine imports the order number from table X to the corresponding field of table Y. The position number field remains empty.
Consequences for programming in UI script: None
Situation 3
From a parent session with main table X a browse list session is started with the same main table. E.g. when the user browses from the Business Partner Details session to the Business Partners browse list session to select a Parent Business Partner.The 4GL engine imports the primary key values from the parent session of table X and stores them in the primary key fields of table X in the browse list session.
Consequences for programming in UI script:
Often a hierarchical structure exists in the same table. In those cases you want to override the automatic import by the 4GL engine, since not the primary key values should be imported, but the value of the browse field (e.g. the Business Partner Parent field) and that value should be stored in the primary key fields of the maintable of the browse list session. You should also take care of saving and restoring the primary key values, otherwise the record pointer of the parent session is set incorrectly.
Example
declaration:
table ttcom100
domain tccom.bpid hold.bpid
field.tccom100.prbp:
before.zoom:
|* Save the primary key field
hold.bpid = tccom100.bpid
tccom100.bpid = tccom100.prbp
after.zoom:
|* Restore the primary key field
tccom100.bpid = hold.bpid
Situation 4
From a parent session without a main table (e.g. a print session) a browse list session is started with main table X. The 4GL engine imports the primary key values of table X (if available) from the parent process and stores them in the primary key fields of the browse list sessions' main table.
Example
Browse list session Business Partners is started from the parent session Print Business Partners. The main table of the browse list session is tccom100. The 4GL engine tries to import tccom100.bpid from the print session and stores it in the tccom100.bpid field of the main table of the browse list session.
Consequences for programming in UI script:
In many cases you will have to re-program the parent session in such a way that the primary key fields of the main table of the browse list session are filled.
declaration:
table ttcom100
field.bpid.f:
before.zoom:
tccom100.bpid = bpid.f
Situation 5
From a parent session with main table X a browse list session starts with main table Y. There is no relationship between table X and table Y (e.g. in case of an integration between packages). The 4GL engine imports the primary key values of table Y from the parent session and stores them in the primary key fields of table Y of the browse list session.
In many cases you will have to re-program the parent session in such a way that the primary key fields of the main table of the browse list session are filled.
Consequences for programming in UI script:
Example
Example: (Browsing to Freight Service Levels from Warehousing Orders)
declaration:
table tfmfmd070
field.whinh200.serv:
before.zoom:
fmfmd070.serv = whinh200.serv
Note
Note: for purposes of clarity the example does not use integration DLLs, nor does it use start.session() to start the browse list.
Overriding Automatic Import
Automatic import only works when the browse list starts with the primary key. With dynamic index switching it is also possible to start the browse list with other keys. In that case automatic import can give wrong results.
Because of this and other reasons the application wants to override automatic import. The application might implement browsing as mentioned above at point 5. However the application can also choose to use zoom.* variables in these cases. (The name of these variables does not matter, however it is common practice to name them zoom.*).
Example:
parent session UI script
declaration:
extern domain tccom.bpid zoom.bpid
field.whinh200.stco: | Ship to BP
before.zoom:
zoom.bpid = whinh200.stco
browse list session UI script
declaration:
table ttccom111
zoom.from.all:
on.entry:
import("zoom.bpid", tccom111.stbp)
Example browsing to session with other than primary key (e.g. browsing to Business Partners by Parent Business Partner):
parent session UI script
declaration:
extern domain tccom.bpid zoom.bpid | BP id
extern domain tccom.bpid zoom.prbp | Parent BP
field.ppmmm999.bpid:
before.zoom:
attr.zoomindex = 2 | Start with index 2
zoom.prbp = ppmmm999.prbp
zoom.bpid = ppmmm999.bpid
browse list session UI script
declaration:
table ttccom100
zoom.from.all:
on.entry:
on case curr.key
case 1:
|* Automatic import
break
case 2:
import("zoom.prbp", tccom100.prbp)
import("zoom.bpid", tccom100.bpid)
break
endcase
Note that the start option of the browse list session can cause this not to work (e.g. when this is set to get.defaults). It is recommended to use the default start option instead.
|