on 04-22-2021 11:03 AM
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?
User | Count |
---|---|
78 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.