cancel
Showing results for 
Search instead for 
Did you mean: 

I'm using jco to get data from bw query

0 Kudos

I'm using jco to get data from bw query , but get error "Trying to access row values in a table which does not have any rows yet" return;

My code is

Properties connectProperties = new Properties(); connectProperties.setProperty(DestinationDataProvider.JCO_ASHOST, "192.168.4.231"); connectProperties.setProperty(DestinationDataProvider.JCO_SYSNR, "00"); connectProperties.setProperty(DestinationDataProvider.JCO_CLIENT, "000"); connectProperties.setProperty(DestinationDataProvider.JCO_USER, "DDIC"); connectProperties.setProperty(DestinationDataProvider.JCO_PASSWD, "c`460653078"); connectProperties.setProperty(DestinationDataProvider.JCO_LANG, "en"); JCoDestination destination = JCoDestinationManager.getDestination("ABAP_AS_WITHOUT_POOL"); JCoContext.begin(destination); JCoFunction function_create = destination.getRepository().getFunction("BAPI_MDDATASET_CREATE_OBJECT"); JCoParameterList tableParams = function_create.getTableParameterList(); try { JCoTable table = null; JCoFieldIterator iter = tableParams.getFieldIterator(); while (iter.hasNextField()) { JCoField f = iter.nextField(); if (f.getName().equals("COMMAND_TEXT") & f.isTable()) { table = f.getTable(); } } // set mdx statementtable.appendRow(); table.setValue("LINE", "SELECT {[4F0Q0T89JPDJCFX8AUVRPFVA0].[C2RRWD6RC4GKR195AFCVHE9LQ]} "); table.appendRow(); table.setValue("LINE", "ON COLUMNS, NON EMPTY [0COMP_CODE].[LEVEL01].MEMBERS DIMENSION "); table.appendRow(); table.setValue("LINE", "PROPERTIES [0COMP_CODE].[10COMP_CODE] ON ROWS "); table.appendRow(); table.setValue("LINE", "FROM [STCO_M01/YSTFI02_BRAND_PL_COGNOS]"); // assign to objec tableParams.setValue("COMMAND_TEXT", table); // execute function_create.execute(destination); // get datasetid Object datasetid = function_create.getExportParameterList().getValue("DATASETID"); // define next function JCoFunction function_select = destination.getRepository().getFunction("BAPI_MDDATASET_SELECT_DATA"); // use datasetid form function_create function_select.getImportParameterList().setValue("DATASETID", datasetid); function_select.execute(destination); System.out.println("executed 2"); // get exportParams JCoParameterList selectReturnList = function_select.getExportParameterList(); JCoParameterFieldIterator paramIt = selectReturnList.getParameterFieldIterator(); JCoStructure struc = null; // loop through params while (paramIt.hasNextField()) { try { JCoField field = paramIt.nextField(); if (field.getName().equals("RETURN")) { struc = field.getStructure(); System.out.println("message: " + struc.getString("MESSAGE")); System.out.println("message type: " + struc.getString("TYPE")); } } catch (Exception e) { e.printStackTrace(); } } // get Axis Info JCoFunction function_getAxisInfo = destination.getRepository().getFunction("BAPI_MDDATASET_GET_AXIS_INFO"); function_getAxisInfo.getImportParameterList().setValue("DATASETID", datasetid); function_getAxisInfo.execute(destination); System.out.println(function_getAxisInfo.getImportParameterList()); System.out.println(function_getAxisInfo.getExportParameterList()); System.out.println(function_getAxisInfo.getTableParameterList()); JCoContext.end(destination); } catch (Exception e) { e.printStackTrace(); }

can anyone help me?

former_member30
Community Manager
Community Manager
0 Kudos

Hi and welcome to the SAP Community!

Thank you for visiting SAP Community to get answers to your questions. Since you're asking a question here for the first time, I recommend that you familiarize yourself with https://community.sap.com/resources/questions-and-answers (if you haven't already), as it provides tips for preparing questions that draw responses from our members.

Should you wish, you can revise your question by selecting Actions, then Edit (although once someone answers your question, you'll lose the ability to edit the question -- but if that happens, you can leave more details in a comment).

Finally, if you're hoping to connect with readers, please consider adding a picture to your profile. Here's how you do it: https://www.youtube.com/watch?v=F5JdUbyjfMA&list=PLpQebylHrdh5s3gwy-h6RtymfDpoz3vDS. By personalizing your profile with a photo of you, you encourage readers to respond.

Cheers,

Julia
SAP Community Moderator

Accepted Solutions (0)

Answers (0)