Skip to Content
0
Former Member
Feb 09, 2017 at 12:29 PM

Connecting to SAP BCM url from .NET Application

515 Views Last edit Feb 09, 2017 at 12:47 PM 2 rev

Our client has provided with one SAP url. They have also given function name and table name and sample data.

We want to consume that url from our .net application and import data from their table to our application.Here is our sample code

public static SAP.Middleware.Connector.RfcDestination connect()
{
RfcDestination testconnect = RfcDestinationManager.GetDestination("QA");
return testconnect;
}
public DataSet GetData(string companycode,string empid)
{
RfcDestination test = connect(); DataSet contacts = new DataSet(); try
{
//RfcRepository rfcrepos = test.Repository;
RfcSessionManager.BeginContext(test);
IRfcFunction rfcfunction = test.Repository.CreateFunction("***-***-***");//
rfcfunction.SetValue("I_BUKRS", companycode);
rfcfunction.SetValue("I_PERNR", empid);
rfcfunction.Invoke(rfcdestination);
contacts.Tables.Add(Converttodatatable(rfcfunction.GetTable("CONTACTS")));

}
catch (Exception ex)
{
throw new Exception(ex.InnerException.ToString());
}
return contacts;
}

config file:

<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<sectionGroup name="SAP.Middleware.Connector">
<sectionGroup name="ClientSettings">
<section name="DestinationConfiguration" type="SAP.Middleware.Connector.RfcDestinationConfiguration, sapnco"/>
</sectionGroup>
</sectionGroup>
</configSections>
<SAP.Middleware.Connector>
<ClientSettings>
<DestinationConfiguration>
<destinations>
<add NAME="QA" USER="***" PASSWD="****" CLIENT="001" LANG="EN" SYSID="000"
ASHOST="*************************" SYSNR="50001" MAX_POOL_SIZE="200" IDLE_TIMEOUT="100"/>
</destinations>
</DestinationConfiguration>
</ClientSettings>
</SAP.Middleware.Connector>

Their URL is something like

https://sampletestname:50001/dir/wsdl?p=tt/f94ac0e18ab0397a8b5703a9a578343a0

Here we are getting in repository.Createfunction() as below:

No RFC authorization for function module RFC_METADATA_GET.

NOTE: They have given only username and password to connect to url