Skip to Content
avatar image
Former Member

Get the return value of an RFC function / BAPI

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!

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    avatar image
    Former Member
    Oct 17, 2008 at 06:41 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      The problem is that wdContext.nodeZMy_Bapi_Output() is empty: wdContext.nodeZMy_Bapi_Output().size() = 0

      Any idea of the reason why it is empty?

  • avatar image
    Former Member
    Oct 17, 2008 at 05:30 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Sorry, my previous reply was not clear enough.

      MyReturnValue is an attribute, and after using getElementAt (instead of getMyOutputResultElementAt) and casting I get the method getMyReturnValue.

      But the result is still empty.

  • avatar image
    Former Member
    Oct 19, 2008 at 11:22 AM

    No Need to write these 2 lines

    ZMy_Bapi_Output bapiOutput = new ZMy_Bapi_Output();

    wdContext.nodeMyOutputResult().bind(bapiOutput);

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 23, 2008 at 01:03 PM

    what error you are getting? while executing the RFC...

    Add comment
    10|10000 characters needed characters exceeded