cancel
Showing results for 
Search instead for 
Did you mean: 

I have problem in fetch data from sap to java

0 Kudos

i have problem in fetch data from bapi to java using jco connector

my syntaxt is  JCO.Function function = function.getTableParameterList().getTable("COMPANY_LIST");

that is return the null pointer extception 

So please solve my problem quick and help

Accepted Solutions (0)

Answers (2)

Answers (2)

vijay_kumar49
Active Contributor
0 Kudos

it may have some problem in your code. Please check this example code and use your existing application . it may be useful  fetch data from sap to java and another example


Kindly let me know if you need any more information

HAL9000
Product and Topic Expert
Product and Topic Expert
0 Kudos

Markus also already mentioned it:

JCo2 is NOT SUPPORTED anymore since more than 2 years now!

So please stop giving such outdated examples.

This does not help other users, or do you recommend to write code for unsupported software?

Nowadays one should use the JCo3 API, especially JCo beginners should only learn the new JCo3 API and not get confused with the old stuff.

Thank you.

MarkusTolksdorf
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Patel,

Please do no longer use the classic JCo2 API in new projects. In standalone environments it is no longer supported and for Application Server Java it is deprecated. Please switch to the better JCo3 API. But even with the new API a similar code will not work because JCoFunction is not a JCoTable, which is returned by getTable(). The most likely reason for a NullPointerException is that the table parameter list is not containing a table parameter COMPANY_LIST. As you did not mention a call stack nor the function module, this is only a guess.

Best regards,

Markus

HAL9000
Product and Topic Expert
Product and Topic Expert
0 Kudos

>> JCO.Function function = function.getTableParameterList().getTable("COMPANY_LIST");


> The most likely reason for a NullPointerException is that the table parameter list is not containing a table parameter COMPANY_LIST.


No, I think that the most likely reason is that the function object references itself at declaration / initialization! 

I am more wondering why there is no compile error instead...

MarkusTolksdorf
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Stefan,

my automatic code correction has fixed that to be an assignment to a table . And actually, even if the code was correctly, my answer is not really correct. It would be a JCoException with key FIELD_NOT_FOUND. I should not write ansers too fast. If the code would be correct and compilable, it is more likely that there isn't a table parameter list at all for that function if function was declared before. In the end it's all guessing as lon as we don't know more details.

Best regards,

Markus