on 07-29-2015 2:41 PM
Dear All,
I am using this code to get data from the table.I am passing the part no to INPUT_TAB and fetching the values from OUTPUT_TAB. If I call the below function, I get an error message saying "Trying to access row values in a table which does not have any rows yet".Requesting you to let me is there any error in the code and Whether the execute function should come before/after setting input values.
public static void getTableData() throws JCoException
{
JCoDestination destination = JCoDestinationManager.getDestination(DESTINATION_NAME2);
JCoFunction function = destination.getRepository().getFunction("ZRFC_MES_PART_QTY_01");
if (function == null)
throw new RuntimeException("BAPI_COMPANYCODE_GETLIST not found in SAP.");
JCoTable codes1 = function.getTableParameterList().getTable("INPUT_TAB");
codes1.setValue("PARTNO","592032/A");
try
{
function.execute(destination);
}
catch(AbapException e)
{
System.out.println(e.toString());
return;
}
JCoTable codes2 = function.getTableParameterList().getTable("OUTPUT_TAB");
for (int i = 0; i < codes2.getNumRows(); i++)
{
codes2.setRow(i);
// System.out.println(codes2.getString("QUANTITY"));
}
}
Just a comment not strictly related to the original topic:
If your code is running on JAVA AS don't use System.out.prinln().
If you use SAP NetWeaver you should use the satandard Logging and Tracing API.
http://scn.sap.com/community/java/blog/2014/12/16/implementation-of-logging-and-tracing
But I know this is just an example.
BR
Szabolcs
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ashwin,
call
codes1.appendRow();
before codes1.setValue(...).
And by the way, the exception call stack shows you at which statement the error occurred.
Best regards,
Stefan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.