Skip to Content
0

MDX Bapi throw .Net connector

Mar 21, 2017 at 03:11 AM

28

avatar image
Former Member

Hello.

I use sap net connector and have some issue.

It's my code for executing mdx.

IRfcFunction fn = dest.Repository.CreateFunction("BAPI_MDDATASET_CREATE_OBJECT");
var queryTable = fn.GetTable("COMMAND_TEXT");
queryTable.Append();
queryTable.CurrentRow.SetValue("LINE", "SELECT ");
queryTable.Append();
queryTable.CurrentRow.SetValue("LINE", "[Measures].[0COST] ON COLUMNS, ");
queryTable.Append();
queryTable.CurrentRow.SetValue("LINE", "[0SALESORG].[3091] ON ROWS ");
queryTable.Append();
queryTable.CurrentRow.SetValue("LINE", "FROM [$CA_SD_02M] ");

fn.Invoke(dest);

var datasetId = fn.GetString("DATASETID");

IRfcFunction selectData = dest.Repository.CreateFunction("BAPI_MDDATASET_SELECT_DATA");
selectData.SetValue("DATASETID", datasetId);
selectData.Invoke(dest);

var returnedValue = selectData.GetStructure("RETURN");
if (returnedValue.GetString("TYPE") == "E")
{
   Console.WriteLine("message: " + returnedValue.GetString("MESSAGE"));
   Console.WriteLine("message v1: " + returnedValue.GetString("MESSAGE_V1"));
   Console.WriteLine("message v1: " + returnedValue.GetString("MESSAGE_V2"));
   Console.WriteLine("message v1: " + returnedValue.GetString("MESSAGE_V3"));
   Console.WriteLine("message v1: " + returnedValue.GetString("MESSAGE_V4"));            

}

it shows follow, without any details:

message: An exception was raised.
message v1: An exception was raised.
message v1:
message v1:
message v1:

I tested this query throw oledb for olap (mdrmsap), it works.

Any suggestion?

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

avatar image
Former Member Apr 19, 2017 at 04:32 AM
0

Solved.

Need to use

RfcSessionManager.BeginContext(dest)

Share
10 |10000 characters needed characters left characters exceeded