Calling SAP BW EasyQuery from C# .Net

EasyQuery is SAP´s newest technology for providing external access to SAP BW via Web Services. Unfortunately there is not a whole lot information out there on how to actually call an EasyQuery Web Service other than from SAP standard tools like BO Design Studio, etc.
So here I’ll give a detailed introduction on how to call an EasyQuery from .Net via C# .
I assume that you have already created a BEx Query with the EasyQuery Option checked and that you also have generated your EasyQuery using transaction EQMANAGER.

Publishing a BEx Query

Publishing a BEx Query

Step 1

I’ll describe how to call the query via SOAP. So first of all we need to generate a Service Proxy with VisualStudio. So copy and paste the WSDL URL from EQMANAGER into the Visual Studio „Add Web Service Reference“ wizard

Adding a service reference

Adding a service reference

Step 2

Sometimes the generated proxy needs some manual adjustments. In case your project does not build you need to search and replace
global:: Prefix with „“ so it gets removed.

Step 3

Now we can use the proxy to actually access the Easy Query

In case there are errors when calling the query you can view the log using transcation SRT_ELOG .

The following code shows you how to actually call the query and get the data

using System;
using System.Net;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
using System.ServiceModel;
using EasyQueryWS.ValidationService;


namespace EasyQueryWS
{
class Class1
{
private static bool ValidateRemoteCertificate(object sender, X509Certificate cert, X509Chain chain, SslPolicyErrors policyErrors)
{
return true;
}


public static void Foo()
{
//Trust all certificates
System.Net.ServicePointManager.ServerCertificateValidationCallback =
((sender, certificate, chain, sslPolicyErrors) => true);// trust sender
System.Net.ServicePointManager.ServerCertificateValidationCallback
= ((sender, cert, chain, errors) => true);


// validate cert by calling a function
ServicePointManager.ServerCertificateValidationCallback += new RemoteCertificateValidationCallback(ValidateRemoteCertificate);


var binding = new BasicHttpsBinding()
{
SendTimeout = new TimeSpan(0, 10, 0),
MaxBufferSize = 20000000,
MaxReceivedMessageSize = 20000000,
ReaderQuotas = new System.Xml.XmlDictionaryReaderQuotas()
{
MaxDepth = 32,
MaxStringContentLength = 20000000,
MaxArrayLength = 20000000
},
Security = new BasicHttpsSecurity()
{
Mode = BasicHttpsSecurityMode.Transport,
Transport = new HttpTransportSecurity
{
ClientCredentialType = HttpClientCredentialType.Basic
}
}
};


var address = new EndpointAddress(„https://sap.test.de:9206/sap/bc/srt/pm/bic/easyquery/local/default_profile/1/binding_t_https_a_http__-bic_-nw_rplmfcadj_fnx_que_va41_default_profile_l“);


using (var svc = new _BIC_NW_RPLMFCADJ_FNX_QUE_VA41Client(binding, address))
{
svc.ClientCredentials.UserName.UserName = „Username“;


svc.ClientCredentials.UserName.Password = „Password“;


var i = new _bic_nf41
{
ISVar_01rplCaStdMiSiIM = new RseqSSelectOption()
{
//set some parameters
Option = „EQ“,
Sign = „I“,
Low = „ValueOfVariable“,
High = „“
},
ETColumnDescription = new RseqSColumnDescription[4]
};


//Initialization of some variables is required for some reason
i.ETColumnDescription[0] = new RseqSColumnDescription { ColumnDescription = „String 3“ };


i.ETGridData = new _bic_nd41[3];
i.ETGridData[0] = new _bic_nd41();


i.ETMessageLog = new Bapiret2[3];
i.ETMessageLog[0] = new Bapiret2();


i.ETRowDescription = new RseqSRowDescription[3];
i.ETRowDescription[0] = new RseqSRowDescription();


var result = svc._bic_nf41(i);


var data = result.ETGridData;
}
}
}
}

Technical names

When accessing the EasyQuery values and variables from C# code it is good to know how they relate to the technical names in the BEx Query Designer.

The Enterprise ID from BEx Designer identifies the value or variable in the C# code.

technical names
Enterprise Id as technical name

References:
https://blogs.sap.com/2012/01/24/soap-consumption-of-easy-query/

Fast Remote Support

 

You need support with the integration of EasyQueries?

Contact us for a quick support session via Skype.

info@yaico.de