FrenkR
21st July 2013, 12:55
Hi,
is there any way to fill external variables of new(child) session on creation in the same way as link between parent and child main table is defined(start.synchronized.child() or start.session() command)?
Sample (pseudo) code:
start.synchronized.child( 'tdpur3111m920', tdpur310.bfbp, bpid.f)
bpid.f is external variable on child session. Is there any similar way(command) to link parent and child varible before child session is displayed?
Rgds,
Frenk
bhushanchanda
21st July 2013, 21:30
Hi,
You can try start.synchronized.child.with with the required arguments. I hope this helps.
From Prog Guide:-
start.synchronized.child.with()
Syntax
long start.synchronized.child.with( const long cmd )
Description
To start a synchronized child with a command other than the default synchronization command, call this function before calling start.synchronized.child().
Although you normally use this function to synchronize sessions that act on different main tables, it is also possible to use it to synchronize sessions that act on the same main table.
Arguments
cmd
This specifies the ID of the required command that is executed immediately after startup. Possible values are FIRST.SET, FIND.DATA and ADD.SET.
Return values
The function returns the specified command or 0 if the command is illegal.
Context
4GL library function.
FrenkR
21st July 2013, 22:04
can't help a lot with that or I don't understand what you would like to tell me. I have standard child (reporting) session where orno.f and orno.t are fields in a session that must be filled. Parent session has a known value for orno field. From parent session I would like to open modal view of session and fill orno.f and orno.t fields(after defaults are filled). I have no source code for this reporting session. Am I clear enough?
Rgds,
Frenk
bhushanchanda
21st July 2013, 22:45
Ok,
Umm, well, if the calling parent session is a Standard session you can write a Wrapper to call the child session on some specific event. Now, in child session script , in the before.program, you can import the values you want from parent session using standard import command or get.var command.
get.var( parent, "variable", value)
Here, "variable" will be the variable you want to import from parent session and "value" will be the variable which stores the value of the imported variable.
I am not sure if this is what you want.
FrenkR
22nd July 2013, 01:06
Problem is that child session is standard session with no source code(trpur3422m000). Parent session has full source code. Is there any other way except doing "wrapper" form(session) and print using AFS on standard form?
Rgds,
Frenk
bhushanchanda
22nd July 2013, 05:01
If you want to take a report after passing the variables on the standard form, AFS would be the best way to do that. There are lot of examples on the Board, to print reports using AFS.
But, if you just want to pass the variables without printing report, what you can do is check if the session has a Save Defaults button, now you can do an AFS to print the required variables on standard sessions form and using AFS you can click on Save Defaults button.
Now, from the Parent session, just use as start.session to start the child session which will now have the stored defaults.
I guess this helps.
FrenkR
22nd July 2013, 12:32
Do you have any idea how to click "save.defaults" using AFS? command "save.defaults" does not work.
Rgds,
Frenk
FrenkR
22nd July 2013, 13:54
I tried to call save.defaults using AFS but it doesn't work. Anybody idea how to call this command using AFS? Button "Save defaults" is enabled in a form and is working.
bhushanchanda
22nd July 2013, 14:58
Well,
It was an assumption that the standard session will have save.defaults as form commands, but as far as I know, it is a standard command.
But, you can try this:-
stpapi.put.field( "tdsls4405m000", "ofbp.f", "CC0001100" )
stpapi.form.command( "tdsls4405m000", 5, "save.defaults", error )
msg1 = stpapi.get.mess.code("tdsls4405m000",msg)
msg1 = stpapi.get.mess.code("tdsls4405m000",msg)
if get.argc() = 0 then
stpapi.end.session( "tdsls4405m000" )
else
error = get.string.arg(1)
stpapi.end.session( "tdsls4405m000" , error )
put.string.arg(1, error)
endif
You can check it in debug mode, in this case, it gives error message in msg1 that the save.defaults is not a form command. I hope your standard session has it as a form command.
If not, I will prefer to go with a wrapper, it will be an easier way to do it.
If not, you will need to wait for AFS masters to answer this.
bhushanchanda
22nd July 2013, 17:33
Also ,
Frenk, what exactly you are trying to achieve?
mark_h
22nd July 2013, 18:17
Yes - his last question is the key? I run a lot of reports out of AFS mode and have never seen a new to save defaults - as a matter of fact I would recommend against it. When you run a session in AFS mode, especially a print session, you just put the fields you need and print the report. Saving defaults means everytime the user runs the session manually they have to know to change the defaults.
Now - there is another way to get variables into a child session. You can use one of the wrapper products - ~Vamsi has a free version in the code and utilities. I use qkey(no longer available) and RMC has another production. With a technique like this you can add code into the session where you do not have source code. This allows you to export from a parent session and import into the child session. I do use this in conjuction with API code since not everything is always in sync in Baan - some sessions just do not play nice with AFS code.
bhushanchanda
22nd July 2013, 19:33
Exactly Mark,
I will go with ~Vamsi's solution for this too. AFS don't play good with standard commands. For a more complicated way, you can use a VB script which will fill the child session form. You see, there are lots of options but its always your choice. :)
bhushanchanda
23rd July 2013, 09:30
Ok,
Here's what I got. In LN , we have a table ttadv990 where the user defaults are stored. Now, its easy to use this table to find the sessions related to user, and just modify the records in this table to put the values on the session. I tried and it works perfectly!
FrenkR
23rd July 2013, 14:51
thanks for your work. I will go (most simple) ttadv990 way. I know that this is not the best solution but in is fast and simple to implement.
BTW, where can I get Vamsi latest tools/utilites/samples? I am working on LN.
Rgds,
Frenk
bhushanchanda
23rd July 2013, 14:54
Hi,
This is it! ~Vamsi's Solution (http://www.baanboard.com/baanboard/showthread.php?t=559).