on 10-17-2008 6:20 PM
Hello,
I'm a Web Dynpro Java beginner and I try to get the return value (domain: NUMC6) of an RFC function without success.
Here is what I do, could you please tell me what is wrong?
First, here is my context:
Context
|
|---- ZMy_Bapi
|
|---- MyOutputResult
| |
| |---- MyReturnValue
|
|---- MyInput
My model:
MyModel
|
|---- ZMy_Bapi_Input
|
|---- Output
| |
| |---- ZMy_Bapi_Output
| |
| |---- Return_Value
|
|---- Input_Value
The mapping between them:
- MyInput is mapped to Input_Value
- MyReturnValue is mapped to Return_Value
And my code:
ZMy_Bapi_Input bapiInput = new ZMy_Bapi_Input();
wdContext.nodeZMy_Bapi().bind(bapiInput);
bapiInput.setInput_Value("A value");
executeZMy_Bapi();
ZMy_Bapi_Output bapiOutput = new ZMy_Bapi_Output();
wdContext.nodeMyOutputResult().bind(bapiOutput);
IMyOutputResultElement outputElement = wdContext.nodeMyOutputResult().currentMyOutputResultElement();
String result = outputElement.getMyReturnValue();
Finally, here is the code of the executeZMy_Bapi() function:
try {
wdContext.currentZMy_BapiElement().modelObject().execute();
wdContext.nodeMyOutputResult().invalidate();
} catch (Exception ex) {
ex.printStackTrace();
}
My problem is that "result" keeps being empty
Thanks in advance for your help!
HI.
I assume this is your model node structure.
MyModel
|
ZMy_Bapi_Input
|
Output
|
|
| ZMy_Bapi_Output
|
|
| Return_Value
|
|---- Input_Value
for(int i=0; i<wdContext.nodeZMy_Bapi_Output().size();i++)
{
String result = wdContext.nodeZMy_Bapi_Output().getZMy_Bapi_OutputElementAt(i).getReturn_Value();
}
and your execute method:
try {
wdContext.currentZMy_Bapi_Input().modelObject().execute();
wdContext.nodeZMy_Bapi_Output().invalidate();
} catch (Exception ex) {
ex.printStackTrace();
}
Regards,
Murtuza
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Here are my context and model again, but maybe I don't understand what you want me to send you?
Context
|
|---- ZMy_Bapi
|
|---- MyOutputResult
| |
| |---- MyReturnValue
|
|---- MyInput
MyModel
|
|---- ZMy_Bapi_Input
|
|---- Output
| |
| |---- ZMy_Bapi_Output
| |
| |---- Return_Value
|
|---- Input_Value
Edited by: Franis Pignon on Oct 17, 2008 8:59 PM
HI,
Could you see one more level or hierarchy in your model compared to your cotext. If you keep your context names same to that of the model nodes name then you need to loop through the ZMy_BAPI_Output node and use the code as mentioned above.
NOTE: Goto the last level of node under the ouput node within the input node(ie within. ZMy_Bapi_Input node) and loop through it as this is the node that contains the output result.
Regards,
Murtuza
I don't really understand what's wrong with my context or modelu2026 I know there is one more level hierarchy in my model, I just followed [this tutorial|https://www.sdn.sap.com/irj/sdn/adobe?rid=/library/uuid/a00f7103-6790-2a10-ac9c-fcac7c5b18a3], so I guess that is the way it should beu2026
The other thing I don't understand is why if I use wdContext.nodeZMy_Bapi_Output().getZMy_Bapi_OutputElementAt(i), I have access to the getInput_Value method, but not the getReturn_Value one.
Edited by: Franis Pignon on Oct 17, 2008 9:59 PM
HI,
If you go to your data modeler and select the link between model and the controller and drag ZMy_Bapi_Input from model to controller then what all nodes have you mapped? I guess that you have mapped something wrong. If possible then remap this thing and select all the nodes that you find under ZMy_Bapi_input node and then follow the steps.
Regards,
Murtuza
Hi,
Here is the detailed mapping:
ZMy_Bapi --> ZMy_Bapi_Input
MyOutputResult --> Output
MyReturnValue --> Return_Value
MyInput --> Input_Value
And the ZMy_Bapi_Output Node of the model is NOT mapped to anything in the context. Maybe the problem comes from this?
I really appreciate your help.
Context
|
|---- ZMy_Bapi
|
|---- MyOutputResult
| |
| |---- MyReturnValue
|
|---- MyInput
MyModel
|
|---- ZMy_Bapi_Input
|
|---- Output
| |
| |---- ZMy_Bapi_Output
| |
| |---- Return_Value
|
|---- Input_Value
Edited by: Franis Pignon on Oct 17, 2008 10:34 PM
It still doesn't work, I'm gonna turn crazy!
But there is one good point: I get the method you mentioned: getZMy_Bapi_OutputElementAt and getMyReturnValue without casting, just as you said first.
Here are the updated context, model, mapping and code.
Context:
MyContext
|
|---- ZMy_Bapi
|
|---- MyOutputResult
| |
| |---- ZMy_Bapi_Output
| |
| |---- MyReturnValue
|
|---- MyInput
Model:
MyModel
|
|---- ZMy_Bapi_Input
| |
| |---- Output
| | |
| | |---- ZMy_Bapi_Output
| | |
| | |---- Return_Value
| |
| |---- Input_Value
|
|
|---- ZMy_Bapi_Output
|
|---- Return_Value
Mapping
ZMy_Bapi --> ZMy_Bapi_Input
MyOutputResult --> Output
ZMy_Bapi_Output --> ZMy_Bapi_Output
MyReturnValue --> Return_Value
MyInput --> Input_Value
Code
ZMy_Bapi_Input bapiInput = new ZMy_Bapi_Input();
wdContext.nodeZMy_Bapi().bind(bapiInput);
bapiInput.setInput_Value("A value");
executeZMy_Bapi();
ZMy_Bapi_Output bapiOutput = new ZMy_Bapi_Output();
wdContext.nodeMyOutputResult().bind(bapiOutput);
String result = "";
for (int i = 0; i < wdContext.nodeZMy_Bapi_Output().size(); i++) {
IZMy_Bapi_OutputElement resultElem = wdContext.nodeZMy_Bapi_Output().getZMy_Bapi_OutputElementAt(i);
if (resultElem.getMyReturnValue() != "" && resultElem.getMyReturnValue() != null) {
result = resultElem.getMyReturnValue();
}
}
Edited by: Franis Pignon on Oct 17, 2008 11:16 PM
Here is my executeZMy_Bapi method:
try {
wdContext.currentZMy_BapiElement().modelObject().execute();
wdContext.nodeMyOutputResult().invalidate();
} catch (Exception ex) {
ex.printStackTrace();
}
And here is the result of the reportSuccess method:
mypackage.model.ZMy_Bapi_Input@377445b8
Edited by: Franis Pignon on Oct 18, 2008 2:12 AM
what error you are getting? while executing the RFC...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No Need to write these 2 lines
ZMy_Bapi_Output bapiOutput = new ZMy_Bapi_Output();
wdContext.nodeMyOutputResult().bind(bapiOutput);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
In order to get the output, you have to loop around your output node:
for(int i=0; i<wdContext.nodeMyOutputResult().size();i++)
{
String result = wdContext.nodeMyOutputResult().getMyOutputResultElementAt(i).getMyReturnValue();
}
Regards,
Murtuza
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you for your help.
Unfortunately, it didn't work.
There isn't any method "getMyOutputResultElementAt" for wdContext.nodeMyOutputResult(), but I guessed I had to use getElementAt(i) and then cast the result.
I also changed what was inside the loop, because the way it was done made the result being reinitialized at each iteration. And to get sure I got the right value (and not the last one), I added a check so the value is set only if it is not empty or null.
Why do I have to loop at my output node? Shouldn't there be a single result element?
Here is how I changed the code
IMyOutputResultElement resultElem = null;
for (int i = 0; i < wdContext.nodeMyOutputResult().size(); i++) {
resultElem = (IMyOutputResultElement)wdContext.nodeMyOutputResult().getElementAt(i);
if (resultElem.getMyReturnValue() != "" && resultElem.getMyReturnValue() != null) {
month = resultElem.getMyReturnValue();
}
}
Hi,
If you didn't find that method then let me know is getMyReturnValue a node or an attribute. It should be a node. If it's a node then you need to loop through this node instead of the nodeMyOutputResult node. If it is the last level node then you should get the method as mentioned above.
Regards,
Murtuza
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
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.