how to restrict the number of table columns in bapi output

542 views Asked by At

While querying BAPI, we are generally interested in only few columns of a table.

For example PO_ITEMS table (under BAPI_PO_GETITEMS) has 58 columns. While querying, I am interested in only 10 of those columns. But the BAPI response contains all the columns, which is a overhead.

In SQL world, we can always select which columns we want to retrieve. The query response contains only those columns, not all the columns.

I remember I have read somewhere that we can disable unwanted columns coming in response. But when I need it now, I am not able to find information about it.

Can anybody share a code snippet to achieve this? Or specific online resource/pointers would help?

Thanks

2

There are 2 answers

2
vwegert On BEST ANSWER

Depending on which technology you use to call the BAPI, you can sometimes restrict which parameters are transferred. For example, if you use the SAP Java Connector (JCo 3), you can use the method setActive of a parameter to restrict whether the parameter is transferred. However:

  • As far as I know, you can only enable or disable entire TABLES parameters or other parameters. You can't enable or disable individual columns.
  • As far as I know, the BAPI itself does not know about this setting - and even if it would know, few implementations would care.

Sometimes there are additional parameters that allow you selectively enable or disable fields, but that is part of the actual BAPI implementation and not some omnipresent basic technology.

1
Ganesh Jagan On

this is not exact answer for your question.i hope it will help.I think we have no option to select certain number of column from a function module tables.but we can access particular row from that table like passing mandatory values from java side .....like this sample code here i did for function module(not table table).

JCoDestination destination = JCoDestinationManager.getDestination(DESTINATION_NAME);

  JCoFunction jf=destination.getRepository().getFunction("ZUSER_DET");

jf.getImportParameterList().setValue("FIRST_NAME","username");

 jf.execute(destination);

String jfex=jf.getExportParameterList().getString("some column name from return table");

System.out.println(jfex);

it will return a row of table value.you can manipulate whatever you want