Monday, March 19, 2012

How To Connect To SAP Service in .Net

Labels: , ,
Posted on Monday, March 19, 2012

How To Connect To SAP Service in .Net
This was my dilemma last week. I was tasked to connect to SAP service to get some data that my new system will need. I was able to connect to the service and pass the parameters but I wasn't able to get the result. If I test the ESB side, the service that I was calling was giving result so the problem is my coding.

Thankfully, my colleague gave me the code to get the result of the service. The code that I'm lacking are the two lines of the code. You just need to declare the response of the service and pass the response of the method.

private SAPService.service _SAPService;
private SAPService.ZhrCostcentreInfo1 SAPTable;

_SAPService = new SAPService.service();
_SAPService.PreAuthenticate = true;
_SAPService.Credentials = new NetworkCredential("username", "password");

SAPService.ZhrCostcentreInfo[] result = new CHS.SAPService.ZhrCostcentreInfo[1];

SAPTable = new CHS.SAPService.ZhrCostcentreInfo1();
SAPTable.Costcentre = "";
SAPTable.EffDte = "";
SAPTable.Orgeh = "";
SAPTable.Pernr = "";
SAPTable.ZhrCostcentre = result;

CHS.SAPService.ZhrCostcentreInfoResponse respobj = new CHS.SAPService.ZhrCostcentreInfoResponse();

respobj = _SAPService.ZhrCostcentreInfo(SAPTable);

0 Responses to “How To Connect To SAP Service in .Net”

Related Posts Plugin for WordPress, Blogger...