cancel
Showing results for 
Search instead for 
Did you mean: 

JCO3 Java bapi mdx call

0 Kudos

Hi, after searching for 3 days without result, maybe someone can help me in the forum:

I want to do a BAPI MDX call with Java using the JCO3 SDK.

Connection is working, also found information to use bapi_mddataset_create_object and other functions.

But, how to build a complete code to get a result back from an MDX select?

Every hint or solution would be great!

Thx, Roland

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

got it... the code is fine, but I needed to find out, how to reach the data using bapi_mddataset_get_axis_data and ...get_cell_data...

Answers (1)

Answers (1)

0 Kudos

Hi,

so far I got a code, which works without an error,

but does not deliver any data.

The MDX itself works fine when using another tool to select the data.

If anyone can see, what's wrong in my code, pls answer. Thx!!

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);