cancel
Showing results for 
Search instead for 
Did you mean: 

How to Call BAPI From the Custom Controller

Former Member
0 Kudos

Hi

I developed frist WD Application Using RFC Adapter.

i did the following steps

1. created the project

2. created the model.

3. created the customer controller and mapped the model of the controller to the model.

4. mapped controller context to the views

5. created one action in the start view

6. created one method in the customer controller.

so please let me know the lines of code to call BAPI using RFC.

and how to pass input valus to the bapi and how to execute the BAPI

plese send the reply ASAP

regards

mmukesh

Accepted Solutions (0)

Answers (6)

Answers (6)

Former Member
0 Kudos

Hi Mukesh,

Right click the table in the view. you'll get a pop up menu.select Create Binding.In the next screen nodes in the view's context will be displayed.Select the FlighListInput node,go to Output node and inside Output node you will have FlightList node(sorry, i don't remember the exact name).select it and click Finish.

Regards,

Shabeer.

Former Member
0 Kudos

create a table UI Element..

Right click on it and Apply Template

Then you select the node you want to bind and the variables you want to show as coulmn...

Regards

AM

Former Member
0 Kudos

Hi Mukesh,

The code which you have written is ok.I think it should work. Are you using any tables to display the results after execution? If yes just bind the table to the node inside the Output node of the FlightListInput node.Just try that.

Regards,

Shabeer.

Former Member
0 Kudos

Hi Khan

Thanks for your reply

let me know how to bind the table to the node inside the output node of the flightlistinput node.

regards

mmukesh

Former Member
0 Kudos

Hi

Simple steps for execute any Fn module Excecution from WD side.

Import the Model and register the model Then u will get the Nodes to ur controller and Do the Model Binding.

Once model binding done later register the controller to which view u want to disoplay the data.

thru context mapping u can pass the node structure controller to View.

Once it has done.

goto the Init mehtod of the View and menthion the following code.

FNModule_Input input = new FNModule_Input();

wdContext.nodeFNModule_Input().bind(input);

// pass the input

input.setZ_Kunnr("0000000001");

try {

wdContext.currentFNModule_InputElement().modelObject().execute();

wdContext.nodeOutput().invalidate();

} catch (WDDynamicRFCExecuteException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

Afte this code simple goto the view designer and insert the template insert Table and click next selelct the ouput node and variables over there and then finish.

Thants all , in any kind of Fnmodule.

deploy and execute

thanks,

Lohi.

Former Member
0 Kudos

Hi Mukesh,

First create an instance of the Input class of the model as

<model name>Input bapiInput=new <model name>Input.

In the wdDoInit() bind this object to the context nodes in custom controller..

wdContext.node<node name>.bind(bapiInput);

now create a method (eg: executeBapi() ) in the custom controller and write this code inside the method

executeBapi()

{

bapiInput.set<input parameter for BAPI>( value to be passed );

try

{

wdContext.current<node name >Element().modelObject.execute();

}

catch(Exception e){

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

}

}

then in the action handler for the button write this code:

wdThis.wdGet<custom controller name>Controller().executeBapi();

Hope this will solve your problem

Regards,

Shabeer

vijayakhanna_raman
Active Contributor
0 Kudos

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. If the bapi has a table parameters then the structure for the table parameters will also be imported In the model class.

4. Set the table parameters by creating the instance for that structure and using this instance set it.

Z<Struct>itm tab=new Z<Struct>();

Tab.set<table parameters>

5. Then add the structure instance to the bapi instance.

Zb.add(Tab);

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

wdContext.<bapi>ement().modelObject().execute();

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

Regards,

Vijai

Former Member
0 Kudos

Hi

i did like this

In Start View OnActionSearch () method code

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

{

wdThis.wdGetTestCustControllerController().executeGetlistBapi();

}

in CustomController Init method

public void wdDoInit()

{

Bapi_Flight_Getlist_Input input = new Bapi_Flight_Getlist_Input();

wdContext.nodeBapi_FlightGetlist_Input().bind(input);

input.setDestination_From(new Bapisfldst());

input.setDestination_To(new Bapisfldst());

}

In CUSTOMECONTROLLER executeGetlistBapi();

METHOD

public void executeGetlistBapi( )

{

//@@begin executeGetlistBapi()

try{

wdContext.currentBapi_FlightGetlist_InputElement().modelObject().execute();

wdContext.nodeOutput().invalidate();

}catch(Exception ex){

ex.printStackTrace();

}

Then let me know what is wrong in this

i did as per pdf

please correct if there is any worng in this code.

this is flight example .

regards

mmukesh

Former Member
0 Kudos

Hi Mukesh,

You should add the custom controller in your view properties.

Then you can call the method by using

wdThis.wdget<<CustomerController>>().method();

I suggest you to check the sample tutorials first

https://www.sdn.sap.com/irj/sdn/downloaditem?rid=/library/uuid/f0b0e990-0201-0010-cc96-d7ecd2e51715

https://www.sdn.sap.com/irj/sdn/downloaditem?rid=/library/uuid/5dcbe990-0201-0010-2c99-a2bc9e61acfc

Regards, Anilkumar

Former Member
0 Kudos

Hi Anil

Thanks for you reply

i did as per the creating wd application using bapi and RFC pdf.

but i am not able to get the search results

so please let me me know the code how to call BAPI and how to execute bapi

regards

mmukesh