<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>SAP Experts: VMware Virtualization &#124; Consulting &#124; Integration - DataXstream &#187; SAP .Net Connector</title>
	<atom:link href="http://www.dataxstream.com/tag/sap-net-connector/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dataxstream.com</link>
	<description>SAP Certified Consultants</description>
	<lastBuildDate>Sat, 04 Feb 2012 05:00:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Build an RFC Client with NCo 3.0 for VB.NET &#8211; A Step-By-Step Guide</title>
		<link>http://www.dataxstream.com/2011/11/nco-3-rfc-client-vb-net-step-by-step/</link>
		<comments>http://www.dataxstream.com/2011/11/nco-3-rfc-client-vb-net-step-by-step/#comments</comments>
		<pubDate>Tue, 08 Nov 2011 16:50:25 +0000</pubDate>
		<dc:creator>Craig Stasila</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[SAP Interface Blog]]></category>
		<category><![CDATA[SAP Technical]]></category>
		<category><![CDATA[.Net Connector]]></category>
		<category><![CDATA[Craig Stasila]]></category>
		<category><![CDATA[DataXstream]]></category>
		<category><![CDATA[NCo]]></category>
		<category><![CDATA[NCo 3.0]]></category>
		<category><![CDATA[SAP .Net Connector]]></category>
		<category><![CDATA[VB.NET]]></category>

		<guid isPermaLink="false">http://www.dataxstream.com/?p=9772</guid>
		<description><![CDATA[Recently, I published an article showing step-by-step instructions for how to consume an SAP RFC with the SAP .Net Connector 3.0 (NCo 3.0).  The article included code samples and a working code example for download written in C#.  Well, not everybody writes in C#.  There are some of you that would prefer to write in VB.NET. [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, I published an article showing step-by-step instructions for <a title="Build an RFC Client with NCo 3.0 – A Step-By-Step Guide" href="http://www.dataxstream.com/2011/08/nco-3-rfc-client-step-by-step/">how to consume an SAP RFC with the SAP .Net Connector 3.0 (NCo 3.0)</a>.  The article included code samples and a working code example for download written in C#.  Well, not everybody writes in C#.  There are some of you that would prefer to write in VB.NET.  So, I have heeded your call, all you VB.NET developers!  Here is your very own article detailing how to build an RFC client with NCo 3.0 for VB.NET.</p>
<p>The SAP .Net Connector 3.0 (NCo 3.0) offers many improvements over SAP .NET Connector 2.0. Unfortunately, SAP no longer offers example .NET code.  This blog attempts to fill that gap by describing how to build a simple RFC Client using SAP .Net Connector (NCo) 3.0 with VB.NET.  <a href="http://www.dataxstream.com/sap-nco-3-0-rfc-client-code-sample-for-visual-basic/" target="_blank">Click here</a> to request a .zip file containing a copy of the source code.</p>
<p><span id="more-9772"></span>The sample program displays details about companies defined by SAP. There are two BAPI calls involved, BAPI_COMPANY_GETLIST and BAPI_COMPANY_GETDETAIL.<br />
Along with the SAP .Net Connector 3.0, we are using Microsoft Visual Studio 2010 and the Microsoft .Net Framework 4.0 to build our sample.  Prior to starting, you will have to download and install <a href="http://service.sap.com/connectors" target="_blank">NCo 3.0</a> (OSS login required).<br />
<img title="More..." src="http://www.dataxstream.com/wp-includes/js/tinymce/plugins/wordpress/img/trans.gif" alt="" /></p>
<h2>Setting up the Project</h2>
<p>Using Visual Studio 2010, create a new Windows Form project. In the project properties, be sure to set the Target Framework to .Net Framework 4.0.  To change the target .NET framework version on a VB.NET project, first open the project&#8217;s property page.  Click on the &#8220;Compile&#8221; tab in the property page.  Then click on the &#8220;Advanced Compile Options..&#8221; button.</p>
<p><a href="http://www.dataxstream.com/wp-content/uploads/NCO3_Client_VB_01.png" rel="shadowbox[sbpost-9772];player=img;"><img class="alignnone size-full wp-image-9773" title="Change .NET Framework Target Version" src="http://www.dataxstream.com/wp-content/uploads/NCO3_Client_VB_01.png" alt="" width="645" height="311" /></a></p>
<p>In the ensuing dialog window, change the target framework version.</p>
<p><a href="http://www.dataxstream.com/wp-content/uploads/NCO3_Client_VB_02.png" rel="shadowbox[sbpost-9772];player=img;"><img class="alignnone size-full wp-image-9774" title="Change .NET Framework Target Version (No Client Profile)" src="http://www.dataxstream.com/wp-content/uploads/NCO3_Client_VB_02.png" alt="" width="520" height="423" /></a></p>
<p>Next, add references to the SAP .Net Connector 3.0. There are two DLLs, sapnco.dll and sapnco_utils.dll.</p>
<p><a href="http://www.dataxstream.com/wp-content/uploads/NCO3_Client_VB_03.png" rel="shadowbox[sbpost-9772];player=img;"><img class="alignnone size-full wp-image-9775" title="Add Reference to NCo 3.0" src="http://www.dataxstream.com/wp-content/uploads/NCO3_Client_VB_03.png" alt="" width="315" height="225" /></a></p>
<p>&nbsp;</p>
<h2>Design the Form</h2>
<p>Add two controls to the form. The first is a List Box, which will contain the list of available SAP companies. The second control to add is a Property Grid control, which is used to display the details of a particular SAP company when the user selects one from the List Box.</p>
<p><a href="http://www.dataxstream.com/wp-content/uploads/NCO3_Client_VB_04.png" rel="shadowbox[sbpost-9772];player=img;"><img class="alignnone size-full wp-image-9776" title="Design Windows Form" src="http://www.dataxstream.com/wp-content/uploads/NCO3_Client_VB_04.png" alt="" width="562" height="445" /></a></p>
<p>&nbsp;</p>
<h2>Using App.Config to define the SAP Connections</h2>
<p>There are several methods you can use in your solutions to define a particular SAP host. For this example, we are using an app.config file to define our SAP host.<br />
The SAP .Net Connector 3.0 includes sample app.config files. For the RFC client, be sure there is a sectionGroup definition for &lt;ClientSettings&gt;.<br />
The SAP host is defined by the destinations section. Within the destination, the Name field identifies this app.config entry to our program code. Specify the appropriate user name, password, SAP host name, client and system number in the destination section.</p>
<p><a href="http://www.dataxstream.com/wp-content/uploads/NCO3_Client_VB_05.png" rel="shadowbox[sbpost-9772];player=img;"><img class="alignnone size-full wp-image-9777" title="App.config" src="http://www.dataxstream.com/wp-content/uploads/NCO3_Client_VB_05.png" alt="" width="647" height="230" /></a></p>
<h2>The BAPIs</h2>
<p>Use the SAP transaction SE37 to determine the parameters for functions BAPI_COMPANY_GETLIST and BAPI_COMPANY_GETDETAIL. This will tell us what parameters need to be passed in and where to find the results that are returned to our code.</p>
<h2>The Code</h2>
<p>During the form load event, we want to populate our List Box with the defined companies from SAP.</p>
<ol>
<li>Acquire a valid RfcDestination to use. Use method RfcDestinationManager.GetDestination() to do this. GetDestination() requires a parameter to determine which SAP host to refer to. Pass in the Name of the SAP host you previously defined in the app.config file. (Line 39)</li>
<li>Now that we have a valid RfcDestination object, we need access to the SAP Repository. The repository contains information about the BAPI calls we are going to make. The RfcRepository is an attribute of an RfcDestination object. (Line 42)</li>
<li>Using the RfcRepository object, acquire a reference to the SAP BAPI by calling method RfcRepository.CreateFunction() method. Pass in the name of the desired function as a string parameter to CreateFunction(). This method returns an object we can use to setup parameters, invoke the function, and retrieve results.</li>
<li>Now we can make the RFC calls into SAP. Using the IRfcFunction object returned by CreateFunction(), call the Invoke() method, passing in our RfcDestination object as parameter. This will make the RFC call into SAP, and provides the results via our IRfcFunction object. (Line 48)</li>
<li>SAP function BAPI_GET_COMPANYLIST returns a table of company records. We use an instance of an IRfcTable object that we retrieve by calling the GetTable() method on the IRfcFunction object. To get a desired table, pass in the table name to the GetTable() method. (Line 50)</li>
<li>We now have an instance of an IRfcTable object that contains company information through which we can iterate. It is possible to iterate through the data by setting the CurrentIndex property on the returned table. For a particular row in the table, it is possible to access values using the GetString() method. (Lines 55-59)</li>
<li>For each company, get the CompanyNumber, and use that as a parameter to SAP function BAPI_COMPANY_GETDETAIL. BAPI_COMPANY_GETDETAIL returns detailed information about that particular SAP company. The techniques are the same as before, with the additional step of using the SetValue() method on the IRfcFunction object to pass in the company number as a parameter. (Lines 60-67)</li>
<li>BAPI_COMPANY_GETDETAIL returns data as an instance of the IRfcStructure interface. Access individual field data of the company record, using the GetString() method of the IRfcStructure object instance. (Lines 67-78)</li>
<li>Extract the company details as desired. Add them to some object you create and then add that object to the List Box control. (Line 80)</li>
</ol>
<p>&nbsp;</p>
<p><a href="http://www.dataxstream.com/wp-content/uploads/NCO3_Client_VB_06.png" rel="shadowbox[sbpost-9772];player=img;"><img class="alignnone size-full wp-image-9778" title="NCo 3.0 RFC Client Sample VB.NET Code" src="http://www.dataxstream.com/wp-content/uploads/NCO3_Client_VB_06.png" alt="" width="580" height="523" /></a></p>
<p>The rest of the code is regular Windows Forms programming. Your code will need to wire up the List Box changed events so that the Property Grid will display the details of the selected company.</p>
<h2>Additional Information</h2>
<p>Follow these links for more information about NCo 3.0 programming:</p>
<ul>
<li>Webinar: <a href="http://www.dataxstream.com/sap_webinars/sap-nco-3-0-best-practice-guide-for-upgrade-from-net-connector-2-0/">SAP NCo 3.0 – Best Practice Guide for Upgrade from .NET Connector 2.0</a></li>
<li>Source Code: <a href="http://www.dataxstream.com/sap-nco-3-0-rfc-client-code-sample-for-visual-basic/" target="_blank">RFC Client with NCo 3.0 for VB.NET</a></li>
<li>C# version of this example: <a title="Build an RFC Client with NCo 3.0 – A Step-By-Step Guide" href="http://www.dataxstream.com/2011/08/nco-3-rfc-client-step-by-step/" target="_blank">Build an RFC Client with NCo 3.0 &#8211; A Step-By-Step Guide</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.dataxstream.com/2011/11/nco-3-rfc-client-vb-net-step-by-step/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>NCo 3.0: Reconnecting a Broken RFC Server Connection</title>
		<link>http://www.dataxstream.com/2011/09/nco-3-0-reconnecting-a-broken-rfc-server-connection/</link>
		<comments>http://www.dataxstream.com/2011/09/nco-3-0-reconnecting-a-broken-rfc-server-connection/#comments</comments>
		<pubDate>Wed, 21 Sep 2011 14:10:17 +0000</pubDate>
		<dc:creator>Craig Stasila</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[SAP Interface Blog]]></category>
		<category><![CDATA[SAP Technical]]></category>
		<category><![CDATA[.Net Connector]]></category>
		<category><![CDATA[Craig Stasila]]></category>
		<category><![CDATA[DataXstream]]></category>
		<category><![CDATA[NCo]]></category>
		<category><![CDATA[NCo 3.0]]></category>
		<category><![CDATA[RFC Server]]></category>
		<category><![CDATA[SAP .Net Connector]]></category>

		<guid isPermaLink="false">http://www.dataxstream.com/?p=8826</guid>
		<description><![CDATA[Don&#8217;t you hate it when you&#8217;re talking on the cell phone and the call drops?   I was talking to my wife on the way to my client site this week and was telling her about this awesome blog post I was writing when the call dropped.  Bummer.  Since I really wanted to tell her [...]]]></description>
			<content:encoded><![CDATA[<p>Don&#8217;t you hate it when you&#8217;re talking on the cell phone and the call drops?   I was talking to my wife on the way to my client site this week and was telling her about this awesome blog post I was writing when the call dropped.  Bummer.  Since I really wanted to tell her about my blog, I wanted to complete the conversation.  But first, I had to wait for service.  Then I had to call her back, and have her answer.  Then I uttered the phrase that all cell phone users know, &#8220;What was the last thing you heard me say?&#8221;  It was a fairly messy recovery, but I was finally able to talk about my blog!</p>
<p>When two software systems integrate, we also have to deal with the &#8220;dropped call&#8221; problem.  SAP NCo 3.0 offers a few different levels of  data recovery options depending on whether NCo is the client or the server.  But before any data recovery can happen, the first step is to call the other party back.  This blog post describes the general process to reconnect an NCo RfcServer to an SAP gateway host.</p>
<p><span id="more-8826"></span></p>
<p>I have read in other blogs that SAP claims their RfcServer object will automatically reconnect if it detects a dropped connection.  While this may be true, I have not seen this automatic reconnection occur in all the testing that I have done.  So, left to my own devices, I set out to figure out the best way to reconnect an RfcServer.</p>
<p>The first thing I did was to map out the &#8220;dropped call&#8221; process diagram.</p>
<p><a href="http://www.dataxstream.com/wp-content/uploads/PhoneCall_Reconnect_Flow-e1316637566273.png" rel="shadowbox[sbpost-8826];player=img;"><img class="alignnone size-full wp-image-9212" title="Phone Call Reconnection Flowchart" src="http://www.dataxstream.com/wp-content/uploads/PhoneCall_Reconnect_Flow-e1316637566273.png" alt="" width="534" height="402" /></a></p>
<p>I know that some of you are thinking that after a call is dropped it is not necessary to hang up.  This is true.  But the connection needs to be cleaned up.  In the mobile phone analogy, the phone automatically detects the dropped call and hangs up for you.  What I found during my research is that NCo 3.0 doesn&#8217;t automatically clean up broken connections, nor does it automatically clean up failed connection attemps.</p>
<p>Armed with this flow chart, my new found understanding of NCo 3.0, some Diet Mountain Dew, and a bag of Skittles, I decided to tackle coding a similar solution in C# using NCo 3.0.</p>
<p>But first, I tweaked my flow chart:</p>
<p><a href="http://www.dataxstream.com/wp-content/uploads/RfcServer_Reconnect_Flow.png" rel="shadowbox[sbpost-8826];player=img;"><img class="alignnone size-full wp-image-8829" src="http://www.dataxstream.com/wp-content/uploads/RfcServer_Reconnect_Flow.png" alt="" width="534" height="402" /></a></p>
<p>The result was a RfcServer NCo 3.0 project that would automatically recover from connection errors.  The key concept is to call the <span style="font-family: Consolas, Courier, monospace;">Shutdown()</span> method of the <span style="font-family: Consolas, Courier, monospace;">RfcServer</span> object after each connection failure.  Add in an event handler for the RfcServerError Event and a timer, and the rest falls into place.</p>
<h2>Download RfcServer Reconnection Sample NCo 3.0 Project</h2>
<p>A full sample C# project is available for download here: <a title="SAP NCo 3.0 RFC Server Reconnection Sample" href="http://www.dataxstream.com/sap-nco-3-0-rfc-server-reconnection-sample/">SAP NCo 3.0 RFC Server Reconnection Sample</a></p>
<h2>Additional SAP NCo 3.0 Information</h2>
<p>Follow these links for more information about SAP NCo 3.0 programming:</p>
<ul>
<li><a title="SAP NCo 3.0 – Best Practice Guide for Upgrade from .NET Connector 2.0" href="http://www.dataxstream.com/sap_webinars/sap-nco-3-0-best-practice-guide-for-upgrade-from-net-connector-2-0/">Webinar: SAP NCo 3.0 – Best Practice Guide for Upgrade from .NET Connector 2.</a></li>
<li><a title="Build an RFC Client with NCo 3.0 – A Step-By-Step Guide" href="http://www.dataxstream.com/2011/08/nco-3-rfc-client-step-by-step/">Build an RFC Client with NCo 3.0 – A Step-By-Step Guide</a></li>
<li><a title="Build an RFC Server with NCo 3.0 – A Step-By-Step Guide" href="http://www.dataxstream.com/2011/08/nco-3-rfc-server-step-by-step/">Build an RFC Server with NCo 3.0 – A Step-By-Step Guide</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.dataxstream.com/2011/09/nco-3-0-reconnecting-a-broken-rfc-server-connection/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Build an RFC Server with NCo 3.0 – A Step-By-Step Guide</title>
		<link>http://www.dataxstream.com/2011/08/nco-3-rfc-server-step-by-step/</link>
		<comments>http://www.dataxstream.com/2011/08/nco-3-rfc-server-step-by-step/#comments</comments>
		<pubDate>Tue, 23 Aug 2011 19:15:01 +0000</pubDate>
		<dc:creator>Craig Stasila</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[SAP Interface Blog]]></category>
		<category><![CDATA[SAP Technical]]></category>
		<category><![CDATA[.Net Connector]]></category>
		<category><![CDATA[Craig Stasila]]></category>
		<category><![CDATA[DataXstream]]></category>
		<category><![CDATA[NCo]]></category>
		<category><![CDATA[NCo 3.0]]></category>
		<category><![CDATA[SAP .Net Connector]]></category>

		<guid isPermaLink="false">http://www.dataxstream.com/?p=8763</guid>
		<description><![CDATA[&#160; SAP .NET Connector 2.0 offered a couple of different sample projects that were instrumental in my learning process.  As I mentioned in my post detailing the steps to build an RFC client, SAP no longer supplies code samples with SAP .NET Connector (NCo) 3.0.  So, I decided to make available some code examples created by [...]]]></description>
			<content:encoded><![CDATA[<p>&nbsp;</p>
<p>SAP .NET Connector 2.0 offered a couple of different sample projects that were instrumental in my learning process.  As I mentioned in my post <a title="Build an RFC Client with NCo 3.0 – A Step-By-Step Guide" href="http://www.dataxstream.com/2011/08/nco-3-rfc-client-step-by-step/">detailing the steps to build an RFC client</a>, SAP no longer supplies code samples with SAP .NET Connector (NCo) 3.0.  So, I decided to make available some code examples created by my colleague, <a href="http://www.dataxstream.com/author/tdebruicker/">Terry DeBruicker</a>.</p>
<p>This blog describes how to build a simple RFC Server using the SAP NCo 3.0. The sample program implements RFC STFC_CONNECTION.  STFC_CONNECTION is a good example to use because it contains both importing and exporting parameters.</p>
<p><span id="more-8763"></span></p>
<p><a title="SAP NCo 3.0 RFC Server Sample Code" href="http://www.dataxstream.com/sap-nco-3-0-rfc-server-sample-code/">Click here</a> to request a .zip file containing a copy of the source code.</p>
<p>Along with the SAP .Net Connector 3.0, we are using Microsoft Visual Studio 2010 and the Microsoft .Net Framework 4.0 to build our sample. Prior to starting, you will have to download and install <a href="http://service.sap.com/connectors" target="_blank">NCo 3.0</a> (OSS login required).</p>
<h2>Setting up the Project</h2>
<p>Using Visual Studio 2010, create a new console project. In the project properties, be sure to set the Target Framework to .Net Framework 4.0.</p>
<p><a href="http://www.dataxstream.com/wp-content/uploads/RFC_Server01.png" rel="shadowbox[sbpost-8763];player=img;"><img class="alignnone size-full wp-image-8765" src="http://www.dataxstream.com/wp-content/uploads/RFC_Server01.png" alt="" width="624" height="401" /></a></p>
<p>Next, add references to the SAP .Net Connector 3.0. There are two DLLs, sapnco.dll and sapnco_utils.dll.</p>
<p><a href="http://www.dataxstream.com/wp-content/uploads/RFC_Server02.png" rel="shadowbox[sbpost-8763];player=img;"><img class="alignnone size-full wp-image-8766" src="http://www.dataxstream.com/wp-content/uploads/RFC_Server02.png" alt="" width="384" height="150" /></a></p>
<h2>Using App.Config to define the SAP Connections</h2>
<p>There are several methods you can use in your solutions to define a particular SAP host. For this simple example, we are using an app.config file to define our SAP host connection information.</p>
<p>One of the biggest differences between NCo 3.0 and NCo 2.0 is how function metadata is retrieved and stored.  With NCo 2.0 the function metadata was downloaded from an SAP system at design  time and persisted as proxy objects that were compiled with the rest of your solution.  NCo 3.0 needs to access this metadata at <em>runtime</em>.  There are two methods for providing this metadata.  One method is to create the metadata in your .NET code.  The other method is to rely on the metadata stored in the SAP system.  For this example, we will rely on the SAP system to provide RFC metadata.  This metadata is retrieved using special built-in RFCs.  Therefore, not only will our program act as an RFC server, it will also need to act as an RFC client.</p>
<p>For basic RFC server configuration, there are two configuration sections that are used, <span style="font-family: Consolas, Courier, monospace"><span style="color: #0000ff">&lt;</span><span style="color: #800000">ClientSettings</span><span style="color: #0000ff">&gt;</span></span> and <span style="font-family: Consolas, Courier, monospace"><span style="color: #0000ff">&lt;</span><span style="color: #800000">ServerSettings</span><span style="color: #0000ff">&gt;</span></span>.  Ensure that the app.config file has a <span style="font-family: Consolas, Courier, monospace"><span style="color: #0000ff">&lt;</span><span style="color: #800000">sectionGroup</span><span style="color: #0000ff">&gt;</span></span> tag for both client and server settings.</p>
<p>An RFC server configuration is linked to a RFC repository by use of the <span style="font-family: Consolas, Courier, monospace"><span style="color: #ff0000">REPOSITORY_DESTINATION</span></span> attribute.  To be able to access function metadata, this attribute must match the name of a destination configuration in the client settings section.</p>
<p>All SAP NCo 3.0 RFC servers communicate with SAP through a SAP service called the gateway.  The server settings configuration section  defines how the program connects to the SAP gateway.  In the servers section, the NAME field identifies this app.config entry to our  program. The SAP .Net Connector 3.0 will use the values in the GWHOST, GWSERV, and PROGRAM_ID fields to register our program on the SAP Application Gateway. The PROGRAM_ID specified here must match the Registered Server Program ID specified in the RFC destination.</p>
<p><a href="http://www.dataxstream.com/wp-content/uploads/RFC_Server03.png" rel="shadowbox[sbpost-8763];player=img;"><img class="alignnone size-full wp-image-8799" src="http://www.dataxstream.com/wp-content/uploads/RFC_Server03.png" alt="" width="604" height="381" /></a></p>
<h2>The SAP RFC Function Interface</h2>
<p>SAP transaction SE37 can be used to determine the parameters for the STFC_CONNECTION function. This describes what parameters will be passed to our function, and what results are expected.</p>
<p>In this example, we expect to receive parameter REQUTEXT, which will be returned to the caller in ECHOTEXT. We also return a text string to the caller in field RESPTEXT.</p>
<p><a href="http://www.dataxstream.com/wp-content/uploads/RFC_Server041.png" rel="shadowbox[sbpost-8763];player=img;"><img class="alignnone size-full wp-image-8812" src="http://www.dataxstream.com/wp-content/uploads/RFC_Server041.png" alt="" width="542" height="181" /></a></p>
<p>SAP transactoin SM59 is used to configure the SAP RFC Destination. In this example, the name of the RFC Destination (NIMBUS) is the name of the development computer that is running the RFC Server. The registered program ID (NCO3_RFC_SERVER) matches our app.config file.</p>
<p><a href="http://www.dataxstream.com/wp-content/uploads/RFC_Server05.png" rel="shadowbox[sbpost-8763];player=img;"><img class="alignnone size-full wp-image-8769" src="http://www.dataxstream.com/wp-content/uploads/RFC_Server05.png" alt="" width="506" height="396" /></a></p>
<h2>The Code</h2>
<p>As an Nco developer, one of my favorite changes brought about by Nco 3.0 is how RFC server functionality is implemented. Instead of overriding generated stub method, we need to implement one or more class methods that will process the incoming RFC calls. For this there are several possibilities:</p>
<ul>
<li>The first option is to create one static method corresponding to each SAP function module to be implemented.  Assigning a SAP function module to a method is done by decorating the method with the <span style="font-family: Consolas, Courier, monospace"><span style="color: #8080ff">RfcServerFunction</span></span> attribute.</li>
<li>The second method is to create one static method for that handles all SAP function modules. This is called the “default” method. Use the same <span style="font-family: Consolas, Courier, monospace"><span style="color: #8080ff">RfcServerFunction</span></span> method decoration as the previous option, but denote that the method is the defualt RFC handler. The Name attribute is irrelevant in this case.  These two methods for RFC Function handling can be combined in the same project.</li>
</ul>
<p>It is also possible to use either of the two previous options with instance methods instead of static methods.  For the purposes of this example, we will use a static method to implement our RFC Server.</p>
<p>We will create a class that exposes a method that can be called via SAP RFC.  In our example that class is named DxsRfcServer and it contains one method that will supply the STFC_CONNECTION functionality.  Now perform the following steps to implement class.</p>
<ol>
<li>Provide the RFC callable code. This is done in our DxsRfcServer class, where we have a method defined. The <span style="font-family: Consolas, Courier, monospace"><span style="color: #8080ff">RfcServerFunction</span></span> code attribute on line 59 identifies this function to the SAP .Net Connector as the method that implements SAP function STFC_CONNECTION. On line 60 is where we are passed two parameters that contain all of the information we need to execute our function. The <span style="font-family: Consolas, Courier, monospace">IRfcFunction</span> interface provides access to parameter values. In this case we use the <span style="font-family: Consolas, Courier, monospace">.GetString()</span> method on line 69 to extract the value of the REQUTEXT parameter. We also can return values to the RFC caller using the IRfcFunction interface by using the <span style="font-family: Consolas, Courier, monospace">.SetValue()</span> method as seen in lines 69-70.<br />
<a href="http://www.dataxstream.com/wp-content/uploads/RFC_Server06.png" rel="shadowbox[sbpost-8763];player=img;"><img class="alignnone size-full wp-image-8771" src="http://www.dataxstream.com/wp-content/uploads/RFC_Server06.png" alt="" width="600" height="207" /></a></li>
<li> Create an array of types, with just one element that refers to our DxsRfcServer class.<br />
<a href="http://www.dataxstream.com/wp-content/uploads/RFC_Server07.png" rel="shadowbox[sbpost-8763];player=img;"><img class="alignnone size-full wp-image-8778" src="http://www.dataxstream.com/wp-content/uploads/RFC_Server07.png" alt="" width="514" height="18" /></a></li>
<li>Register the array with an <span style="font-family: Consolas, Courier, monospace">RfcServer</span> object.  Notice that on line 22, the first parameter to the <span style="font-family: Consolas, Courier, monospace">.GetServer()</span> method is the NAME field of the servers section in app.config.<br />
<a href="http://www.dataxstream.com/wp-content/uploads/RFC_Server08.png" rel="shadowbox[sbpost-8763];player=img;"><img class="alignnone size-full wp-image-8779" src="http://www.dataxstream.com/wp-content/uploads/RFC_Server08.png" alt="" width="483" height="67" /></a></li>
<li>Start the RFC server.<br />
<a href="http://www.dataxstream.com/wp-content/uploads/RFC_Server09.png" rel="shadowbox[sbpost-8763];player=img;"><img class="alignnone size-full wp-image-8784" src="http://www.dataxstream.com/wp-content/uploads/RFC_Server09.png" alt="" width="222" height="16" /></a></li>
<li>At this time, the SAP system has visibility of our program running on the application gateway. (SAP transaction SMGW Goto menu-&gt;Logged On Clients)<br />
<a href="http://www.dataxstream.com/wp-content/uploads/RFC_Server10.png" rel="shadowbox[sbpost-8763];player=img;"><img class="alignnone size-full wp-image-8785" src="http://www.dataxstream.com/wp-content/uploads/RFC_Server10.png" alt="" width="653" height="82" /></a></li>
<li>Use the test function screen in transaction SE37 to test the new function. The RFC Target System is set to the name of the RFC destination created in the previous step (in this case it is our development system name).<br />
<a href="http://www.dataxstream.com/wp-content/uploads/RFC_Server11.png" rel="shadowbox[sbpost-8763];player=img;"><img class="alignnone size-full wp-image-8786" src="http://www.dataxstream.com/wp-content/uploads/RFC_Server11.png" alt="" width="370" height="205" /></a><br />
Here are the results:<br />
<a href="http://www.dataxstream.com/wp-content/uploads/RFC_Server12.png" rel="shadowbox[sbpost-8763];player=img;"><img class="alignnone size-full wp-image-8787" src="http://www.dataxstream.com/wp-content/uploads/RFC_Server12.png" alt="" width="489" height="307" /></a></li>
<li>The command console will also display some useful information:<br />
<a href="http://www.dataxstream.com/wp-content/uploads/RFC_Server13.png" rel="shadowbox[sbpost-8763];player=img;"><img class="alignnone size-full wp-image-8788" src="http://www.dataxstream.com/wp-content/uploads/RFC_Server13.png" alt="" width="536" height="160" /></a></li>
</ol>
<p>The rest of the code is regular Windows Console programming and is very straight forward.</p>
<h2>Additional Information</h2>
<p>Follow these links for more information about NCo 3.0 programming:</p>
<ul>
<li><a title="SAP NCo 3.0 – Best Practice Guide for Upgrade from .NET Connector 2.0" href="http://www.dataxstream.com/sap_webinars/sap-nco-3-0-best-practice-guide-for-upgrade-from-net-connector-2-0/">Webinar: SAP NCo 3.0 – Best Practice Guide for Upgrade from .NET Connector 2.0</a></li>
<li><a title="SAP NCo 3.0 RFC Server Sample Code" href="http://www.dataxstream.com/sap-nco-3-0-rfc-server-sample-code/">Source Code: RFC Server with NCo 3.0</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.dataxstream.com/2011/08/nco-3-rfc-server-step-by-step/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Build an RFC Client with NCo 3.0 &#8211; A Step-By-Step Guide</title>
		<link>http://www.dataxstream.com/2011/08/nco-3-rfc-client-step-by-step/</link>
		<comments>http://www.dataxstream.com/2011/08/nco-3-rfc-client-step-by-step/#comments</comments>
		<pubDate>Tue, 16 Aug 2011 14:15:32 +0000</pubDate>
		<dc:creator>Craig Stasila</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[SAP ABAP Blog]]></category>
		<category><![CDATA[SAP Interface Blog]]></category>
		<category><![CDATA[SAP Technical]]></category>
		<category><![CDATA[.Net Connector]]></category>
		<category><![CDATA[Craig Stasila]]></category>
		<category><![CDATA[DataXstream]]></category>
		<category><![CDATA[NCo]]></category>
		<category><![CDATA[NCo 3.0]]></category>
		<category><![CDATA[SAP .Net Connector]]></category>

		<guid isPermaLink="false">http://www.dataxstream.com/?p=8576</guid>
		<description><![CDATA[The SAP .Net Connector 3.0 (NCo 3.0) offers many improvements over the 2.0 version of that product. Unfortunately, SAP no longer offers example .NET code.  This blog attempts to fill that gap by describing how to build a simple RFC Client using SAP .Net Connector (NCo) 3.0.  Click here to request a .zip file containing a [...]]]></description>
			<content:encoded><![CDATA[<p>The SAP .Net Connector 3.0 (NCo 3.0) offers many improvements over the 2.0 version of that product. Unfortunately, SAP no longer offers example .NET code.  This blog attempts to fill that gap by describing how to build a simple RFC Client using SAP .Net Connector (NCo) 3.0.  <a href="http://www.dataxstream.com/sap-nco-3-0-rfc-client-code/">Click here</a> to request a .zip file containing a copy of the source code.</p>
<p>The sample program displays details about companies defined by SAP. There are two BAPI calls involved, BAPI_COMPANY_GETLIST and BAPI_COMPANY_GETDETAIL.<br />
Along with the SAP .Net Connector 3.0, we are using Microsoft Visual Studio 2010 and the Microsoft .Net Framework 4.0 to build our sample.  Prior to starting, you will have to download and install <a href="http://service.sap.com/connectors" target="_blank">NCo 3.0</a> (OSS login required).<br />
<span id="more-8576"></span></p>
<h2>Setting up the Project</h2>
<p>Using Visual Studio 2010, create a new Windows Form project. In the project properties, be sure to set the Target Framework to .Net Framework 4.0.<a href="http://www.dataxstream.com/wp-content/uploads/RFC_Client01.png" rel="shadowbox[sbpost-8576];player=img;"><img class="alignnone size-full wp-image-8581" src="http://www.dataxstream.com/wp-content/uploads/RFC_Client01.png" alt="" width="564" height="332" /></a></p>
<p>Add references to the SAP .Net Connector 3.0. There are two DLLs, sapnco.dll and sapnco_utils.dll.</p>
<p><a href="http://www.dataxstream.com/wp-content/uploads/RFC_Client02.png" rel="shadowbox[sbpost-8576];player=img;"><img class="alignnone size-full wp-image-8582" src="http://www.dataxstream.com/wp-content/uploads/RFC_Client02.png" alt="" width="251" height="154" /></a></p>
<h2>Design the Form</h2>
<p>Add two controls to the form. The first is a List Box, which will contain the list of available SAP companies. The second control to add is a Property Grid control, which is used to display the details of a particular SAP company when the user selects one from the List Box.</p>
<p><a href="http://www.dataxstream.com/wp-content/uploads/RFC_Client03.png" rel="shadowbox[sbpost-8576];player=img;"><img class="alignnone size-full wp-image-8583" src="http://www.dataxstream.com/wp-content/uploads/RFC_Client03.png" alt="" width="575" height="454" /></a></p>
<h2>Using App.Config to define the SAP Connections</h2>
<p>There are several methods you can use in your solutions to define a particular SAP host. For this example, we are using an app.config file to define our SAP host.<br />
The SAP .Net Connector 3.0 includes sample app.config files. For the RFC client, be sure there is a sectionGroup definition for <span style="font-family: Consolas, Courier, monospace"><span style="color: #0000ff">&lt;</span><span style="color: #800000">ClientSettings</span><span style="color: #0000ff">&gt;</span></span>.<br />
The SAP host is defined by the destinations section. Within the destination, the Name field identifies this app.config entry to our program code. Specify the appropriate user name, password, SAP host name, client and system number in the destination section.</p>
<p><a href="http://www.dataxstream.com/wp-content/uploads/RFC_Client04.png" rel="shadowbox[sbpost-8576];player=img;"><img class="alignnone size-full wp-image-8584" src="http://www.dataxstream.com/wp-content/uploads/RFC_Client04.png" alt="" width="688" height="347" /></a></p>
<h2>The BAPIs</h2>
<p>Use the SAP transaction SE37 to determine the parameters for functions BAPI_COMPANY_GETLIST and BAPI_COMPANY_GETDETAIL. This will tell us what parameters need to be passed in and where to find the results that are returned to our code.</p>
<h2>The Code</h2>
<p>During the form load event, we want to populate our List Box with the defined companies from SAP.</p>
<ol>
<li>Acquire a valid RfcDestination to use. Use method <span style="font-family: Consolas, Courier, monospace">RfcDestinationManager.GetDestination()</span> to do this. <span style="font-family: Consolas, Courier, monospace">GetDestination()</span> requires a parameter to determine which SAP host to refer to. Pass in the Name of the SAP host you previously defined in the app.config file. (Line 60)</li>
<li>Now that we have a valid <span style="font-family: Consolas, Courier, monospace">RfcDestination</span> object, we need access to the SAP Repository. The repository contains information about the BAPI calls we are going to make. The <span style="font-family: Consolas, Courier, monospace">RfcRepository</span> is an attribute of an <span style="font-family: Consolas, Courier, monospace">RfcDestination</span> object. (Line 62)</li>
<li>Using the <span style="font-family: Consolas, Courier, monospace">RfcRepository</span> object, acquire a reference to the SAP BAPI by calling method <span style="font-family: Consolas, Courier, monospace">RfcRepository.CreateFunction()</span> method. Pass in the name of the desired function as a string parameter to <span style="font-family: Consolas, Courier, monospace">CreateFunction()</span>. This method returns an object we can use to setup parameters, invoke the function, and retrieve results.</li>
<li>Now we can make the RFC calls into SAP. Using the <span style="font-family: Consolas, Courier, monospace">IRfcFunction</span> object returned by <span style="font-family: Consolas, Courier, monospace">CreateFunction()</span>, call the <span style="font-family: Consolas, Courier, monospace">Invoke()</span> method, passing in our <span style="font-family: Consolas, Courier, monospace">RfcDestination</span> object as parameter. This will make the RFC call into SAP, and provides the results via our <span style="font-family: Consolas, Courier, monospace">IRfcFunction</span> object. (Line 68)</li>
<li>SAP function BAPI_GET_COMPANYLIST returns a table of company records. We use an instance of an <span style="font-family: Consolas, Courier, monospace">IRfcTable</span> object that we retrieve by calling the <span style="font-family: Consolas, Courier, monospace">GetTable()</span> method on the <span style="font-family: Consolas, Courier, monospace">IRfcFunction</span> object. To get a desired table, pass in the table name to the <span style="font-family: Consolas, Courier, monospace">GetTable()</span> method. (Line 70)</li>
<li>We now have an instance of an <span style="font-family: Consolas, Courier, monospace">IRfcTable</span> object that contains company information through which we can iterate. It is possible to iterate through the data by setting the <span style="font-family: Consolas, Courier, monospace">CurrentIndex</span> property on the returned table. For a particular row in the table, it is possible to access values using the <span style="font-family: Consolas, Courier, monospace">GetString()</span> method. (Lines 75-79)</li>
<li>For each company, get the CompanyNumber, and use that as a parameter to SAP function BAPI_COMPANY_GETDETAIL. BAPI_COMPANY_GETDETAIL returns detailed information about that particular SAP company. The techniques are the same as before, with the additional step of using the <span style="font-family: Consolas, Courier, monospace">SetValue()</span> method on the <span style="font-family: Consolas, Courier, monospace">IRfcFunction</span> object to pass in the company number as a parameter. (Lines 78-84)</li>
<li>BAPI_COMPANY_GETDETAIL returns data as an instance of the <span style="font-family: Consolas, Courier, monospace">IRfcStructure</span> interface. Access individual field data of the company record, using the <span style="font-family: Consolas, Courier, monospace">GetString()</span> method of the <span style="font-family: Consolas, Courier, monospace">IRfcStructure</span> object instance. (Lines 88-99)</li>
<li>Extract the company details as desired. Add them to some object you create and then add that object to the List Box control. (Line 101)</li>
</ol>
<p><a href="http://www.dataxstream.com/wp-content/uploads/RFC_Client05.png" rel="shadowbox[sbpost-8576];player=img;"><img class="alignnone size-full wp-image-8585" src="http://www.dataxstream.com/wp-content/uploads/RFC_Client05.png" alt="" width="665" height="547" /></a></p>
<p>The rest of the code is regular Windows Forms programming. Your code will need to wire up the List Box changed events so that the Property Grid will display the details of the selected company.</p>
<h2>Additional Information</h2>
<p>Follow these links for more information about NCo 3.0 programming:</p>
<ul>
<li>Webinar: <a href="http://www.dataxstream.com/sap_webinars/sap-nco-3-0-best-practice-guide-for-upgrade-from-net-connector-2-0/">SAP NCo 3.0 – Best Practice Guide for Upgrade from .NET Connector 2.0</a></li>
<li>Source Code: <a href="http://www.dataxstream.com/sap-nco-3-0-rfc-client-code/">RFC Client with NCo 3.0</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.dataxstream.com/2011/08/nco-3-rfc-client-step-by-step/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>SAP NCo 3.0 &#8211; Best Practice Guide for Upgrade from .NET Connector 2.0</title>
		<link>http://www.dataxstream.com/sap_webinars/sap-nco-3-0-best-practice-guide-for-upgrade-from-net-connector-2-0/</link>
		<comments>http://www.dataxstream.com/sap_webinars/sap-nco-3-0-best-practice-guide-for-upgrade-from-net-connector-2-0/#comments</comments>
		<pubDate>Mon, 15 Aug 2011 17:05:34 +0000</pubDate>
		<dc:creator>Dataxstream</dc:creator>
				<category><![CDATA[.Net Connector]]></category>
		<category><![CDATA[Craig Stasila]]></category>
		<category><![CDATA[Integration]]></category>
		<category><![CDATA[NCo 3.0]]></category>
		<category><![CDATA[SAP .Net Connector]]></category>
		<category><![CDATA[upgrades]]></category>

		<guid isPermaLink="false">http://www.dataxstream.com/?page_id=8675</guid>
		<description><![CDATA[Duration: 1 hour Speaker:  Craig Stasila, Principal, DataXstream This one hour webinar will supply you with knowledge of features specific to the new upgrade, as well as an overview of the advantages that come with investing in NCo 3.0. What Will Be Highlighted: Changes and new features brought upon by the NCo 3.0 update Demonstrations [...]]]></description>
			<content:encoded><![CDATA[<h3><a href="http://www.dataxstream.com/wp-content/uploads/Tin-Can-Banner-No-Date3.jpg" rel="shadowbox[sbpost-8675];player=img;"><img class="alignnone size-full wp-image-8568" title="Tin Can Banner No Date" src="http://www.dataxstream.com/wp-content/uploads/Tin-Can-Banner-No-Date3.jpg" alt="" width="600" height="235" /></a></h3>
<h3>Duration: 1 hour</h3>
<h3>Speaker:  <a href="http://www.dataxstream.com/author/cstasila/">Craig Stasila</a>, Principal, DataXstream</h3>
<h3><span class="Apple-style-span" style="font-size: 13px; font-weight: normal;">This one hour webinar will supply you with knowledge of features specific to the new upgrade, as well as an overview of the advantages that come with investing in NCo 3.0.</span></h3>
<h3>What Will Be Highlighted:</h3>
<ul>
<li>Changes and new features brought upon by the NCo 3.0 update</li>
<li>Demonstrations of best-practices for implementing new and existing NCo code</li>
<li>Live demonstration of inbound and outbound function calls between a .NET solution and SAP ECC</li>
</ul>
<div class="featureblock">
<h3><a title="foot_note_1" name="foot_note_1"></a>Available on Demand</h3>
<p><em>Please complete the required form to view the webinar</em></p>

		<div id="usermessage5a" class="cf_info "></div>
		<form enctype="multipart/form-data" action="/tag/sap-net-connector/feed/#usermessage5a" method="post" class="cform nco-3-0-webinar " id="cforms5form">
		<ol class="cf-ol">
			<li id="li-5-1" class=""><label for="cf5_field_1"><span>First Name</span></label><input type="text" name="cf5_field_1" id="cf5_field_1" class="single fldrequired" value=""/><span class="reqtxt">(required)</span></li>
			<li id="li-5-2" class=""><label for="cf5_field_2"><span>Last Name</span></label><input type="text" name="cf5_field_2" id="cf5_field_2" class="single fldrequired" value=""/><span class="reqtxt">(required)</span></li>
			<li id="li-5-3" class=""><label for="cf5_field_3"><span>Company</span></label><input type="text" name="cf5_field_3" id="cf5_field_3" class="single fldrequired" value=""/><span class="reqtxt">(required)</span></li>
			<li id="li-5-4" class=""><label for="cf5_field_4"><span>Job Title</span></label><input type="text" name="cf5_field_4" id="cf5_field_4" class="single fldrequired" value=""/><span class="reqtxt">(required)</span></li>
			<li id="li-5-5" class=""><label for="cf5_field_5"><span>Email</span></label><input type="text" name="cf5_field_5" id="cf5_field_5" class="single fldemail fldrequired" value=""/><span class="emailreqtxt">(valid email required)</span></li>
			<li id="li-5-6" class=""><label for="cf5_field_6"><span>Phone</span></label><input type="text" name="cf5_field_6" id="cf5_field_6" class="single fldrequired" value=""/><span class="reqtxt">(required)</span></li>
			<li id="li-5-7" class=""><label for="cf5_field_7"><span>Additional Information</span></label><textarea cols="30" rows="8" name="cf5_field_7" id="cf5_field_7" class="area"></textarea></li>
		</ol>
		<fieldset class="cf_hidden">
			<legend>&nbsp;</legend>
			<input type="hidden" name="cf_working5" id="cf_working5" value="One%20moment%20please..."/>
			<input type="hidden" name="cf_failure5" id="cf_failure5" value="Please%20fill%20in%20all%20the%20required%20fields."/>
			<input type="hidden" name="cf_codeerr5" id="cf_codeerr5" value="Please%20double-check%20your%20verification%20code."/>
			<input type="hidden" name="cf_customerr5" id="cf_customerr5" value="yyy"/>
			<input type="hidden" name="cf_popup5" id="cf_popup5" value="nn"/>
		</fieldset>
		<p class="cf-sb"><input type="submit" name="sendbutton5" id="sendbutton5" class="sendbutton" value="Submit" onclick="return cforms_validate('5', false)"/></p></form><p class="linklove" id="ll5"></p>		<div id="usermessage5b" class="cf_info " ></div>

</div>
]]></content:encoded>
			<wfw:commentRss>http://www.dataxstream.com/sap_webinars/sap-nco-3-0-best-practice-guide-for-upgrade-from-net-connector-2-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introducing SAP .NET Connector (NCo) 3.0</title>
		<link>http://www.dataxstream.com/2011/01/introducing-sap-net-connector-nco-3-0/</link>
		<comments>http://www.dataxstream.com/2011/01/introducing-sap-net-connector-nco-3-0/#comments</comments>
		<pubDate>Wed, 05 Jan 2011 15:33:30 +0000</pubDate>
		<dc:creator>Craig Stasila</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[SAP Interface Blog]]></category>
		<category><![CDATA[SAP Technical]]></category>
		<category><![CDATA[.Net Connector]]></category>
		<category><![CDATA[Craig Stasila]]></category>
		<category><![CDATA[DataXstream]]></category>
		<category><![CDATA[external program]]></category>
		<category><![CDATA[NCo]]></category>
		<category><![CDATA[NCo 3.0]]></category>
		<category><![CDATA[SAP .Net Connector]]></category>
		<category><![CDATA[SAP Integration]]></category>
		<category><![CDATA[SAP programming]]></category>

		<guid isPermaLink="false">http://www.dataxstream.com/?p=6680</guid>
		<description><![CDATA[This past summer, SAP announced a new version of SAP Connector for Microsoft .NET &#8212; NCo 3.0.  SAP decided to give us an early Christmas present when they officially released NCo 3.0 on December 22, 2010.  You can download NCo 3.0 at http://service.sap.com/connectors (you will need an OSS logon). Included in the downloads are documents [...]]]></description>
			<content:encoded><![CDATA[<p>This past summer, SAP announced a new version of SAP Connector for Microsoft .NET &#8212; NCo 3.0.  SAP decided to give us an early Christmas present when they officially released NCo 3.0 on December 22, 2010.  You can download NCo 3.0 at <a href="http://service.sap.com/connectors" target="_blank">http://service.sap.com/connectors</a> (you will need an OSS logon).</p>
<p>Included in the downloads are documents that discuss the notable changes from .NET Connector 2.0 and a very comprehensive help file (in .chm format).  Noticeably absent are complete samples, although SAP claims that the included tutorial will be updated.</p>
<p>Additionally, I already have my first NCo 3.0 project under way, so check back soon for more information about NCo 3.0!</p>
<p>Happy Coding!</p>
<p>[UPDATED]</p>
<h2>Additional Information</h2>
<p>Follow these links for more information about NCo 3.0 programming:</p>
<ul>
<li>Webinar: <a href="http://www.dataxstream.com/sap_webinars/sap-nco-3-0-best-practice-guide-for-upgrade-from-net-connector-2-0/">SAP NCo 3.0 – Best Practice Guide for Upgrade from .NET Connector 2.0</a></li>
<li><a title="Build an RFC Client with NCo 3.0 – A Step-By-Step Guide" href="http://www.dataxstream.com/2011/08/nco-3-rfc-client-step-by-step/">Build an RFC Client with NCo 3.0 &#8211; A Step-By-Step Guide</a></li>
<li><a title="Build an RFC Server with NCo 3.0 – A Step-By-Step Guide" href="http://www.dataxstream.com/2011/08/nco-3-rfc-server-step-by-step/">Build an RFC Server with NCo 3.0 &#8211; A Step-By-Step Guide</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.dataxstream.com/2011/01/introducing-sap-net-connector-nco-3-0/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Case Study &#8211; Integration with SAP .Net Connector</title>
		<link>http://www.dataxstream.com/success-stories/case-studies/sap-net-connector/</link>
		<comments>http://www.dataxstream.com/success-stories/case-studies/sap-net-connector/#comments</comments>
		<pubDate>Tue, 04 Jan 2011 20:21:09 +0000</pubDate>
		<dc:creator>Dataxstream</dc:creator>
				<category><![CDATA[.Net Connector]]></category>
		<category><![CDATA[Integration]]></category>
		<category><![CDATA[NCo]]></category>
		<category><![CDATA[SAP .Net Connector]]></category>

		<guid isPermaLink="false">http://www.dataxstream.com/</guid>
		<description><![CDATA[Pure Fishing, Inc. &#8211; Integration with SAP .Net Connector Pure Fishing needed a new and standardized solution to allow seamless interaction between their SAP systems and third-party warehouse management software that was more reliable and flexible then custom integration approach used in the past. View More Case Studies]]></description>
			<content:encoded><![CDATA[<p><!--StartFragment--> <!--EndFragment--></p>
<table border="0" cellspacing="20" cellpadding="0" width="100%">
<tbody>
<tr>
<td width="90" valign="top"><a href="http://www.dataxstream.com/download/22"><img class="size-medium wp-image-6654 alignleft" title="Pure Fishing Thumbnail" src="http://www.dataxstream.com/wp-content/uploads/Pure-Fishing-Thumbnail4-232x300.png" alt="" width="83" height="108" /></a></td>
<td>
<h3><strong>Pure Fishing, Inc. &#8211; Integration with SAP .Net Connector</strong></h3>
<h2><strong> </strong></h2>
<p>Pure Fishing needed a new and standardized solution to allow seamless interaction between their SAP systems and third-party warehouse management software that was more reliable and flexible then custom integration approach used in the past.</td>
</tr>
</tbody>
</table>
<p><a href="http://www.dataxstream.com/success-stories/case-studies/"><strong>View More Case Studies</strong></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.dataxstream.com/success-stories/case-studies/sap-net-connector/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Coming Soon: SAP .NET Connector (NCo) 3.0</title>
		<link>http://www.dataxstream.com/2010/07/sap-net-connector-nco-3-0-overview/</link>
		<comments>http://www.dataxstream.com/2010/07/sap-net-connector-nco-3-0-overview/#comments</comments>
		<pubDate>Wed, 21 Jul 2010 13:40:15 +0000</pubDate>
		<dc:creator>Craig Stasila</dc:creator>
				<category><![CDATA[SAP ABAP Blog]]></category>
		<category><![CDATA[SAP Basis Blog]]></category>
		<category><![CDATA[SAP Interface Blog]]></category>
		<category><![CDATA[SAP Technical]]></category>
		<category><![CDATA[.Net Connector]]></category>
		<category><![CDATA[Craig Stasila]]></category>
		<category><![CDATA[DataXstream]]></category>
		<category><![CDATA[Integration]]></category>
		<category><![CDATA[NCo]]></category>
		<category><![CDATA[SAP .Net Connector]]></category>
		<category><![CDATA[Xstream Connector]]></category>
		<category><![CDATA[XstreamConnector]]></category>

		<guid isPermaLink="false">http://www.dataxstream.com/?p=5499</guid>
		<description><![CDATA[SAP is announcing a new version of SAP Connector for Microsoft .NET 3.0 (now called &#8220;NCo 3.0&#8243;). A beta program for selected customers and partners is currently underway (Q3, 2010) with the general release of the software coming soon thereafter.  I will highlight some of the major differences between the SAP Connector for Microsoft .NET [...]]]></description>
			<content:encoded><![CDATA[<p>SAP is announcing a new version of SAP Connector for Microsoft .NET 3.0 (now called &#8220;NCo 3.0&#8243;). A beta program for selected customers and partners is currently underway (Q3, 2010) with the general release of the software coming soon thereafter.  I will highlight some of the major differences between the SAP Connector for Microsoft .NET 2.0 and NCo 3.0 (besides the obvious, and much-needed name-shortening).</p>
<blockquote><p>EDITOR&#8217;S NOTE: NCo 3.0 has now been released.  <a href="http://www.dataxstream.com/2011/01/introducing-sap-net-connector-nco-3-0/">Read more details here.</a></p></blockquote>
<p><span id="more-5499"></span></p>
<h2>NCo 3.0 Logon</h2>
<div>Security got vital improvements in NCo 3.0.  The component handling logon and authentication was redesigned to thwart the following attacks:</div>
<div>
<ul>
<li>The unauthorized reading of sensitive logon data from the .NET configuration file (e.g. app.config).</li>
<li>The potential to create a malevolent application which replaces the customized logon data with it’s own logon data to obtain backend user sessions with different authorizations.</li>
<li>The potential to create a malevolent application which gains access to an open connection that was originally intended for a different application.</li>
</ul>
</div>
<p>One of the new features implemented to combat the malevolent for RFC client attacks is the interface <span style="font-family: Courier;">IDestinationConfiguration</span>.  This interface contains method <span style="font-family: Courier;">IDestinationConfiguration.GetParameters(string destinationName)</span> which allows .NET programmers to provide their own secure method for storing and retrieving logon information, be it encrypted database, encrypted file, or even LDAP.  There is also a corresponding interface and method to secure NCo 3.0 RFC servers.</p>
<p>Additionally, there is updated functionality to support single sign-on (SSO) and X.509 certificates.</p>
<h2>Say Goodbye to Data Containers and Generated Code</h2>
<p>In SAP Connector 2.0, working with RFCs required the generation of proxy code via the SAP .NET Connector design-time tool.  This tool would convert the IMPORTING, EXPORTING, CHANGING, and TABLES parameters from the RFC you were calling/serving to .NET representations of the same.  With NCo 3.0 there is no longer any kind of generated code.  Instead of one generated proxy method for each function module, there is one single <span style="font-family: Courier;">RfcFunction</span> class, whose <span style="font-family: Courier;">Invoke()</span> method dynamically executes every given ABAP function module.  Additionally, all ABAP parameters will be represented by the class <span style="font-family: Courier;">RfcStructure</span> instead of a dedicated generated class for every structure; All tables will be represented by class <span style="font-family: Courier;">RfcTable</span>.  So, instead of hard-coding all of the data and variable bindings statically at design time, NCo 3.0 now handles everything dynamically at runtime.</p>
<p>NCo 3.0 uses SAP&#8217;s data dictionary to determine the function interface for the called RFCs.  While this data is cached locally for performance reasons, NCo 3.0 is robust enough to detect changes in RFC interface signatures so your code will still execute if you&#8217;ve added, deleted, or changed RFC parameters.  If there arises a situation where the dynamic lookup of RFC interface signature is not wanted, there is also an option to hard code the RFC parameter metadata.</p>
<p>The biggest benefit of NCo 3.0&#8242;s new dynamic function handling is that NCo 3.0 no longer has a design-time component.  This releases the Visual Studio version restriction that .NET 2.0 had.  Let me rephrase that, <strong>NCo 3.0 will work with any version of Visual Studio you like!</strong> The only requirement is that at runtime, a .NET Framework version is installed that is compatible with the NCo 3.0 libraries.</p>
<h2>Anxiously Waiting</h2>
<p>NCo 3.0 figures to be a much-needed update to a vital SAP integration technology.  I, for one, cannot wait for the new functionality to be generally released.  Once NCo 3.0 is released we&#8217;ll be posting blogs highlighting the new features.  We&#8217;ll also include helpful information regarding a .NET Connector 2.0 to NCo 3.0 upgrade.  In the meantime, if you have any leave any questions or comments you have regarding NCo 3.0 below.  You may also email me directly at <span class="mh-email">csta<a href='http://www.google.com/recaptcha/mailhide/d?k=01NvHbOaIcE_hinzIpcpzZQQ==&amp;c=2sqVLQgd7lYWASsTIrUumIH5gCbE09il9SNcQyxGWDs=' onclick="window.open('http://www.google.com/recaptcha/mailhide/d?k=01NvHbOaIcE_hinzIpcpzZQQ==&amp;c=2sqVLQgd7lYWASsTIrUumIH5gCbE09il9SNcQyxGWDs=', '', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=300'); return false;" title="Reveal this e-mail address">...</a>@dataxstream.com</span> if you&#8217;d like to set up a detailed conversation.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dataxstream.com/2010/07/sap-net-connector-nco-3-0-overview/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Build an SAP RFC Server using the SAP .Net Connector</title>
		<link>http://www.dataxstream.com/2010/03/build-an-sap-rfc-server-using-the-sap-net-connector/</link>
		<comments>http://www.dataxstream.com/2010/03/build-an-sap-rfc-server-using-the-sap-net-connector/#comments</comments>
		<pubDate>Tue, 09 Mar 2010 13:30:58 +0000</pubDate>
		<dc:creator>Terry DeBruicker</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[SAP Interface Blog]]></category>
		<category><![CDATA[SAP Technical]]></category>
		<category><![CDATA[.Net Connector]]></category>
		<category><![CDATA[ABAP]]></category>
		<category><![CDATA[DataXstream]]></category>
		<category><![CDATA[Integration]]></category>
		<category><![CDATA[SAP]]></category>
		<category><![CDATA[SAP .Net Connector]]></category>

		<guid isPermaLink="false">http://www.dataxstream.com/?p=4054</guid>
		<description><![CDATA[This blog post describes step-by-step how to use the SAP .Net Connector and Microsoft C# to create an SAP RFC Server. This allows an SAP process to call your custom C# code, which can accept parameters and return values. The SAP .Net Connector simplifies creating C# programs that can interoperate with an SAP host. The [...]]]></description>
			<content:encoded><![CDATA[<p>This blog post describes step-by-step how to use the SAP .Net Connector and Microsoft C# to create an SAP RFC Server. This allows an SAP process to call your custom C# code, which can accept parameters and return values.</p>
<p>The SAP .Net Connector simplifies creating C# programs that can interoperate with an SAP host. The SAP .Net Connector is available from the <a href="http://service.sap.com/connectors" target="_blank">SAP Service Marketplace</a>. You must have access to the SAP Service Marketplace to be able to download the SAP .Net Connector. The SAP .Net Connector must be installed on your development machine before we begin.</p>
<p>RFC is a Remote Function Call. In this case, the SAP process is a ‘client’ that is making an RFC call to our custom ‘server’ code. Our code uses the SAP .Net Connector to register on an SAP Application Gateway.</p>
<p>The TLA system we have been creating exists solely to demonstrate certain programming techniques involving the SAP .Net Connector and C#.  We will cover three separate parts of the solution: defining the function to SAP, creating a proxy object used to access SAP, and creating our C# code to perform the RFC function.</p>
<h2><span id="more-4054"></span>Defining the Function in SAP</h2>
<p>Before we build our RFC server, we will define our RFC function in the SAP system. There are two parts we will need to create:  the Function Signature, and the RFC Destination.</p>
<h3>Defining the RFC Function Signature</h3>
<p>Open the SAP SE37 Function Builder screen. For the Function Module field, enter <strong>Z_RFC_TLA_HELLO_WORLD</strong> and click Create. For the Function group, press the browse button to the right of the field, then select an appropriate function Group. Enter a short text description and click Save to save the function signature.</p>
<p><a href="http://www.dataxstream.com/wp-content/uploads/2010/02/Image0013.jpg" rel="shadowbox[sbpost-4054];player=img;"><img style="border-width: 0px;" src="http://www.dataxstream.com/wp-content/uploads/2010/02/Image0013_thumb.jpg" border="0" alt="Image-0013" width="244" height="187" /></a></p>
<p>On the Attributes tab, be sure to select the <em>Remote-enabled module</em> radio button.</p>
<p><a href="http://www.dataxstream.com/wp-content/uploads/2010/02/Image0027.jpg" rel="shadowbox[sbpost-4054];player=img;"><img style="border-width: 0px;" src="http://www.dataxstream.com/wp-content/uploads/2010/02/Image0027_thumb.jpg" border="0" alt="Image-0027" width="244" height="164" /></a></p>
<p>Now we will be asked to define the parameters that are used. SAP refers to values passed to the RFC call as Import values. Values that are returned from the RFC call are called Export values.</p>
<p>In the Function Builder screen, on the Import tab, define a Parameter named <strong>Name</strong>. Fill in the appropriate Type and Associated Type values. Be sure to check the Pass Value check box.</p>
<p><a href="http://www.dataxstream.com/wp-content/uploads/2010/02/Image0016.jpg" rel="shadowbox[sbpost-4054];player=img;"><img style="border-width: 0px;" src="http://www.dataxstream.com/wp-content/uploads/2010/02/Image0016_thumb.jpg" border="0" alt="Image-0016" width="244" height="69" /></a></p>
<p>On the Export tab, create a Parameter named Hello_World. This will end up storing the result of the RFC call. Define the field in the same way as the Name import field.</p>
<p><a href="http://www.dataxstream.com/wp-content/uploads/2010/02/Image0017.jpg" rel="shadowbox[sbpost-4054];player=img;"><img style="border-width: 0px;" src="http://www.dataxstream.com/wp-content/uploads/2010/02/Image0017_thumb.jpg" border="0" alt="Image-0017" width="244" height="75" /></a></p>
<p>Save your RFC Function. Then you need to activate your RFC function. To do that, from the SE37 screen, enter the function module name. then click the <em>Activate</em> button.</p>
<p><a href="http://www.dataxstream.com/wp-content/uploads/2010/02/Image0019.jpg" rel="shadowbox[sbpost-4054];player=img;"><img style="border-width: 0px;" src="http://www.dataxstream.com/wp-content/uploads/2010/02/Image0019_thumb.jpg" border="0" alt="Image-0019" width="244" height="186" /></a></p>
<h3>Defining the RFC Destination</h3>
<p>SAP can direct an RFC call to different destinations. We will create an RFC Destination using SAP function SM59. This RFC Destination is used by the SAP system to route an RFC call to our program, which previously registered itself on the SAP Application Gateway.</p>
<p>In the SM59 screen, click the Create button.  Enter RFC destination of <strong>TLARFCSERVER</strong>. The Connection type is <strong>T</strong> for TCP/IP. Enter a description.</p>
<p>On the Technical settings tab, select Activation Type of <em>Registered Server Program</em>.</p>
<p>For the Registered Server Program Program ID, enter <strong>TlaRfcSrv</strong>. The Program ID we use here must match the Program ID used when our server code connects to the SAP Application Gateway.</p>
<p><a href="http://www.dataxstream.com/wp-content/uploads/2010/02/Image0010.jpg" rel="shadowbox[sbpost-4054];player=img;"><img style="border-width: 0px;" src="http://www.dataxstream.com/wp-content/uploads/2010/02/Image0010_thumb.jpg" border="0" alt="Image-0010" width="346" height="387" /></a></p>
<p>If you try the Test connection button, it will fail, since we have not yet registered our program on the Application Gateway. Later, we can come back to SM59 and test this and see that our RFC destination is available.</p>
<h2>C# Code</h2>
<p>We will create an application that can be called from an SAP host. The SAP host will pass in a name, as a string. Our application will return a hello greeting back to the calling program.</p>
<p>Our solution will consist of two parts.</p>
<ol>
<li>The first part is the SAP .Net Connector Proxy project, named TlaRfcServerSapProxy. This will produce a Dynamic Link Library that encapsulates what we need to know to interoperate with the SAP host.</li>
<li>The second part is is our custom code project, named TlaRfcServer. This contains the code which will execute when called from the SAP host via RFC. Save the RFC destination.</li>
</ol>
<h3>Creating the SAP Proxy Project</h3>
<p>We will use Visual Studio 2003 to create a DLL that manages the interactions with the SAP host. The SAP .Net Connector version 2.0 works with Visual Studio 2003 or 2005. To use the .Net Connector in our preferred environment of Visual Studio 2008, we will create the proxy DLL in 2003 and add that to our 2008 project. The techniques are described in our earlier post, <a title="How to Build an SAP .Net Connector Proxy" href="http://www.dataxstream.com/2009/08/using-the-sap-net-connector-in-visual-studio-2008/" target="_blank">Using the SAP .Net Connector in Visual Studio 2008</a>.</p>
<p>In Visual Studio 2003, start a new Class Library project named TlaRfcServerSapProxy. Delete the default Class1.cs file that is created automatically.</p>
<p><a href="http://www.dataxstream.com/wp-content/uploads/2010/02/Image0020.jpg" rel="shadowbox[sbpost-4054];player=img;"><img style="border-width: 0px;" src="http://www.dataxstream.com/wp-content/uploads/2010/02/Image0020_thumb.jpg" border="0" alt="Image-0020" width="341" height="248" /></a></p>
<p>From the Solution Explorer, Right-click on References and choose Add New References. Under the .Net tab, highlight SAP.Connector.dll and SAP.Connector.RFC. Click the Select button, then OK to add the SAP .Net Connector references.</p>
<p><a href="http://www.dataxstream.com/wp-content/uploads/2010/02/Image0021.jpg" rel="shadowbox[sbpost-4054];player=img;"><img style="border-width: 0px;" src="http://www.dataxstream.com/wp-content/uploads/2010/02/Image0021_thumb.jpg" border="0" alt="Image-0021" width="352" height="246" /></a></p>
<p>Now add the SAP Connector Proxy to our project. Right click on the project and choose Add / Add New Item. Under the templates, highlight SAP Connector Proxy. In the Name field, give our proxy the name TlaRfcServerSapProxy.sapwsdl. The name we use here will become the object type name for our SAP Server Proxy object we use when we build our RFC server code.</p>
<p><a href="http://www.dataxstream.com/wp-content/uploads/2010/02/Image0005.jpg" rel="shadowbox[sbpost-4054];player=img;"><img style="border-width: 0px;" src="http://www.dataxstream.com/wp-content/uploads/2010/02/Image0005_thumb.jpg" border="0" alt="Image-0005" width="353" height="280" /></a></p>
<p>The TlaRfcSerfverSapProxy.sapwsdl file will be displayed in Design mode. Right click on the Design surface and choose properties. This displays properties of our SAP Connector Proxy. Change the Proxy Type to Server.</p>
<p><a href="http://www.dataxstream.com/wp-content/uploads/2010/02/Image0022.jpg" rel="shadowbox[sbpost-4054];player=img;"><img style="border-width: 0px;" src="http://www.dataxstream.com/wp-content/uploads/2010/02/Image0022_thumb.jpg" border="0" alt="Image-0022" width="359" height="127" /></a></p>
<p>Now we need to add in a reference to our SAP host so that we can pull in the signature and object model for our RFC function. Open the Server Explorer windows and expand SAP / Application Servers. Right-click on Application Servers and choose add New Server. Enter in the connection information for your SAP host. Click OK.</p>
<p>Expand the newly added SAP Server and right-click on Functions. Choose Add New Function Filter. In the Name Filter field, enter *HELLO* . The * is used as a wild card. Click OK to display our Z_TLA_RFC_HELLO_WORLD function in the Server Explorer.</p>
<p><a href="http://www.dataxstream.com/wp-content/uploads/2010/02/Image0007.jpg" rel="shadowbox[sbpost-4054];player=img;"><img style="border-width: 0px;" src="http://www.dataxstream.com/wp-content/uploads/2010/02/Image0007_thumb.jpg" border="0" alt="Image-0007" width="351" height="150" /></a></p>
<p>Highlight the Z_TLA_RFC_HELLO_WORLD function in the Server Explorer, and drag it onto the TlaRfcServerSapProxy.sapwsdl design surface. This will add the necessary function signatures and object type definitions to the project.</p>
<p><a href="http://www.dataxstream.com/wp-content/uploads/2010/02/Image0028.jpg" rel="shadowbox[sbpost-4054];player=img;"><img style="border-width: 0px;" src="http://www.dataxstream.com/wp-content/uploads/2010/02/Image0028_thumb.jpg" border="0" alt="Image-0028" width="350" height="121" /></a></p>
<p>Now attempt to build the project. It will fail, as we have not yet created the code to implement our remote function. But, when we ran the build, the SAP Connector generated an implementation stub for our server method. A new class was automatically added to our project, named TlaRfcServerSapProxyImpl.cs.</p>
<p>However, we desire to implement our RFC server using Visual Studio 2008.</p>
<p>So, we will modify this code so it will build, and later we will override the implementation from our Visual Studio 2008 project.</p>
<p>If you double-click on the build error, it will take you to the offending line of code. All we need to do is set the result of Hello_World to some value.  To prevent confusion with our Visual Studio 2008 code, we will just return foo.</p>
<p><a href="http://www.dataxstream.com/wp-content/uploads/2010/02/Image0029.jpg" rel="shadowbox[sbpost-4054];player=img;"><img style="border-width: 0px;" src="http://www.dataxstream.com/wp-content/uploads/2010/02/Image0029_thumb.jpg" border="0" alt="Image-0029" width="356" height="73" /></a></p>
<p>Now build the TlaRfcSapServerProxy project and it will create TlaRfcServerSapProxy.dll, which we will use in our Visual Studio 2008 project.</p>
<h3>Creating the RFC Server Project</h3>
<p>Using Visual Studio 2008, create a C# console project named TlaRfcServer. In the Solution Explorer, right-click on References and choose Add New Reference. Using the Browse tab, select both SAP.Connector.dll and Sap.Connector.Rfc.dll, typically found in C:\Program Files\SAP\SAP .Net Connector 2.0.</p>
<p>Add a reference to the TlaRfcServerSapProxy.dll created earlier, also using the Browse tab. Add a reference to System.Web.Services using the .Net tab.</p>
<p><a href="http://www.dataxstream.com/wp-content/uploads/2010/02/Image0024.jpg" rel="shadowbox[sbpost-4054];player=img;"><img style="border-width: 0px;" src="http://www.dataxstream.com/wp-content/uploads/2010/02/Image0024_thumb.jpg" border="0" alt="Image-0024" width="352" height="375" /></a></p>
<p>In our C# code, we need to provide the code to implement our RFC function, which we do by inheriting from TlaRfcServerSapProxyImpl and overriding the Hello World function.</p>
<p><a href="http://www.dataxstream.com/wp-content/uploads/2010/02/Image0030.jpg" rel="shadowbox[sbpost-4054];player=img;"><img style="border-width: 0px;" src="http://www.dataxstream.com/wp-content/uploads/2010/02/Image0030_thumb.jpg" border="0" alt="Image-0030" width="357" height="141" /></a></p>
<p>On Line 3, with have our ‘using’ directive to include our custom proxy.</p>
<p>On line 8, we are creating a new class named SAPProxy, which is derived from our TlaRfcServerSapProxyImpl class that was created in our Visual Studio 2003 class.</p>
<p>On line 12 is the override of the Z_Tla_Rfc_Hello_World call. We provide our functionality and place the result in the Hello_World variable.</p>
<p>That concludes our class that will implement the RFC functionality.</p>
<p>Now we will finish off our console program so that we can establish our code on the SAP Application Gateway and execute it.</p>
<p>To do this,we will pass in command line arguments to our Main routine. These arguments are passed to the SAPProxy constructor, which uses them to connect to the correct SAP Application Gateway.</p>
<p>Each of our SAP Proxy objects are hosted by an SAPServerHost object, which is part of the SAP .Net Connector. The SAPServerHost object governs the connection to the SAP host.</p>
<p>Once we create the SAPProxy object and attach it to an SAPServerHost, we can start the host and that will cause our program to register and be available on the SAP Application Gateway.</p>
<p>Our program will continue to be available on the SAP Application Gateway as long as we have it running (until we press the enter key, in our example).</p>
<p><a href="http://www.dataxstream.com/wp-content/uploads/2010/02/Image0031.jpg" rel="shadowbox[sbpost-4054];player=img;"><img style="border-width: 0px;" src="http://www.dataxstream.com/wp-content/uploads/2010/02/Image0031_thumb.jpg" border="0" alt="Image-0031" width="369" height="212" /></a></p>
<p>On lines 22-25, we instantiate our proxy and SAP host. Notice how we pass in the command line arguments to the SAPProxy constructor (line 25).</p>
<p>We start the proxy on line 29. After we have done that, we can go back to the SAP SM59 function and test our RFC destination. If things are working, that test will success.</p>
<p>Our code will continue to be available until we press enter at line 37, after which we stop the SAP host.</p>
<h4>Command Line Arguments</h4>
<p>The command line arguments consist of three parts, and are specified in the Visual Studio environment under the Debug tab of the Project Properties display.</p>
<p>The three parts are</p>
<p>-aProgram ID</p>
<p>-XPort</p>
<p>-GHost</p>
<p>The Program ID specified here must match the Program ID we used when creating the SAP RFC Destination. In our case this is specified as –aTlaRfcSrv.</p>
<p>The Port field tells SAP what TCP/IP port to use. This is specified by –XSAPGW00. The SAPGW part specifies port 3300, we add whatever the 00 is to get the actual port number. In our case we are using port number 3300, so we use –XSAPGW00. If we wanted port 3302, we would have used –XSAPGW02.</p>
<p>The Host field is the DNS name or IP address of the SAP server.</p>
<p>So, your parameters will be different but they will look something like –aTlaRfcSrv –XSAPGW00 –Ghostname</p>
<p><a href="http://www.dataxstream.com/wp-content/uploads/2010/02/Image0032.jpg" rel="shadowbox[sbpost-4054];player=img;"><img style="border-width: 0px;" src="http://www.dataxstream.com/wp-content/uploads/2010/02/Image0032_thumb.jpg" border="0" alt="Image-0032" width="359" height="214" /></a></p>
<p>Now build and run TlaRfcServer. A console window will appear.</p>
<p>Go back to SAP and bring up the SM59 screen. Expand the TCP/IP connections and find TLARFCSERVER. Double click that to display the definition. When you click the Test Connection button, you should see something like :</p>
<p><a href="http://www.dataxstream.com/wp-content/uploads/2010/02/Image0034.jpg" rel="shadowbox[sbpost-4054];player=img;"><img style="border-width: 0px;" src="http://www.dataxstream.com/wp-content/uploads/2010/02/Image0034_thumb.jpg" border="0" alt="Image-0034" width="359" height="316" /></a></p>
<p>which indicates a successful test of the RFC destination.</p>
<p>Now we need to test our actual RFC function. Bring up the SAP SE37 screen. In the Function Module name, enter Z_TLA_RFC_HELLO_WORLD, which matches the name of the function signature we created earlier.</p>
<p>Press the F8 key to test the function. The Test Function Module screen is displayed.</p>
<p>For the RFC Target sys, we use the RFC Function destination we created earlier, TLARFCSERVER.</p>
<p>For the name field, type WORLD. Press F8 to execute the RFC call.</p>
<p><a href="http://www.dataxstream.com/wp-content/uploads/2010/02/Image0035.jpg" rel="shadowbox[sbpost-4054];player=img;"><img style="border-width: 0px;" src="http://www.dataxstream.com/wp-content/uploads/2010/02/Image0035_thumb.jpg" border="0" alt="Image-0035" width="360" height="213" /></a></p>
<p>This indicates a good test of our RFC function.</p>
<h4>Troubleshooting</h4>
<p>If things don’t work, check the following:</p>
<p>Program ID in RFC Destination matches –a parameter of TlaRfcServer command line.</p>
<p>Port number (SAPGW00) on TlaRfcSever comand line is set to correct port number.</p>
<p>Any firewalls in between the SAP host and the RFC Server program need to allow traffic in both directions over that port.</p>
<h2>Summary</h2>
<p>In this blog posting we have shown how you can call custom C# code from an SAP process.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dataxstream.com/2010/03/build-an-sap-rfc-server-using-the-sap-net-connector/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Build an SAP IDOC Receiver Using the SAP .Net Connector</title>
		<link>http://www.dataxstream.com/2009/12/build-an-sap-idoc-receiver-using-the-sap-net-connector/</link>
		<comments>http://www.dataxstream.com/2009/12/build-an-sap-idoc-receiver-using-the-sap-net-connector/#comments</comments>
		<pubDate>Wed, 16 Dec 2009 05:00:16 +0000</pubDate>
		<dc:creator>Terry DeBruicker</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[SAP Interface Blog]]></category>
		<category><![CDATA[SAP Technical]]></category>
		<category><![CDATA[.Net Connector]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[DataXstream]]></category>
		<category><![CDATA[IDOC receiver]]></category>
		<category><![CDATA[Integration]]></category>
		<category><![CDATA[SAP .Net Connector]]></category>

		<guid isPermaLink="false">http://www.dataxstream.com/?p=3611</guid>
		<description><![CDATA[Using the SAP .Net Connector makes it easy to receive an IDOC from an SAP host.]]></description>
			<content:encoded><![CDATA[<h2>Overview</h2>
<p>This blog post describes how to receive an IDOC from an SAP system, using the SAP .Net Connector and Microsoft C#.</p>
<h2>Introduction</h2>
<p>The SAP .Net Connector simplifies creating C# programs that can interoperate with an SAP host. The SAP .Net Connector is available from the <a href="http://service.sap.com/connectors" target="_blank">SAP Service Marketplace</a>. You must have access to the SAP Service Marketplace to be able to download the SAP .Net Connector. The SAP .Net Connector must be installed on your development machine before we begin.</p>
<p>An IDOC is an Interface Document that is used to send or receive information to or from an SAP host.  An IDOC will consist of a header record and as many detail records as necessary. The header records follow the format of the EDI_DC40 table, and the detail records follow the format of the EDI_DD40 table. The exact format of the payload in the detail records depends on the type of IDOC being transmitted.</p>
<h2><span id="more-3611"></span>C# Code</h2>
<p>We will create an application that displays the contents of IDOCs received from an SAP host. Use Visual Studio 2008 and create a new C# console application. Name the new application IdocReceive.</p>
<h3>Add Reference to SAP .Net Connector.</h3>
<p>In the Solution Explorer,  right-click on References and choose Add New Reference. Select both SAP.Connector.dll and SAP.Connector.Rfc.dll. Typically, these files will be found in C:\Program Files\SAP\SAP .Net Connector 2.0.</p>
<p>Our program will instantiate a custom class, <strong>IdocReceiver</strong>, that encapsulates the SAP transmit and receive logic.</p>
<p>IdocReceiver inherits from the SAP .Net Connector.  IdocReceiver overrides methods from the SAP .Net Connector to manage the flow of IDOCs from the SAP host. IdocReceiver also subscribes to two events exposed by the SAP .Net Connector that perform the actual transmission.</p>
<div id="attachment_3635" class="wp-caption aligncenter" style="width: 624px"><a href="http://www.dataxstream.com/wp-content/uploads/2009/12/Image-00003.jpg" rel="shadowbox[sbpost-3611];player=img;"><img class="size-large wp-image-3635      " src="http://www.dataxstream.com/wp-content/uploads/2009/12/Image-00003-1024x427.jpg" alt="IDOC Receiver Main Method" width="614" height="256" /></a><p class="wp-caption-text">IDOC Receiver Main Method</p></div>
<p>Line 5 contains the reference to the SAP .Net Connector that we need.</p>
<p>The IdocReceiver object requires an SAPHost object that is used to configure the connection to the SAP Gateway. Line 9 instantiates the SAPHost object.</p>
<p>Line 14 calls the IdocReceiver constructor. The first parameter is the SAP Connection String, used to connect to the SAP host. There are three parts of an SAP Connection String:</p>
<p style="padding-left: 30px;"><strong>-aProgramName</strong> is the program name as it is defined on the SAP Gateway. This value must match the Program ID configured on the SAP Gateway. Use SAP command SM59 to view the settings of the SAP Gateway.</p>
<p style="padding-left: 30px;"><strong>-xSAPGWnn</strong> is the SAP Gateway number to which the IDOC receiver will register.  The SAP Gateway listens on a TCP/IP port number based on <em>nn</em> value. The actual port number is equal to 3300 plus the <em>nn</em> value. In this case <em>nn</em> is zero, so port 3300 is used.</p>
<p style="padding-left: 30px;"><strong>-gHostName</strong> is the DNS host name of the SAP server. It is also possible to specify an IP address, like -g192.168.10.1.</p>
<p>Line 16 starts the SAP host, which makes it possible to begin receiving IDOCs. At this point, our program will now be visible to the SAP host, which you can verify using the Test Connection command via SAP transaction SM59. As long as the IdocReceiver object remains in scope, it will receive IDOCs.</p>
<h3>IdocReceiver Class</h3>
<p>To receive an IDOC, the IdocReceiver class inherits from the SAP .Net Connector SAPIdocReceiver class. To control the flow of IDOCs, the IdocReceiver class overrides certain methods of the SAPIdocReceiver class. To actually receive an IDOC, the IdocReceiver subscribes to two events exposed by the SAPIdocReceiver class.</p>
<h4>Constructor</h4>
<p>Here is the code for the IdocReceiver constructor.</p>
<div id="attachment_3637" class="wp-caption aligncenter" style="width: 624px"><a href="http://www.dataxstream.com/wp-content/uploads/2009/12/Image-00013.jpg" rel="shadowbox[sbpost-3611];player=img;"><img class="size-large wp-image-3637     " src="http://www.dataxstream.com/wp-content/uploads/2009/12/Image-00013-1024x195.jpg" alt="IdocReceiver Constructor" width="614" height="117" /></a><p class="wp-caption-text">IdocReceiver Constructor</p></div>
<p>On line 25 we declare our IdocReceiver and inherit from the appropriate SAP .Net Connector object. We use the StringWriter on Line 27 to store the contents of the actual IDOC received.</p>
<p>The constructor requires two parameters, the SAP Configuration string, and an SAPServerHost object that is a container for the IdocReceiver. Line 30 is where we call the base constructor.</p>
<p>The transfer of the IDOC raises an event at two times: when the transfer begins and when the transfer ends. On lines 32-33, we wire up our IdocReceiver methods to the BeginReceive and EndReceive events exposed by the SAPIdocReceiver class. Our IdocBeginReceive will be called at the start of the IDOC transmission, and our IdocEndReceive method will be called at the end of the IDOC transmission.</p>
<h4>IDOC Flow Control</h4>
<p>IDOCs flow out of an SAP system in a transactional way, in that an SAP host will send a particular IDOC once an only once. To accomplish this, the SAP host will put together one or more IDOCs into a transaction and send that off to the IdocReceiver that has registered on the SAP Gateway. The transaction is identified by a unique Transaction ID (TID) that is supplied by the SAP host. The SAP host will communicate with our IdocReceiver using the Transaction ID to control the flow of IDOCs from SAP to our program.</p>
<p>There are four methods of the base SAPIdocReceiver class that we need to override.</p>
<div id="attachment_3638" class="wp-caption aligncenter" style="width: 624px"><a href="http://www.dataxstream.com/wp-content/uploads/2009/12/Image-00021.jpg" rel="shadowbox[sbpost-3611];player=img;"><img class="size-full wp-image-3638    " src="http://www.dataxstream.com/wp-content/uploads/2009/12/Image-00021.jpg" alt="IDOC Flow Control Methods" width="614" height="244" /></a><p class="wp-caption-text">IDOC Flow Control Methods</p></div>
<p>In each case, the SAP host expects our code to return a zero if there are no difficulties. The TIDs passed as parameters can be used to verify the state of the transmission. This demonstration code leaves out any processing you may want to use to validate the state of the transaction.</p>
<p>The SAP host will first call the CheckTransaction method. If a zero is returned, the SAP host will call ConfrimTransaction. If a zero is then returned, the SAP host will begin transmitting IDOCs. When the transmission is complete, the SAP host will call CommitTransaction.</p>
<h4>IDOC Reception</h4>
<p>We use two methods to receive the actual IDOCs. At the start of the transmission, we assign a StringWriter to the EventArg, which tells the SAP .Net Connector where we want to place the payload of the transmission. When the transmission is complete, we can read from the StringWriter to extract the payload.</p>
<div id="attachment_3639" class="wp-caption aligncenter" style="width: 624px"><a href="http://www.dataxstream.com/wp-content/uploads/2009/12/Image-00031.jpg" rel="shadowbox[sbpost-3611];player=img;"><img class="size-full wp-image-3639   " src="http://www.dataxstream.com/wp-content/uploads/2009/12/Image-00031.jpg" alt="IDOC Reception" width="614" height="252" /></a><p class="wp-caption-text">IDOC Reception</p></div>
<p>There can be one or more IDOCs transmitted at a time. Your code will need to parse the payload to determine what goes where.</p>
<p>If any of your code throws an exception, the SAP .Net Connector will detect that and alert the SAP side. The SAP side will then call your Rollback method.</p>
<h2>Summary</h2>
<p>Using the SAP .Net Connector makes it easy to receive an IDOC from an SAP host.</p>
<h3>To learn more about IDOCs download the white paper: <a href="http://www.dataxstream.com/success-stories/whitepapers/white-paper-request/" target="_self">ALE &amp; IDOC Leveraging</a></h3>
<div class="wlWriterEditableSmartContent" style="margin: 0px; float: none; padding: 0px;"><a rel="tag" href="http://technorati.com/tags/how+to"></a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.dataxstream.com/2009/12/build-an-sap-idoc-receiver-using-the-sap-net-connector/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

