cancel
Showing results for 
Search instead for 
Did you mean: 

how to call BAPI from R/3 system

Former Member
0 Kudos

hi,

i am doing small application by using Model. that is calling BAPI from R/3 system. but i am not able to get data from the back end system. please suggest me regarding this problem

thanx

tanvi

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

hi tanvi,

first check the context mapping whether u did correctly or not.

and then write the execute method in the component controller. after that call that execute method in the view.

make sure that u have to initialize BAPIs in the "init" method of component controller

forExample:

executeBAPIname()

{

wdContext.ComponentControllername.contextnode.execute();

}

then call this execute method in the view like..

wdthis.wdComponentcontrollercontext.executeBAPIname();

follow this procedure then u will get data from the backend. and make sure that your JCO connection should be in enable mode

thank's

Anusha.T

Former Member
0 Kudos

thanks lavanya and anusha

i think my problem may be with calling Execute method in view.

thanx

tanvi

Answers (2)

Answers (2)

nikhil_bose
Active Contributor
0 Kudos

steps:

1) create Model

2) bind Model to component controller ( you can use data modeler.) 2.1) open data modeler; if your model is not there, you can add by clicking add existing model;

2.2) create data link between model and controller, it will open map dialog.

2.3) click and drag BAPI_xxx_Input to context of controller and select all nodes inside

- if there is any duplicate nodes, just rename it.

3) map context to view controller

3.1) map input parameters separately ( which takes value for IMPORT to BAPI. select only that fields

3.2) do map for output (exact node which contains BAPI output)

coding:

1) in component controller you need to instantiate model and bind to context


BAPI_xxx_Input my_input = new BAPI_xxx_input();
wdContext.nodeBAPI_xxx_Input my_input().bind( my_input);

2) create a method in the component controller so that we can execute it from any of views used.


try{
  wdContext.currentBAPI_xxx_Input my_input().modelObject().execute();
}catch(WDRFCException e) {
e.printStackTrace();
}
wdContext.node<ExactOutput>().invalidate();
// this stmt will reflect new values

3) Go to view and bind values to UI Elements

in wdDoInit()


IPrivate<Comp_Name>View.I<ExactOutput>Element  input = wdContext.create<BAPI_xxx_Input>Element();
// see if this may demand model instance as parameter
wdContext.node<BAPI_xxx_Input>().addElement( input);

4) In OnAction you just executes the component controller method


wdThis.wdGet<Com_Name>Controller().executeMyBapi();
// executeMyBapi() is the method contains the mentioned try..catch code

nikhiL

Former Member
0 Kudos

Hi ,

You hav to excute the model,by using this method:

wdContext.currenBAPI_NAME_Element().modelObject().execute();

Regards,

LG