Salesforce and sap integration

Preview:

DESCRIPTION

This is topic is presented by Sridhar Barla (Technical Lead at GE) in Chennai salesforce platform developer meetup

Citation preview

Sales force Integration

Sridhar Barla

Agenda

Agenda

Platform APIs : Breif History

– SOAP

– Bulk

– REST

– Also : calouts & APEX WS

Intégration use case for SOAP API

– Intégration Sales force Data with SAP

– Intégration sales force data with Primavera

SOAP APIintegration

Create a middle ware web service in .Net

2003/2005/2008/2010

Add Sales force WSDL (Enterprise /Partner ) file as

web reference in middle ware web service

Create a Web method As

Get_Quote()

Implement logic to read data from quote object

Read data from SFDC

SforceService sobj = new SforceService();

System.Net.NetworkCredential cr = new

System.Net.NetworkCredential(“sridhar", "taralika", “chennai");

System.Net.WebProxy proxy = new System.Net.WebProxy("http-proxy-

sample.com", 80);

proxy.Credentials = cr;

sobj.Proxy = proxy;

LoginResult lr = sobj.login(“dhamodhar@gmail.com.",

“testpasswordplusRFwWSPB4PPjWdjpDO3VC2yts");

sobjj.Url = lr.serverUrl;

sobj.SessionHeaderValue = new SessionHeader();

sobj.SessionHeaderValue.sessionId = lr.sessionId;

QueryResult quoteDetails = null;

sobj.QueryOptionsValue = new QueryOptions();

sobj.QueryOptionsValue.batchSize = 1000;

sobj.QueryOptionsValue.batchSizeSpecified = true;

string sforceQuery = "Select

ID,NAME,RECORDTYPEID,RecordType.Name,PARENTID,OWNERI

D,CREATEDDATE,CREATEDBYID,LASTMODIFIEDDATE,LASTMO

DIFIEDBYID,SAPREF__C,

ACCOUNTACTIVITYSTATUS__C,ACCOUNTCOUNTRY__C,DUNS

NUMBER__C,REPRESENTATIVE__C,COMPETITOR__C,OEM__C,

ENDUSER__C,EPCDESIGNINSTITUTE__C,KEYACCOUNT__C,FL

OW_BUSINESS_ACCOUNT__C,OTHERTYPEACCOUNT__C,INDU

STRY__C,CVTUNIT__C from Quote__C";

quoteDetails = sobj .query(sforceQuery);

bool bContinue = true;

while (bContinue)

{

if (quoteDetails .records != null)

{

if (quoteDetails .records.Length > 0)

{

quoteListObj.Add(quoteDetails );

//handle the loop + 1 problem by checking the most recent queryResult

if (quoteDetails .done)

bContinue = false;

else

quoteDetails = sobj .queryMore(accDetails.queryLocator);

}

}

else

{

bContinue = false;

}

}

Access Middle ware in SAP

Make sure, that the proxy configuration is ok. In SAP

other wise you won’t have a chance to connect to an

external web service.

To check proxy settings use SM59 transaction code

Create Consumer Proxy in SAP

At first you have to generate a consumer proxy. A proxy

class will be generated

Generation can be triggered out of SE80:

In the following dialogue you have to input the WSDL, in

order that the proxy settings can be retrieved

automatically

The following screenshot display the consumer proxy.

For our example, the default settings are o.k.

Next step is to create a logical port

The logical port is necessary to call the external web

service. You create the logical port with transaction

SOAMANAGER.

Within SOAMANAGER you have to go for the Single

Service Administration:

Within SOAMANAGER you have to select the

respective web service

After applying the selection, you just push the button for creation of logical port and use the default setting. Be

sure to input the correct URL for the WSDL into the creation dialogue and write down the logical port name.

This will be used in your ABAP coding. Also make sure, that the proxy settings are entered

ABAP Coding

The following sample coding consumes the external

web service. It uses the created consumer proxy and

the logical port to request the quote for the symbol

SAP. After successful calling, the structure out keeps

the actual values for the SAP stock.

SAP integration

Integrate Sales force and SAP with using middle ware

technology as .NET

SAP .NET connector– SAP connector 2.0

– SAP connector 3.0

Sales force WSDL (Enterprise /Partner )

SAP connector versions and .NET versions

SAP connector 2.0 supports Visual studio .NET 2003

only and this connector supports XP not windows 7

SAP connector 3.0 supports all Visual studio versions.

SAP connector 2.0

Download SAP connector from service.sap.com/connectors and install

Open visual studio 2003 and createa class Library project as SAPProxyLib

After you add the proxy, you will notice that the system automatically adds the

necessary references to your project as well as creates a WSDL file

called SAPProxy1.wsdl. This file will show up as a blank screen in Visual Studio, as

shown in figure below:

Once the proxy has been added, it's time to add the SAP Server to your project. Click View,

then click Server Explorer and you will see that an option for SAP is included in the list. Click

the SAP entry and it will expand and show "Application Servers". Right click this and select

"Add Application Server". A dialog box similar to Figure below will appear

This is where you will need to set your parameters for establishing a

connection to your SAP server. Change the Destination Type property to

“Custom”, then add the necessary values for the following properties:

– User Name

– Password

– AppServerHost

– SAPRouterString

– HTTP Port

– Client

– System Number

These variables will depend on your SAP installation. Check with

your SAP Administrator for the specific settings in your environment.

Once you have the properties set, you can then establish your connection to SAP.

Expand the new server, then expand the Functions entry. This will provide a list of

all ABAP functions that are contained in your SAP environment. See figure below:

The next step is to locate the function that you wish to call. When you find it, simply

drag and drop it onto theSAPProxy1.sapwsdl file. It will automatically create several

objects and even code files that relate to your particular function (note that you need

to be viewing all files in your project to see the code files that the process creates):

Right click the solution and Build the project

Then system generate dll like SAPProxyLib.dll

This class library you can use any .NET version

application

Create new website in VS2010

Add web reference Sales force WSDL (Enterprise

/Partner )

Add reference SAPProxyLib.dll

Read data from SAP

SAPProxyLib.SAPProxy1 BAPI = new SAPProxyLib .SAPProxy1();

DataSet salesOrder = new DataSet();

string conStr = "ASHOST=xx.xx.xx.xx SYSNR=0 CLIENT=10 USER=IM_SREE

PASSWD=sappass LANG=EN";

BAPI = new SAPProxyLib .SAPProxy1(conStr);

System.Net.NetworkCredential cr = new System.Net.NetworkCredential(“1236456",

“password", “chennai");

System.Net.WebProxy proxy = new System.Net.WebProxy(“proxyservername", 80);

proxy.Credentials = cr;

BAPI.Proxy = proxy;

BAPI.Connection.Open();

SAPProxy1.BAPIRET2 ret = new SAPProxy1.BAPIRET2();

SAPProxy1.ZPROJOUT proj = new SAPProxy1.ZPROJOUT();

SAPProxy1.ZPROJOUTTable prjOut = new SAPProxy1 ZPROJOUTTable();

BAPI.Zbapi_Proj_Sales_Details(startdate, ref prjOut);//

if (prjOut.Count > 0) {

salesOrder.Tables.Add(prjOut.ToADODataTable());

if (salesOrder.Tables[0].Rows.Count > 0) {

foreach (DataRow salesDetails in salesOrder.Tables[0].Rows) {

}

Read Data from SAP with using SAP connector 3.0

using SAP.Middleware.Connector;

Recommended