cancel
Showing results for 
Search instead for 
Did you mean: 

RFC call on click of button

Former Member
0 Kudos

Hi,

I need to make RFC call to ABAP function module with some input parameters.

On click of a button, I need to navigate between views based on returned values.

I have followed steps similar to FlightList example. Created a model, custom controller and all necessary contexts between them.

Basic RFC connection seems to be working fine (I tried to populate a table with the return values for testing purposes) as the table header gets the appropriate values based on model... but the actual values are not being returned.

Please guide me what needs to be done with

1) ButtonAction() method, 2) DoInit( ) method of the model, 3) ...Bapi_execute( )

Or give me the steps to start from fresh, whatever is easier...

Thanks a lot in advance,

Dil

Accepted Solutions (0)

Answers (6)

Answers (6)

Former Member
0 Kudos

Thanks all, resolved

Former Member
0 Kudos

Hi Dileep,

Just follow this Steps:

1] Create a Method execute<BAPINAME> in customer controller.

2] In customer controller init

Add this lines:

BAPI_Input Input=new BAPI_Input();

wdContext.nodeBAPI().bind(Input);

3] In <BAPINAME> write this code:

BAPI_Input ModelObject=wdContext.BAPIElement().modelObject();

ModelObject.setContact_Id(inputParameter);

ModelObject.execute();

wdContext.nodeBAPI().nodeBAPIOutput().invalidate();

4] Called this function in View Action Event for the Button.

Former Member
0 Kudos

Thanks all, I have tried these options...

Can all these lines of code be placed in onActionsubmit()? I tried this, the method nodeZ... in this line is not resolved .

wdContext.nodeZ<bapi name>. bind(zb);

even after organizing imports.

Can you guys please help me with what lines of code should go in what methods?

Thanks a lot

Dileep

former_member211296
Participant
0 Kudos

Hi,

For example you are having the name of the BAPI as ZORG_READ_MESSAGE

try

{

Zorg_Read_Message_Input input1=new Zorg_Read_Message_Input();

input1.setPersoneelsnummer(employid);

wdContext.nodeZorg_Read_Message_Input().bind(input1);

wdContext.currentZorg_Read_Message_InputElement().modelObject().execute();

String A1=wdContext.currentZorg_Read_Message_OutputElement().getAcht();

String B1=wdContext.currentZorg_Read_Message_OutputElement().getTuss();

wdContext.currentZorg_Read_Message_InputElement().modelObject().modelInstance().disconnectIfAlive();

}catch(Exception e)

{

wdComponentAPI.getMessageManager().reportException( e.getMessage());

}

here what we have to do as bind the necessary inputs and execute the BAPI after that you may get the ouput..In this scenario the employeeid is the input and acht,tuss output from the BAPI.

try this,

Kind regards,

R.Hariprasath

Former Member
0 Kudos

Hi Dileep,

For Adaptive RFC Models :

<a href="http://help.sap.com/saphelp_nw04/helpdata/en/6a/11f1f29526944e8580c5e59333d96d/content.htm">Importing Adaptive RFC Models</a>

An Example : <a href="http://help.sap.com/saphelp_nw04/helpdata/en/c3/76b45d9688e04abe1a1070410ddc1e/content.htm">Accessing ABAP functions.</a>

Code for the different methods : <a href="http://help.sap.com/saphelp_nw04/helpdata/en/5d/3c96e4c1c3934cbd9c19fb9df49944/content.htm">Code Sample.</a>

Hope it helps.

Regards,

Alka.

arun_srinivasan
Contributor
0 Kudos

Hi

Steps:

1. First create an instance for bapi and bind the instance to the bapi node.

Z<bapi name> zb=new Z<bapi name>();

wdContext.nodeZ<bapi name>. bind(zb);

2. Then if u have the import parameter u have to set them by using

The instance of the above bapi.

Zb.set<import parameters>;

3. Then Execute the bapi after setting the import parameters.

4. If there is any export parameters, then get the values after execution.

public void onActionsubmit(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )

{

//@@begin onActionsubmit(ServerEvent)

Z<bapi name> zb=new Z<bapi name>();

wdContext.nodeZ<bapi name>. bind(zb);

Zb.set<import parameters>;

try

{

wdContext.nodeZ<bapi name>_Input().currentZ<bapi name>_InputElement().modelObject().execute();

}

catch (Exception e)

{

wdComponentAPI.getMessageManager().reportWarning("Exception:"+e);

}

// code for getting values from response node

//@@end

}

Hope this helps,

Regards,

Arun