cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to fetch data from R/3 using BAPI

Former Member
0 Kudos

Hi All,

I am facing difficulty in getting data using BAPI. I have written small program in Web Dynpro. It uses RFC model and gets data from BAPI_MATERIAL_GET_DETAL. In R/3, I can see the data. However I can not see the same data using Web Dynpro. I have created one view. There is one Action push button, one input field and one table output field in the form. After inserting some value in the input field 'Material No' & on pressing the action bution, data should get populated in table. It is not happening !!!

In wdDoInit I have written following code:

//@@begin wdDoInit()

Bapi_Material_Get_Detail_Input input = new Bapi_Material_Get_Detail_Input();

wdContext.nodeBapi_Material_Get_Detail_Input().bind(input);

//@@end

In Action button I have written following code:

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

{

//@@begin onActionclick(ServerEvent)

try {

// wdContext.

wdContext.currentBapi_Material_Get_Detail_InputElement().modelObject().execute();

wdContext.nodeOutput().invalidate();

wdComponentAPI.getMessageManager().reportSuccess("Size of Output node "+wdContext.nodeOutput().size());

wdComponentAPI.getMessageManager().reportSuccess("BAPI executed successfully");

} catch (Exception e) {

// TODO Auto-generated catch block

wdComponentAPI.getMessageManager().reportException("BAPI execution failed "+e.getMessage(), true);

e.printStackTrace();

}

//@@end

}

I have imported the BAPI and have done mapping etc correctly. Could you pls let me know the reason why data is not being fetched by the BAPI. Pls note that wdComponentAPI.getMessageManager().reportSuccess("Size of Output node "+wdContext.nodeOutput().size()) returns 1. So, I guess model is fetching data. However the data is not getting displayed.

Can you please help me out.

Regards,

Gaurav

Accepted Solutions (1)

Accepted Solutions (1)

former_member197348
Active Contributor
0 Kudos

Hi Gaurav,

I hope this piece of code is in Copmonent controller's wdDoInit

//@@begin wdDoInit()

Bapi_Material_Get_Detail_Input input = new Bapi_Material_Get_Detail_Input();

wdContext.nodeBapi_Material_Get_Detail_Input().bind(input);

//@@end

instead of this

wdComponentAPI.getMessageManager().reportSuccess("Size of Output node "+wdContext.nodeOutput().size())

<b>try to print Output Return message().</b> May be you can get closer to the problem

regards,

Siva

Former Member
0 Kudos

Hi All,

The issue got sorted out. In fact the problem was due to authorization issue. I was not having the requisite authorization on the BAPI. After getting the authorization, I can query the R/3 record and records are getting displayed.

Thanks for you help.

Regards,

Gaurav

Former Member
0 Kudos

Hi,

I have mentioned the same thing in my last post.

Did you seen that or not?

Thanks,

Lohi.

Answers (2)

Answers (2)

former_member720137
Active Participant
0 Kudos

Hi

Ur BAPI is executing well i guess the prob is may b this BAPI required some input parameter which u have to set, i faced the same prob wen i used Bapi_Material_Getlist BAPI, but once i gave the required input, it gave me list of all materials, and regarding ur size of O/P node, it is appearing 1 coz may b u hv sub node in it.

Thanks

Puneet

Former Member
0 Kudos

Puneet,

I'm facing problem in getting data back from BAPI_MATERIAl_GETLIST. Since you have executed that successfully earlier, can you please guide me as to what am I missing. Please follow the link below for detailed description.

Thanks,

Vishwas.

Former Member
0 Kudos

Hi,

Try to find the size of ur output tablenode I mean under the table do u have more nodes I think so.

Which node u binded to the table find that node size it it returns some values then it works and compare form the R/3 side.

Otherwise u need to give some autorization for the Function module in R/3 end.

Thanks,

Lohi.