on 01-14-2005 10:55 AM
hi,
i'm wondering if there's a bug in the execution of an "adaptive rfc model" or am I doing something wrong?
I'm using a selfmade RFC (but this problem occured with SAP RFC's, too) that has got some tables as input/output.
2 of them are used for input&output, 4 of them as output only.
the only way to get the results in the output tables is, that i'm initially add an (empty) object in the corresponding input tables and remove them immediatley afterwards in wdInit()in the controller, because most of them will never be used as input tables.
when i'm trying to fill one of the input tables at a later stage (for exmaple in a view, that context is mapped to the controller context), the mapping is done (i'm checking this with another view, that refers to the controller context, too) but obviously the binding to the model never takes place, so that the RFC never gets these tables as input.
my controller wdInit() looks like this:
MyRFC_Input input = new MyRFC_Input();
wdContext.nodeMyRFC_Input().bind(input);
Table1 mytab1 = new Table1();
input.addT_Table1(mytab1);
// I'm using Table1 as input table in my first view
// Start: Workaround to get results in the other tables
Table2 mytab2 = new Table2();
input.addT_Table2(mytab2);
input.removeT_Table2(mytab2);
Table3 mytab3 = new Table3();
input.addT_Table3(mytab3);
input.removeT_Table3(mytab3);
...
//End: Workaround
I could live with this workaround, but actually (after reimporting the model) I don't get any results in one special table even with this workaround...
this table wasn't touched by the abap code and used to work.
i'm also excluding mistakes in the abap code, because this table wasn't touched and I have to do this workaround with SAP RFCs, too (for example: when I use the RFC_READ_TABLE and I don't use this workaronud with the Data-Table, it'll never gets any results from the abap)
what is going on there?
kr, achim
Hi Achim,
To get the results in the tables that are being used as output in my opinion you dont need to fill the tables with initial object.
You just need to map the nodes under OUTPUT node in the controller context and the nodes will be filled after the RFC execution.
Regards
Sidharth
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
victor, yes i invalidate the whole Output-node after rfc-call (i suggest it invalidates all his children below it, too).
sidharth, i've mapped it to the output nodes. and i'm getting these output values correctly, but only with the mentioned workaround...
fortunately, the special one table also gets results now again. i've made 2 rfc-calls sequentially and the latter one obviously destroyed the output of the first one.
but without the "workaround" none of the tables delievers any output. is there a special thing to consider in the abap implementation of the rfc call?
kr, achim
Hi Achim,
this is just to make our findings for your customer message public:
The reason why the output table has not been filled was that the
input table(s) were not filled. The reason for not filling the input
table(s) was the approach to fill them via the context node(s) bound
to the input table(s).
Solution:
Updates of model nodes should always be done via the model bound to
the nodes(s) because an automatic data transport from the context
to the model cannot be guaranteed. Provided the Table2 model object
from the above code sample is bound to a context node Table2In having
an Sample_Rfc_Input as parent the code to add rows to the input
table looks as follows:
//let Table2 be the structure for a T_Table2 row
Table2 newTable2_modelObject = new Table2();
//will not work: update in context
// IPrivateTestView.Table2InElement table2InEl = wdContext.createTable2InElement(newTable2_modelObject);
// wdContext.nodeTable2In().addElement(table2InEl);
//update via model
Sample_Rfc_Input inputModelObject = wdContext.currentSample_Rfc_Input_Element().modelObject();
//clear table2 if existing
if (inputModelObject.getT_Table2() != null) {
inputModelObject.getT_Table2().clear();
}
inputModelObject.addT_Table2(newTable2_modelObject);
//sync context with model
wdContext.nodeTable2In().invalidate();
The above line for sync'ing the context with the model is necessary because
an automatic update of the context from the model may not happen in
cases when the context node Table2In has been accessed before by the
WD framework (e.g. when a table UI element bound to this node has
been rendered). In these cases the context will generate its own
empty list representing Table2In which cannot be bound to the model.
The call to invalidate() will sync the context with the model again.
Answer to the question: Why is the update of the model via context
update working, when the lines
input.addT_Table2(mytab2);
input.removeT_Table2(mytab2);
run in wdDoInit() of the custom controller?
By the add/remove on the model an empty list of Table2 model objects
is created and bound to the context before the context node Table2In is
accessed for the first time.
The context inserts the model object into this in the lines
IPrivateTestView.Table2InElement table2InEl = wdContext.createTable2InElement(newTable2_modelObject);
wdContext.nodeTable2In().addElement(table2InEl);
This only works in cases when the context has not already generated its own list as explained above.
That's why it is not recommended; always do updates on the model instead!
Regards,
Patric
Hi Achim,
to have a clear separation according to MVC you could of course put the model update into a method contained in the custom controller defining the origin context to which the view context's model nodes are mapped. And then call this method of the custom controller from the view controller's action event handler.
Regards,
Patric.
Hi,
I am tryng to understand what is the difereence between what you are doing and the examples in the tutorial like BAPI_FLIGHT_GET_LIST? There you are using tables for output only an this works fine. Did you invalidate you nodes after call to the RFC/BAPI?
Regards,
Victor.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.