cancel
Showing results for 
Search instead for 
Did you mean: 

Reg: Bapi Implementation

Former Member
0 Kudos

Hi,

I am importing 2 bapis into my model. and i am executing them in different actions of webdynpro application.

when i execute the first bapi and then continue with the next one, then its giving null pointer exception for the second one.

but when i import these 2 bapis seperately they worked fine.

kindly suggest me what could be the problem.

Regards,

Prasanthi.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

hi,

u must not have a prob in putting 2 bapis in a single model.i have done this many times without any issues

u will get a null pointer exception only if u dont

execute the bapi and try to get or set values of its attributes...

can u elaborate on ur problem

Regards,

Satya.

Answers (12)

Answers (12)

Former Member
0 Kudos

Go through the following link that my help you[]

Regards

Raghu

Former Member
0 Kudos

This action is for dropdown.

I can select either RBU code or Dealer grp.

If i select RBU code from output it gives correct values.

if i select Dealer grp....it ll give correct values.

But if i go to the Output and first select RBU code it gives correct values. And by any chance if i select dealer grp agn its not coming up.....

Former Member
0 Kudos

Hi

Code is correct, I think your requirement is when you enter input value as "by rbu code" then node nodeVn_RBUCode() should be

filled and if input value is "by dealer group" then node nodeVn_DealerGroup() should be filled. To be clear only one node will

be filled on each action. Where are you writing your code is it in Button Action or what?

Check these

1) check the conditional parameters "by rbu code" "by dealer group" exactly matches with the model data.

2) check the import parameters setTable("TVKBT");

setVkbur("*");

setTable("T077D");

setKtokd("*"); matches with the backend. Test execute the bapi in Backend ECC system(SE37) by

giving the above import parameters and make sure the bapi is executing output values with the above import parameters.

Regards

Raghu

Former Member
0 Kudos

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

{

//@@begin onActionselectCriteria(ServerEvent)

if(wdContext.currentVn_SelectCriteriaElement().getVa_SelectCriteria().trim().equalsIgnoreCase("by rbu code"))

{

wdContext.currentZbapi_Display_All_InputElement().setTable("TVKBT");

wdContext.currentZbapi_Display_All_InputElement().setVkbur("*");

wdThis.wdGetCustomerHierarchyCompController().executeZbapi_Display_All();

List nodeElements = new ArrayList();

for (int i = 0; i <wdContext.nodeI_Tvkbt().size(); ++i)

{

IPrivateCustomerHierarchyView.IVn_RBUCodeElement xElement =wdContext.createVn_RBUCodeElement();

xElement.setVa_RBUCode(""wdContext.nodeI_Tvkbt().getI_TvkbtElementAt(i).getVkbur()"-"+wdContext.nodeI_Tvkbt().getI_TvkbtElementAt(i).getBezei());

wdComponentAPI.getMessageManager().reportSuccess(""wdContext.nodeI_Tvkbt().getI_TvkbtElementAt(i).getBezei()""+wdContext.nodeI_Tvkbt().getI_TvkbtElementAt(i).getVkbur());

nodeElements.add(xElement);

}

wdContext.nodeVn_RBUCode().bind(nodeElements);

}

else

if(wdContext.currentVn_SelectCriteriaElement().getVa_SelectCriteria().trim().equalsIgnoreCase("by dealer group"))

{

wdContext.currentZbapi_Display_All_InputElement().setTable("T077D");

wdContext.currentZbapi_Display_All_InputElement().setKtokd("*");

wdThis.wdGetCustomerHierarchyCompController().executeZbapi_Display_All();

List nodeElementsDealergrp = new ArrayList();

for (int j = 0; j <wdContext.nodeI_T077D().size(); ++j)

{

IPrivateCustomerHierarchyView.IVn_DealerGroupElement xElement_Dealergrp =wdContext.createVn_DealerGroupElement();

xElement_Dealergrp.setVa_DealerGroup(""wdContext.nodeI_T077D().getI_T077DElementAt(j).getKtokd()"-"+wdContext.nodeI_T077D().getI_T077DElementAt(j).getTxt30());

wdComponentAPI.getMessageManager().reportSuccess(""wdContext.nodeI_T077D().getI_T077DElementAt(j).getKtokd()""+wdContext.nodeI_T077D().getI_T077DElementAt(j).getTxt30());

nodeElementsDealergrp.add(xElement_Dealergrp);

}

wdContext.nodeVn_DealerGroup().bind(nodeElementsDealergrp);

}

//@@end

}

this is how i am using the code

Former Member
0 Kudos

Hi

Different node that was what i mean dummy node. So you are executing your BAPI and then copying all values to different node and then executing the BAPI with other input values. So it is correct. make sure you have bind your UI element with that different node. Can you elaborate your requirement or paste your code what you have written such that we can know it better.

Regards

Raghu

Former Member
0 Kudos

actually i am taking all those values into a different node after executing the BAPI. Then i dont thnink there is a need of dummy node again. Correct me if i am wrong.

Former Member
0 Kudos

Hi Prasanthi

please go through this link

U find ur answer

Regards

Ruturaj

Former Member
0 Kudos

Hi Prasanthi,

I am not sure what is your problem, but what i think is you want to execute the BAPI twice both in if and else part and get two different values out of it, which is not possible because the second execution of bapi will overwrite the node. So what you have to do is

create two dummy copy nodes one for if part and the other for else part and after executing the bapi in if and else part just copy the node values to the dummyif and dummyelse nodes and bind the dummy nodes to the respective UI elements. Hope this will solve your problem.

if

{

executeBAPI

WDCopyService.copyElements(sourceNode,targetNode);

}

else

{

executeBAPI

WDCopyService.copyElements(sourceNode,targetNode)

}

Regards

Raghu

Former Member
0 Kudos

But, I need to take different output values from the BAPI in IF ElSE conditions...

Former Member
0 Kudos

hi,

ur question if i am correct.

In both the cases(if and else), i am executing the same bapi with different input parameters.

in both cases bapi will be executed with the i/p values u have given.If first case is right it takes i/p from "if" otherwise it takes i/p from "else" and bapi will be executed.

Regards,

Srikanth Reddy.T

Former Member
0 Kudos

please post the code ?

Former Member
0 Kudos

hi,

is that u want to show different output values for different input values in the same action?

how does ur layout look like?

and how are u displaying ur output?

Regards,

Satya.

Former Member
0 Kudos

hi,

to my understanding

u want to display the output of the corresponding

input ..

if this is ur requirement , it is better to go for supply functions

correct me if im wrong

Regards,

Satya.

Former Member
0 Kudos

Thanks for the answers. But, sorry that i framed the question in wrong way.

I have one BAPI that is being executed in a action. i am using if else inside the action. In both the cases(if and else), i am executing the same bapi with different input parameters. But its executing only for the first time and for the second time its giving null values. I tried invalidating the nodes...but dint work.

Kindly suggest.

Regards,

Prasanthi.

Former Member
0 Kudos

Hi Prashanthi,

In if block set the i/p values and in else block set the required i/p values and execute the bapi out of blocks only once.

If(condition)

{

set i/p values

}

else

{

set i/p values

}

execute bapi();

Regards,

Srikanth Reddy.T

Former Member
0 Kudos

Hi,

if you passing any input to bapi make sure it not be null.

Regards,

ramesh

Former Member
0 Kudos

Hi Prasanthi,

Check whether your are suppling the necessary mandatory import parameters to the Bapi before executing the Bapi. Because you should have no problem in importing two Bapi's into One Model. Try Again.

Regards

Raghu