<?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 Integration Experts - DataXstream &#187; SAP Interface Blog</title>
	<atom:link href="http://www.dataxstream.com/category/sap-consultants-blog/sap-technical/sap-interface-blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dataxstream.com</link>
	<description>SAP Certified Consultants</description>
	<lastBuildDate>Sat, 24 Jul 2010 11:29:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<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[Craig Stasila]]></category>
		<category><![CDATA[DataXstream]]></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>
<div id="_mcePaste"><span id="more-5499"></span></div>
<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 <a href="mailto:cstasila@dataxstream.com">cstasila@dataxstream.com</a> 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>1</slash:comments>
		</item>
		<item>
		<title>What’s in a Naming Convention? Part II</title>
		<link>http://www.dataxstream.com/2010/05/what%e2%80%99s-in-a-naming-convention-part-ii/</link>
		<comments>http://www.dataxstream.com/2010/05/what%e2%80%99s-in-a-naming-convention-part-ii/#comments</comments>
		<pubDate>Tue, 25 May 2010 13:30:29 +0000</pubDate>
		<dc:creator>Dave Morin</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[SAP Interface Blog]]></category>
		<category><![CDATA[SAP PI Blog]]></category>
		<category><![CDATA[SAP Technical]]></category>
		<category><![CDATA[DataXstream]]></category>
		<category><![CDATA[David Morin]]></category>
		<category><![CDATA[namespace]]></category>
		<category><![CDATA[SAP PI]]></category>
		<category><![CDATA[XI]]></category>
		<category><![CDATA[XI/PI]]></category>

		<guid isPermaLink="false">http://www.dataxstream.com/?p=5056</guid>
		<description><![CDATA[ I would like to say that I had a great DataXstream ESR-specific naming convention, however the SAP naming convention guide for PI 7.1 does the job perfectly.  In this post I would like to point out some things that I feel most people miss, as well as some things that I think are particularly interesting.]]></description>
			<content:encoded><![CDATA[<p>In my <a href="http://www.dataxstream.com/2010/05/what’s-in-a-naming-convention/">last post</a>, I discussed naming the naming convention that DataXstream recommends for SAP PI Integration Directory (ID) objects.  I would like to say that I had a great DataXstream ESR-specific naming convention, however the SAP naming convention guide for PI 7.1 does the job perfectly. Here is the link to the  PI 7.1 naming convention guide <a href="http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/40a66d0e-fe5e-2c10-8a85-e418b59ab36a?QuickLink=index&amp;overridelayout=true">http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/40a66d0e-fe5e-2c10-8a85-e418b59ab36a?QuickLink=index&amp;overridelayout=true</a> . I would like to point out some things that I feel most people miss, as well as some things that I think are particularly interesting.</p>
<h3><strong>Object Name Prefixes</strong></h3>
<p>I have seen a lot of places use prefixes or suffixes before objects such as or dt_ or _mt. I have never really been a fan of these prefixes and suffixes, and apparently neither is the above linked naming convention guide. The reason being is that they are unnecessary. It would be difficult to confuse a message type with a data type in a real interface scenario, even if troubleshooting an unknown broken object. Plus it makes message mapping unnecessarily confusing and long since it’s not clear whether to add the prefix, i.e. MT_one_to_MT_two. Good descriptive names are usually all that you need e.g. DEBMAS_to_Customer. The only possible exception to a no-suffix-or-prefix-policy is the service interface, as sometimes it is useful to know which direction and type a service interface is. An argument for a prefix or a suffix to describe a service interface would be to assist in understanding the flow from an SAP perspective in the event that someone who didn’t develop the interface had to come behind and troubleshoot. A argument against would be the fact that it looks silly if you use it for a web service, because you have a name that doesn’t mean anything to a third party user (note operation mappings are told to omit the prefix of direction and mode in the SAP guide).</p>
<p>One interesting thing that I noticed in my investigation of PI 7.1 EHP1 is that it appears that naming conventions on PI can be validated. If the object names do not conform to a naming convention a message will appear. Ter perform this check in the ESR go to menu <em>Tools&gt;Component Check</em>.</p>
<p><a href="http://www.dataxstream.com/wp-content/uploads/2010/05/ESB-Component-Check1.jpg" rel="shadowbox[post-5056];player=img;"><img class="alignnone size-full wp-image-5115" title="ESB-Component-Check" src="http://www.dataxstream.com/wp-content/uploads/2010/05/ESB-Component-Check1.jpg" alt="" width="551" height="434" /></a></p>
<p>Select &#8220;Governance&#8221; and &#8220;Interface Name Checks&#8221;:</p>
<p><a href="http://www.dataxstream.com/wp-content/uploads/2010/05/Interface-Name-Checks1.jpg" rel="shadowbox[post-5056];player=img;"><img class="alignnone size-full wp-image-5116" title="Interface Name Checks" src="http://www.dataxstream.com/wp-content/uploads/2010/05/Interface-Name-Checks1.jpg" alt="" width="598" height="494" /></a></p>
<p>If the service interface does not end with (In/Out)(SYNC/ASY) the interface check will show as an error (does not impact interface processing). I created 2 interfaces: one good and one bad to show this error.</p>
<p><a href="http://www.dataxstream.com/wp-content/uploads/2010/05/Results.jpg" rel="shadowbox[post-5056];player=img;"><img class="alignnone size-full wp-image-5117" title="Results" src="http://www.dataxstream.com/wp-content/uploads/2010/05/Results.jpg" alt="" width="599" height="494" /></a></p>
<p>My suspicion is that SAP will put more in place to force consistent naming standards depending on the service interface pattern in future releases.</p>
<h3><strong>Using a software component and Namespace for each “side” of an interface</strong></h3>
<p>All objects of an interface should not be grouped in a single namespace. They should to be split among the Software Component Versions of the systems being interfaced. Otherwise when you go to configure, you will not be able to see your operational mapping (OM) in the dropdown box without having to select all in the dropdown menu. A general rule of thumb is: if it’s not easy to configure, odds are you have probably done something wrong. Another reason why an object might not appear in the dropdown menu (for example for an operations mapping on an interface mapping) would be if the installed checkbox is not clicked on the SLD. When done correctly, most interfaces should be able to be configured quickly and intuitively in the integration directory (ID) without the need to select from all SWCV from dropdown menus on the integration builder.</p>
<p>Whatever naming convention you choose to use for the ESR, the important thing to remember is that adhering to the standard makes production support and troubleshooting faster and easier.
<script src="http://www.stumbleupon.com/hostedbadge.php?s=5"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.dataxstream.com/2010/05/what%e2%80%99s-in-a-naming-convention-part-ii/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What’s in a Naming Convention?</title>
		<link>http://www.dataxstream.com/2010/05/what%e2%80%99s-in-a-naming-convention/</link>
		<comments>http://www.dataxstream.com/2010/05/what%e2%80%99s-in-a-naming-convention/#comments</comments>
		<pubDate>Wed, 05 May 2010 13:30:25 +0000</pubDate>
		<dc:creator>Dave Morin</dc:creator>
				<category><![CDATA[SAP Interface Blog]]></category>
		<category><![CDATA[SAP PI Blog]]></category>
		<category><![CDATA[SAP Technical]]></category>
		<category><![CDATA[DataXstream]]></category>
		<category><![CDATA[David Morin]]></category>
		<category><![CDATA[namespace]]></category>
		<category><![CDATA[PI]]></category>
		<category><![CDATA[SAP PI]]></category>

		<guid isPermaLink="false">http://www.dataxstream.com/?p=4762</guid>
		<description><![CDATA[It doesn’t take long for a PI implementation to become a complete mess if standards are not put in place before development occurs.  Even among seasoned developers, opinions vary as to the best way to name and organize the IR (ESR) or ID (IB), depending on different backgrounds and previous project experience.  In the next [...]]]></description>
			<content:encoded><![CDATA[<p>It doesn’t take long for a PI implementation to become a complete mess if standards are not put in place before development occurs.  Even among seasoned developers, opinions vary as to the best way to name and organize the IR (ESR) or ID (IB), depending on different backgrounds and previous project experience.  In the next few blogs I would like to touch upon some of the best practices that we utilize in our implementations at DataXstream, which we have arrived at though our project experiences and  discussion, both internally and with other middleware experts.
<span id="more-4762"></span></p>
<h2>Part One &#8211; The Integration Directory (for PI 7.1 or greater)</h2>
<p>I decided to start with the Integration Builder because it’s the easier component with which to bring everything into alignment (versus the ESR). Most of the time there are only two things to name: the scenario and the communication channel.  Unfortunately, it is still incredibly easy for objects to become disorganized.</p>
<h3>Configuration Scenarios</h3>
<p>The whole purpose of a configuration scenario is for organization. An interface will run whether it is in a scenario or not, however troubleshooting is much more difficult when objects are not properly organized. It is important to use a naming convention that addresses the business purpose of the interface and is specific to the flow of the interface (to help with troubleshooting issues and make flows easily traceable).  To accomplish all of these requirements, DataXstream recommends a naming convention that includes the specification number which originated the development request and a route number. The route number is used in interface diagrams and documentation and assists production support with identifying objects in the event that a business scenario involves multiple destinations.  We also recommend including a statement to describe the flow for the route, as well as the description of what the interface does. Some examples of a naming convention we might use would be:</p>
<p>0001.001_ECC_to_Partner1_TransactionalDataDistribution
0001.002_ECC_to_Partner2_TransacationalDataDistribution
0002.001_Partner3_to_ECC_SomeInboundInterface
0003.001_Partner4_to_Partner5_SomeNonSAPInterface</p>
<p>The other thing of note is that all objects should exist in a scenario, even if in a test_DONOTTRANSPORTTOPRODUCTION_prototype_interfacedescription scenario. Proper organization makes it a lot easier to identify, modify, turn on and off, and troubleshoot interfaces. Fully configured interfaces running in objects view take more time to understand and are more time consuming to fix.</p>
<h3>Communication Channels</h3>
<p>Communication channels should describe the purpose, type, and direction of communication. However a lot of people include unnecessary components in the communication channel. For example, since there are usually only two objects with names in the IB, it is not necessary to prefix a communication channel with cc_ as it is unlikely to ever be confused for a scenario. A lot of people also include the communication component in the name of the communication channel, but that also seems redundant, since only communication channels exist under communication components. Some things that are valuable in looking at communication channel naming convention are knowing a brief description of the process it involves, a direction of the communication channel, and the type of adapter being used. Some examples of naming conventions we might use are:</p>
<p><strong>Logistics Company</strong></p>
<ul>
<li>PO_file_sender</li>
</ul>
<p><strong>Database System</strong></p>
<ul>
<li>materialSqlXml_jdbc_receiver</li>
</ul>
<p><strong>ECC system</strong></p>
<ul>
<li>IDoc_receiver</li>
</ul>
<p>As you can see, it is possible to keep the name descriptive and helpful without making the name overly verbose when it comes to communication channels.</p>
<p>The order in which the naming components are ordered depend as much on personal preference as anything else.  For example, let&#8217;s examine a sender file channel that pertains to purchase order data.  Some of the naming convention options are:</p>
<ul>
<li>Sender_File_PO: groups all sender and receiver channels together, then groups by adapter type</li>
<li>File_Sender_PO: groups communication channels by adapter type, then by sender and receiver</li>
<li>PO_File_Sender: groups by logical interface payload, then adapter type</li>
</ul>
<h3>Other Things To Watch Out For</h3>
<ul>
<li><strong>Configure the unnecessary</strong>- We all know that no sender agreement or channel is needed for certain communication methods like iDoc or SOAP to the IE, but if you can, add them to the scenario anyways. It makes it easier for a new developer (think of someone new to production support) to understand what’s happening with an interface, when they can see a consistent flow of the interface sender agreement to receiver agreement on all interfaces in a landscape. I know from working with working with soap, it’s kind of nice being able to grab the wsdl from the sender agreement, even though that component is technically optional.</li>
</ul>
<ul>
<li><strong>Don’t force an interface to work</strong>- If you are configuring a determination or agreement and are not seeing what you expect from the drop down menu, it may be because you haven’t properly defined the SLD or IR. Don’t be lazy and select the interface from all namespaces or SWCVs just to make the interface work; go back and figure out why its not dropping down on the drop down box and correct it.</li>
</ul>
<p>Establishing and adhering to a well thought-out and consistent naming convention can save you a lot of time during the support of your SAP PI interfaces.  In Part II of this blog, I will discuss naming conventions in SAP PI&#8217;s Enterprise Service Repository (ESR).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dataxstream.com/2010/05/what%e2%80%99s-in-a-naming-convention/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>IDoc Has Left The Building</title>
		<link>http://www.dataxstream.com/2010/04/idoc-has-left-the-building/</link>
		<comments>http://www.dataxstream.com/2010/04/idoc-has-left-the-building/#comments</comments>
		<pubDate>Tue, 06 Apr 2010 13:30:00 +0000</pubDate>
		<dc:creator>Steve Park</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[SAP Interface Blog]]></category>
		<category><![CDATA[SAP Technical]]></category>
		<category><![CDATA[IDOC]]></category>
		<category><![CDATA[Interface]]></category>
		<category><![CDATA[SAP]]></category>
		<category><![CDATA[Steve Park]]></category>

		<guid isPermaLink="false">http://www.dataxstream.com/?p=4339</guid>
		<description><![CDATA[SAP IDocs are a tried and true interface methodology.  But as with any interfacing technology the most brittle component is the connection between the two systems (in the case, SAP and the subsystem).  In scenarios where SAP is sending IDocs to a subsystem via the transactional RFC, one question is paramount: How do you know [...]]]></description>
			<content:encoded><![CDATA[<p>SAP IDocs are a tried and true interface methodology.  But as with any interfacing technology the most brittle component is the connection between the two systems (in the case, SAP and the subsystem).  In scenarios where SAP is sending IDocs to a subsystem via the transactional RFC, one question is paramount:</p>
<blockquote><p><strong>How do you know when an Outbound IDoc has physically left SAP?</strong></p></blockquote>
<p>It’s a simple fact that if your subsystem never receives an IDoc from SAP, the subsystem will not be able to route or process the IDoc.   I have always gone by the notion that once the subsystem has successfully received the IDoc, the subsystem now has all the responsibility to process and route the IDoc, but before that time, SAP has the responsibility to ensure that the IDoc is fully dispatched.  The subsystem should have processes in place to determine if the IDoc has been received at the target system successfully or not.  In this blog I will focus on the handshake between SAP and the subsystem.  This will entail Outbound IDoc status and a couple of batch jobs that should be setup to ensure a better chance of a successful handoff between SAP and the subsystem.</p>
<p><span id="more-4339"></span>First, let&#8217;s cover the normal, expected progression of statuses for outbound IDocs.  The following graphic shows the collection of status records for a random outbound IDoc.</p>
<p><a href="http://www.dataxstream.com/wp-content/uploads/2010/03/IDOC-Statuses.jpg" rel="shadowbox[post-4339];player=img;"><img class="alignnone size-full wp-image-4584" title="IDOC Statuses" src="http://www.dataxstream.com/wp-content/uploads/2010/03/IDOC-Statuses.jpg" alt="" width="423" height="167" /></a></p>
<p>The status records at the bottom of the list depict the IDoc status <em>before</em> the status records at the top of the list.  So, in this example, the IDoc started in status &#8220;01 &#8211; IDoc generated&#8221;, then progressed to status &#8220;30 &#8211; IDoc ready for dispatch (ALE service).&#8221;  These two statuses usually are created in rapid succession for outbound IDocs and mean that the IDoc has been created in the SAP system and is ready to be sent via tRFC to the subsystem.  The next two IDoc status, 03 and 12, can be a little confusing.  They both seem to mean that the IDoc has been dispatched from SAP.  What is the difference?  I have found that sometimes there is some confusion on weather the IDoc has left SAP or not.  After I explain the difference, I will show 2 batch jobs that should be setup in order to update the status if the Outbound IDoc has physically left SAP.</p>
<h2><strong>So what do statuses ‘03’ and ‘12’ really mean?</strong></h2>
<p>The status ‘03’ actually means “Data passed to port OK” which basically means that the IDoc has been dispatched to the tRFC queue and an attempt was made to send the IDoc to the subsystem.  However, that does not necessarily mean that the IDoc has left SAP.   There could be many reasons why SAP would fail to send the IDoc.  One example could be that the subsystem was down during the transmission of the IDoc.  Errors during data transmission would cause the IDoc to remain in the tRFC queue.  Thus, the IDoc would still remain in SAP and remain with a status of ‘03’.</p>
<p>When the Status changes to ‘12’; a successful connection was made to the subsystem and the IDoc was sent.  This status represents that the Outbound IDoc is no longer in the tRFC queue  and, therefore, has physically left SAP.  The IDoc is in the hands of the subsystem which is now responsible for processing or routing the IDoc.</p>
<h2><strong>But what if I never see a status of ‘12’ on IDocs that were successfully sent?</strong></h2>
<p>For one reason or another, sometimes the batch job to update the status to ‘12’ is not scheduled.  In Production this batch job is usually set up, however in the QA or Dev environment this may or may not be setup depending on the client.</p>
<p>1)  The following job should be setup in order to process a status ‘12’.  I typically set this to every 10 minutes depending on the client.</p>
<p>Program:  <strong>RBDMOIND </strong>– Schedule this program in order to check whether the IDoc have been successfully sent out of the tRFC queue.  If the IDoc has been sent successfully to the subsystem, the program RBDMOIND will change the status of the IDoc from status ‘03’ to status ‘12’.  This means that the handshake with subsystem was successfully and the IDoc has physically left SAP.</p>
<p>2)  There may be times when the subsystem is unavailable at the time the SAP is trying to send the Outbound IDoc.  By default, SAP will only make one attempt to transmit the IDoc.  By scheduling the following program in a batch job, SAP will try to resend the Outbound IDoc again at a specified time interval.  I also usually set this at job every 10 min, depending on the client.</p>
<p>Program:  <strong>RSARFCEX</strong> – Schedule this program in a batch job in order to resend any IDocs that have are stuck on the tRFC queue.</p>
<h2><strong>Ok I have set up these jobs, but the status does not change.  Now what?</strong></h2>
<p>Sometimes an Outbound IDoc could remain stuck on the tRFC queue and never get sent out successfully.  Some issues could be that the RFC Destination for the subsystem is configured incorrectly or there could be an authorization issue.  These types of errors need to be fixed before the batch job for RSARFCEX will send the IDoc out successfully.  You may need to get some additional detail of the problem.  Execute the following transaction below.</p>
<p><strong>Transaction SM58</strong> – This will check what is currently on the tRFC queue.   Once you display the list, you also have the ability to drill down and get some additional detail of what has caused the failed transmission.</p>
<p><a href="http://www.dataxstream.com/wp-content/uploads/2010/03/SM58.jpg" rel="shadowbox[post-4339];player=img;"><img class="alignnone size-full wp-image-4585" title="SM58" src="http://www.dataxstream.com/wp-content/uploads/2010/03/SM58.jpg" alt="" width="612" height="202" /></a></p>
<h2><strong>Conclusion</strong></h2>
<p>Typically you won’t see many issues with Outbound IDocs.  From time to time, IDocs will get stuck on the tRFC queue and if not managed properly, could be stuck there a long time.  This blog should give you more visibility in respect to IDoc status to ensure that the Outbound IDoc has successfully left SAP for processing.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dataxstream.com/2010/04/idoc-has-left-the-building/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Too Many Developers Spoil The Code</title>
		<link>http://www.dataxstream.com/2010/03/too-many-developers-spoil-the-code/</link>
		<comments>http://www.dataxstream.com/2010/03/too-many-developers-spoil-the-code/#comments</comments>
		<pubDate>Wed, 31 Mar 2010 13:24:42 +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[ABAP]]></category>
		<category><![CDATA[ABAP development]]></category>
		<category><![CDATA[BADI]]></category>
		<category><![CDATA[Craig Stasila]]></category>
		<category><![CDATA[DataXstream]]></category>
		<category><![CDATA[SAP ABAP]]></category>

		<guid isPermaLink="false">http://www.dataxstream.com/?p=4689</guid>
		<description><![CDATA[You may have heard the following idiom before: Too many cooks spoil the broth The common meaning extracted from this saying is that too many people working on a single task tend to make a mess of it.  But, what happens when you have too many developers working in a single piece of ABAP code? [...]]]></description>
			<content:encoded><![CDATA[<p>You may have heard the following idiom before:</p>
<blockquote><p>Too many cooks spoil the broth</p></blockquote>
<p>The common meaning extracted from this saying is that too many people working on a single task tend to make a mess of it.  But, what happens when you have too many developers working in a single piece of ABAP code?  That&#8217;s right, you get a big mess.  This issue is especially difficult to deal with when there are multiple functional requirements leveraging the same custom code object, form-based user-exit, or function-based user-exit.</p>
<p>While current releases of SAP (those built on SAP NetWeaver 2004s and later) have good built-in handling of enhancements and customizations via implicit and explicit enhancement points and BADIs, there still exists many old-school user-exits.</p>
<h2>Multiple Developers; One Code Object</h2>
<p>I recently worked on a project where three separate developers were creating three separate interfaces based on the outbound delivery IDOC.  While the development for all three interfaces was occurring at the same time, the go-live date for each of the interfaces were different (we&#8217;ll discuss that project management glitch at another time).  Each interface required a separate set of custom fields and, therefore, it&#8217;s own IDOC extension.  The problem is there is only one appropriate user-exit in IDOC_OUTPUT_DELVRY and three developers needed to be developing in it at the same time!</p>
<p>How did we solve this problem?
<span id="more-4689"></span></p>
<h2>An Object To Call One&#8217;s Own</h2>
<p>To allow each developer his own development object and transport timeline, I decided to implement a custom multiple-use, filtered BADI <em>inside</em> the SAP user-exit function EXIT_SAPLV56K_002.  Actually, you can implement your own BADI almost anywhere you need alternate logic execution&#8211;even custom code!</p>
<p>So you might be saying, &#8220;Create my own multi-use, filtered BADI definition? Sounds complicated.&#8221; Well, it&#8217;s easier than you think!</p>
<p>NOTE: This solution was done on an ECC6 system based on SAP NetWeaver 2004s.  The steps to implement this type of solution in ECC5 (SAP NetWeaver 2004) are very similar.</p>
<h2>Create A Custom BADI Definition</h2>
<ol>
<li>To create a new enhancement spot definition, use transaction SE18.  I named my enhancement spot Z_EXIT_SAPLV56K_002 because the enhancement spot will be used in user-exit function EXIT_SAPLV56K_002.
<a href="http://www.dataxstream.com/wp-content/uploads/2010/03/BADI-01.jpg" rel="shadowbox[post-4689];player=img;"><img class="alignnone size-full wp-image-4694" title="BADI 01" src="http://www.dataxstream.com/wp-content/uploads/2010/03/BADI-01.jpg" alt="" width="399" height="179" /></a></li>
<li>In the ensuing dialog box, enter a description and choose <em>BAdi</em> <em>Definition</em> for the Technology
<a href="http://www.dataxstream.com/wp-content/uploads/2010/03/BADI-02.jpg" rel="shadowbox[post-4689];player=img;"><img class="alignnone size-full wp-image-4695" title="BADI 02" src="http://www.dataxstream.com/wp-content/uploads/2010/03/BADI-02.jpg" alt="" width="646" height="149" /></a></li>
<li>Next, create a new BADI definition.
<a href="http://www.dataxstream.com/wp-content/uploads/2010/03/BADI-03.jpg" rel="shadowbox[post-4689];player=img;"><img class="alignnone size-full wp-image-4696" title="BADI 03" src="http://www.dataxstream.com/wp-content/uploads/2010/03/BADI-03.jpg" alt="" width="614" height="191" /></a></li>
<li>Specify that the new BADI definition will be multiple use and limited to filtered use.
<a href="http://www.dataxstream.com/wp-content/uploads/2010/03/BADI-04.jpg" rel="shadowbox[post-4689];player=img;"><img class="alignnone size-full wp-image-4697" title="BADI 04" src="http://www.dataxstream.com/wp-content/uploads/2010/03/BADI-04.jpg" alt="" width="538" height="95" />
</a>Making the BADI definition multiple use means that each developer can create his or her own BADI implementation.  Each BADI is implemented in its own class.  This promotes code separation and the proper reuse of shared development objects.
Making the BADI definition limited to filter use ensures that the BADI implementations are separate and cannot affect every interface using the user-exit.</li>
<li>Now, create a new filter.
<a href="http://www.dataxstream.com/wp-content/uploads/2010/03/BADI-05.jpg" rel="shadowbox[post-4689];player=img;"><img class="alignnone size-full wp-image-4698" title="BADI 05" src="http://www.dataxstream.com/wp-content/uploads/2010/03/BADI-05.jpg" alt="" width="262" height="102" /></a>
BADI filtering in SAP NetWeaver 2004s is much more powerful than in previous versions of SAP.  Read more about BADI filtering <a href="http://help.sap.com/saphelp_nw04/helpdata/en/eb/3e7cf7940e11d295df0000e82de14a/frameset.htm" target="_blank">here</a>.</li>
<li><a href="http://www.dataxstream.com/wp-content/uploads/2010/03/BADI-05.jpg" rel="shadowbox[post-4689];player=img;"></a> The BADI we are defining will be used to populate IDOC extensions.  Each IDOC extension has its own message type (e.g. ZMHL_DESADV, ZQTC_DESADV, ZMHL_SHPORD), therefore the message type of the IDOC being processed is a good value to filter on.  I named my BADI filter EDI_MESTYP.
<a href="http://www.dataxstream.com/wp-content/uploads/2010/03/BADI-06.jpg" rel="shadowbox[post-4689];player=img;"><img class="alignnone size-full wp-image-4710" title="BADI 06" src="http://www.dataxstream.com/wp-content/uploads/2010/03/BADI-06.jpg" alt="" width="588" height="288" /></a>
SAP allows for the automatic checking of BADI implementation filter values.  The standard domain EDI_MESTYP has a value range of table EDMSG attached to it.  This is exactly the range of values I want as allowable values, so I configure the BADI filter to automatically check the filter values against dictionary object EDI_MESTYP.</li>
<li>Next, create the BADI interface that will be inherited by each implementing class
<a href="http://www.dataxstream.com/wp-content/uploads/2010/03/BADI-07.jpg" rel="shadowbox[post-4689];player=img;"><img class="alignnone size-full wp-image-4700" title="BADI 07" src="http://www.dataxstream.com/wp-content/uploads/2010/03/BADI-07.jpg" alt="" width="572" height="149" /></a></li>
<li>The original user-exti function EXIT_SAPLV56K_002 is executed after each segment is added.  Our BADI will do the same.  Create a new public interface method SEGMENT_ADDED.
<a href="http://www.dataxstream.com/wp-content/uploads/2010/03/BADI-08.jpg" rel="shadowbox[post-4689];player=img;"><img class="alignnone size-full wp-image-4701" title="BADI 08" src="http://www.dataxstream.com/wp-content/uploads/2010/03/BADI-08.jpg" alt="" width="560" height="118" /></a></li>
<li>The BADI we are creating is replicating user-exit function EXIT_SAPLV56K_002.  Here is the function interface for EXIT_SAPLV56K_002:
<a href="http://www.dataxstream.com/wp-content/uploads/2010/03/BADI-09_1.jpg" rel="shadowbox[post-4689];player=img;"><img class="alignnone size-full wp-image-4711" title="BADI 09_1" src="http://www.dataxstream.com/wp-content/uploads/2010/03/BADI-09_1.jpg" alt="" width="602" height="383" /></a>
Here is the same data being passed via the interface method.
<a href="http://www.dataxstream.com/wp-content/uploads/2010/03/BADI-09.jpg" rel="shadowbox[post-4689];player=img;"><img class="alignnone size-full wp-image-4702" title="BADI 09" src="http://www.dataxstream.com/wp-content/uploads/2010/03/BADI-09.jpg" alt="" width="582" height="218" /></a></li>
<li>Lastly, the BADI has to be called from the existing user-exit.  I will not cover the steps required for implementing user-exit function EXIT_SAPLV56K_002 here, but once you have the user-exit implemented, add the following code.  This code should be the only logic directly inside the user-exit.  Any data processing logic should be implemented via a BADI implementation:
<pre style="background-color: #eaeaea; color: #222;">DATA: GO_BADI TYPE REF TO Z_EXIT_SAPLV56K_002.
DATA: L_STR TYPE STRING.
L_STR = MESSAGE_TYPE.

* Get BADI class based on IDOC message type
GET BADI GO_BADI
   FILTERS EDI_MESTYP = L_STR.

* Execute SEGMENT_ADDED BADI method
CALL BADI GO_BADI-&gt;SEGMENT_ADDED
   EXPORTING
     MESSAGE_TYPE       = MESSAGE_TYPE
     SEGMENT_NAME       = SEGMENT_NAME
     DATA               = DATA
     TAB_IDOC_REDUCTION = TAB_IDOC_REDUCTION
     FLT_VAL            = MESSAGE_TYPE
   CHANGING
     CONTROL_RECORD_OUT = CONTROL_RECORD_OUT
     IDOC_DATA          = IDOC_DATA[].</pre>
</li>
</ol>
<p>We&#8217;re done with creating the BADI definition!  Save and activate your work.  I bet you&#8217;re saying to yourself, &#8220;Wow, that was easy!&#8221;</p>
<h2>BADI Implementation</h2>
<p>Implementing the BADI you just created in the steps above is just like implementing any other BADI in SAP, so here are the Cliff Notes version of implementation instructions.</p>
<ol>
<li>Using transaction SE19, create a new enhancement spot implementation for Z_EXIT_SAPLV56K_002.
<a href="http://www.dataxstream.com/wp-content/uploads/2010/03/BADI-10.jpg" rel="shadowbox[post-4689];player=img;"><img class="alignnone size-full wp-image-4703" title="BADI 10" src="http://www.dataxstream.com/wp-content/uploads/2010/03/BADI-10.jpg" alt="" width="547" height="180" /></a></li>
<li>Enter the BADI implementation details.  This particular BADI implementation is for RICEF ID MHL-IO-007, so I added that identification to the BADI implementation name and implementing class name.
<a href="http://www.dataxstream.com/wp-content/uploads/2010/03/BADI-12.jpg" rel="shadowbox[post-4689];player=img;"><img class="alignnone size-full wp-image-4705" title="BADI 12" src="http://www.dataxstream.com/wp-content/uploads/2010/03/BADI-12.jpg" alt="" width="572" height="280" /></a></li>
<li>In the BADI definition, we required each BADI implementation to be filtered on message type. This particular BADI implementation is for message type ZMHL_SHPORD.  Create the filter combination for the BADI implementation.
<a href="http://www.dataxstream.com/wp-content/uploads/2010/03/BADI-13.jpg" rel="shadowbox[post-4689];player=img;"><img class="alignnone size-full wp-image-4706" title="BADI 13" src="http://www.dataxstream.com/wp-content/uploads/2010/03/BADI-13.jpg" alt="" width="586" height="149" /></a></li>
<li>This ensures that the other interfaces using this BADI (ZMHL_DESADV, ZQTC_DESADV) will not execute the code implemented with this BADI.
<a href="http://www.dataxstream.com/wp-content/uploads/2010/03/BADI-14.jpg" rel="shadowbox[post-4689];player=img;"><img class="alignnone size-full wp-image-4707" title="BADI 14" src="http://www.dataxstream.com/wp-content/uploads/2010/03/BADI-14.jpg" alt="" width="518" height="255" /></a></li>
<li>The final steps are to add the code to the SEGMENT_ADDED method just like you would in user-exit function EXIT_SAPLV56K_002.  Once you are done, save and activate your changes!</li>
</ol>
<h2>Summary</h2>
<p>As you can see, with a few extra steps, it is possible to have your cake and eat it, too, by create a custom BADI definition that can be used by other developers.  All this talk of food is making me hungry.  Is it lunchtime yet?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dataxstream.com/2010/03/too-many-developers-spoil-the-code/feed/</wfw:commentRss>
		<slash:comments>0</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[ABAP]]></category>
		<category><![CDATA[DataXstream]]></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[post-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[post-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[post-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[post-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[post-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[post-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[post-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[post-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[post-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[post-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[post-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[post-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[post-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[post-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[post-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[post-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[post-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[post-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[post-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>0</slash:comments>
		</item>
		<item>
		<title>Troubleshooting the Services Registry</title>
		<link>http://www.dataxstream.com/2010/02/troubleshooting-the-services-registry/</link>
		<comments>http://www.dataxstream.com/2010/02/troubleshooting-the-services-registry/#comments</comments>
		<pubDate>Sun, 28 Feb 2010 02:07:45 +0000</pubDate>
		<dc:creator>Dave Morin</dc:creator>
				<category><![CDATA[SAP Interface Blog]]></category>
		<category><![CDATA[SAP PI Blog]]></category>
		<category><![CDATA[SAP Technical]]></category>
		<category><![CDATA[DataXstream]]></category>
		<category><![CDATA[David Morin]]></category>
		<category><![CDATA[PI]]></category>
		<category><![CDATA[SAP PI]]></category>
		<category><![CDATA[UDDI]]></category>
		<category><![CDATA[web service]]></category>
		<category><![CDATA[XI]]></category>
		<category><![CDATA[XI/PI]]></category>

		<guid isPermaLink="false">http://www.dataxstream.com/?p=4441</guid>
		<description><![CDATA[Recently I set up the services registry for PI 7.1 EHP1 for a client of ours. Although it seemed like it would be a simple process, I ran into a 401 authorization issue and another issue where  web services were not publishing to the services registry. Looking online there are a lot of people who ran [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I set up the services registry for PI 7.1 EHP1 for a client of ours. Although it seemed like it would be a simple process, I ran into a 401 authorization issue and another issue where  web services were not publishing to the services registry. Looking online there are a lot of people who ran into the same issues as I did, so I am providing, here, the steps to perform if your services registry isn’t working.</p>
<p><span id="more-4441"></span></p>
<p>Please note that I was unable to find the wizard for setting it the Services registry in PI 7.1 EPH1, which means I did it manually.</p>
<h3><strong>Make sure everything is correct in the Services Registry Management </strong></h3>
<p>Go to the NWA (http://host:port/nwa).</p>
<p>Go to <em>SOA Management&gt; Technical Configuration&gt;Services Registry Management</em>.
In theory, there is nothing to do here, however I did specify the discovery URL api parameter as the hostname of the server (no port). If you have changed some settings, on the maintenance tab you can click reinitialize, which should reset any changes you have made back to the initial state.</p>
<h3><strong>Configure the ServicesRegistrySiPort</strong></h3>
<p>Go to <em>SOA Management&gt; Application and Scenario Communication&gt; Single Service Administration</em></p>
<p>Click the Consumer Proxies tab.</p>
<p>Search for &#8220;ServicesRegistrySi&#8221;.</p>
<p>Click on the result and click the Configuration Tab and click on ServicesRegistrySiPort.</p>
<p>The service endpoint name should be ServicesRegistrySiPort.  Don’t change it.</p>
<p>Click security.</p>
<p>You have to give it an http authentication. If you don&#8217;t give the authentication, you will eventually have problems like not being able to publish to the SR, even though you may be able to access the registry.</p>
<p>Click on the user ID/ password, click details, and input your http authentication parameters.</p>
<p style="text-align: center;"><a href="http://www.dataxstream.com/wp-content/uploads/2010/02/ServiceRegistrySI1.png" rel="shadowbox[post-4441];player=img;"><img class="aligncenter size-full wp-image-4455" src="http://www.dataxstream.com/wp-content/uploads/2010/02/ServiceRegistrySI1.png" alt="" width="567" height="596" /></a></p>
<h3><strong>Configure the third party UDDI (Only if not using SAP’s UDDI)</strong></h3>
<p>If you are using a non-sap UDDI, you will need to go to <em>NWA&gt;Destination Template Management</em> and create a UDDI_DESTINATION and a CLASSIFICATION_DESTINATION to point to the respective urls of your uddi. Don’t forget to click security and select User ID/Password Authentication for both destinations. Otherwise, you will get a 401 not authorized error when you try to access the services registry&#8211;similar to if you mistyped your password at ServicesRegistrySiPort.</p>
<p style="text-align: center;"><a href="http://www.dataxstream.com/wp-content/uploads/2010/02/3rd-party-uddi.png" rel="shadowbox[post-4441];player=img;">
</a><a href="http://www.dataxstream.com/wp-content/uploads/2010/02/3rd-party-uddi.png" rel="shadowbox[post-4441];player=img;"></a><a href="http://www.dataxstream.com/wp-content/uploads/2010/02/3rd-party-uddi1.png" rel="shadowbox[post-4441];player=img;"><img class="aligncenter size-full wp-image-4453" src="http://www.dataxstream.com/wp-content/uploads/2010/02/3rd-party-uddi1.png" alt="" width="493" height="503" /></a></p>
<h3><strong>Security</strong></h3>
<p style="text-align: center;">Make sure that your user has  UDDI_TierN and SERVICES_REGISTRY_READ_WRITE authorizations or you will get a 401 not authorized error.  Of course. in your system you should use a technical user instead of your userid as which I did for the purposes of this blog.<a href="http://www.dataxstream.com/wp-content/uploads/2010/02/Security-Authorizations1.png" rel="shadowbox[post-4441];player=img;"><img class="aligncenter size-full  wp-image-4454" src="http://www.dataxstream.com/wp-content/uploads/2010/02/Security-Authorizations1.png" alt="" width="557" height="441" /></a></p>
<p>Please note, I did run into an issue where it suddenly stopped working a day everything was configured. All I can say is Gremlins. I switched the user to a technical user with the authorization listed above on the ServicesRegistrySiPort as well as on the destination templates and I haven’t had a problem since.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dataxstream.com/2010/02/troubleshooting-the-services-registry/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>BD53 Doesn’t Play Well With Others</title>
		<link>http://www.dataxstream.com/2010/02/bd53-doesn%e2%80%99t-play-well-with-others/</link>
		<comments>http://www.dataxstream.com/2010/02/bd53-doesn%e2%80%99t-play-well-with-others/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 16:03:32 +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[ALE]]></category>
		<category><![CDATA[Change Pointer]]></category>
		<category><![CDATA[Craig Stasila]]></category>
		<category><![CDATA[DataXstream]]></category>
		<category><![CDATA[Integration]]></category>
		<category><![CDATA[Interface]]></category>
		<category><![CDATA[SAP]]></category>

		<guid isPermaLink="false">http://www.dataxstream.com/?p=4397</guid>
		<description><![CDATA[I recently posted a blog about how to implement field-level IDOC reduction for the HRMD_A message type.  In short, the standard SAP transaction to reduce IDOC segments and fields (transaction BD53) can&#8217;t be used because the field-level reduction is ignored by SAP.  My solution leveraged TVARV as a repository for the fields to clear.  Read the whole [...]]]></description>
			<content:encoded><![CDATA[<p>I recently posted a blog about how to implement field-level IDOC reduction for the HRMD_A message type.  In short, the standard SAP transaction to reduce IDOC segments and fields (transaction BD53) can&#8217;t be used because the field-level reduction is ignored by SAP.  My solution leveraged TVARV as a repository for the fields to clear.  Read the whole solution <a href="http://www.dataxstream.com/2010/02/how-to-implement-field-level-hrmd_a-reduction/" target="_blank">here</a>. A <a href="http://www.dataxstream.com/author/tyates/" target="_blank">colleague</a> of mine was very quick to point out that instead of using TVARV as the method for controlling which fields are cleared, I should have continued to leverage transaction BD53 for the IDOC reduction maintenance and changed my code to look up field level reductions in table TBD24.</p>
<p>What a great idea!  Too bad I hate this suggestion&#8230; and it&#8217;s all SAP&#8217;s fault!!</p>
<p><span id="more-4397"></span>You see, SAP transaction BD53 just does not play well with others.  My full HRMD_A solution used a custom filter object (transactions BD95 and BD59) and a custom outbound IDOC formatting function module to convert change pointers into IDOCs (transaction BD60).  The dirty little secret of transaction BD53 is that every time you save and update the IDOC reduction in transaction BD53, SAP goes and screws up a bunch of configuration  displaying a message that says <em>&#8220;Interface changed for message type &lt;your_message_type&gt;:  Settings reset&#8221;</em></p>
<p><a href="http://www.dataxstream.com/wp-content/uploads/2010/02/00-Settings-Reset.jpg" rel="shadowbox[post-4397];player=img;"><img class="alignnone size-full wp-image-4398" title="00 Settings Reset" src="http://www.dataxstream.com/wp-content/uploads/2010/02/00-Settings-Reset.jpg" alt="" width="436" height="152" /></a></p>
<p><strong>Wait! What!?!</strong></p>
<p>What does that message even mean?  Well, that message is telling you in very cryptic language that SAP has gone and reset the settings in BD59 and BD60 to the SAP standard! So, every time the field reductions were updated, kiss your custom filter assignments and custom IDOC processing function goodbye!</p>
<p>Why couldn&#8217;t the message say:</p>
<blockquote><p>Hey Buddy! You know all that custom configuration you did to get your interface working just so? Well, its gone and you&#8217;re going to have to redo it all in the following transactions:
BD59
BD60
etc.</p></blockquote>
<p>I guess SAP is just far too polite.</p>
<p>So, be very cautious when you pair IDOC reduction with custom filter assignments and custom IDOC formatting function modules and be aware that <strong>every time</strong> the IDOC reduction is updated, you will need to go back in to reconfigure transactions BD59 and BD60.</p>
<p>For more information, see SAP <a href="https://service.sap.com/sap/bc/bsp/spn/sapnotes/index2.htm?numm=655321" target="_blank">OSS Note 655321</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.dataxstream.com/2010/02/bd53-doesn%e2%80%99t-play-well-with-others/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How To Implement Field-Level HRMD_A Reduction</title>
		<link>http://www.dataxstream.com/2010/02/how-to-implement-field-level-hrmd_a-reduction/</link>
		<comments>http://www.dataxstream.com/2010/02/how-to-implement-field-level-hrmd_a-reduction/#comments</comments>
		<pubDate>Wed, 24 Feb 2010 13:08:42 +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[ABAP]]></category>
		<category><![CDATA[ALE]]></category>
		<category><![CDATA[Craig Stasila]]></category>
		<category><![CDATA[HRMD_A]]></category>
		<category><![CDATA[IDOC]]></category>
		<category><![CDATA[Interface]]></category>
		<category><![CDATA[SAP programming]]></category>

		<guid isPermaLink="false">http://www.dataxstream.com/?p=4289</guid>
		<description><![CDATA[I love ALE.  It is super-powerful and, once you get the hang of it, is a snap to configure.  Recently, I was setting up an HRMD_A interface for my client.  Everything was going smoothly until I ran into a requirement to filter out the social security number (PERID), birthdate (GBDAT), and gender (GESCH) for privacy [...]]]></description>
			<content:encoded><![CDATA[<p>I love ALE.  It is super-powerful and, once you get the hang of it, is a snap to configure.  Recently, I was setting up an HRMD_A interface for my client.  Everything was going smoothly until I ran into a requirement to filter out the social security number (PERID), birthdate (GBDAT), and gender (GESCH) for privacy reasons.  All of these fields are in segment E1P0002.  Initially, I thought that this requirement was easy enough to accomplish.  I just created a IDOC reduction in transaction BD53 and filtered out the three fields.  I soon found out that while entire segments were getting reduced from the IDOC as configured, the individually reduced fields were still showing up in the IDOC.  What&#8217;s going on?!?
<span id="more-4289"></span> Well, after some digging, I found <a href="https://service.sap.com/sap/bc/bsp/spn/sapnotes/index2.htm?numm=381766" target="_blank">OSS Note 381766</a>.  This note&#8217;s cause section states:</p>
<blockquote><p>The reduction at segment level (see also Note 301223) was facilitated in order to be able to copy message type HRMD_A. This involved setting the reduction at field level, which was not taken into account in the code because it is not possible to centrally determine which fields are mandatory and which are dependent for all country versions. In addition, for one info type there may several records for different periods of time, which may also cause a problem when you are reducing fields.</p></blockquote>
<p>So, in essence, field-level reduction isn&#8217;t supported for HRMD_A.  The solution supplied in the OSS note suggests creating user-exit code to filter out the unwanted fields.  I already have implemented BADI HRALE00OUTBOUND_IDOC to add some other processing logic (if you&#8217;re lucky I&#8217;ll cover that logic in this blog, too), so I have a module in which I can place the code. And while the code to loop through an IDOC and clear out all instances of E1P0002-PERID, E1P0002-GBDAT, and E1P0002-GESCH is very easy, I can&#8217;t help but think I can make the code more useful.  You see, I hate unitasking code.  I can see it now.  If I take the shortcut path and wrote the unitasking code to clear those 3 fields, the code won&#8217;t be in production for more than a month before the requirements change and now there is another field that needs to be filtered out as well.  With unitasking code, I would have to crack open the code, create a transport, unit test, transport to Q, integration test, wait for a transport window, blah, blah, blah.  Ugh!  What a waste of time for a minor change.  We can do better.</p>
<p>I decided to create a multi-tasking module that will work for HRMD_A message types.  The fields to be cleared will be stored in TVARV in the format &lt;SEGMENT&gt;-&lt;FIELD&gt; (e.g. E1P0002-PERID).  That way, whenever the HR functional team wanted to filter out a new field, all they had to do was to update a TVARV variable.</p>
<p>To implement the solution, I created a new method called CLEAR_IDOC_FIELDS in my class implementation for BADI HRALE00OUTBOUND_IDOC.  CLEAR_IDOC_FIELDS has the same method signature as IF_EX_HRALE00OUTBOUND_IDOC~IDOC_DATA_FOR_RECEIVER_MODIFY:</p>
<p><a href="http://www.dataxstream.com/wp-content/uploads/2010/02/00-Method-Signature.jpg" rel="shadowbox[post-4289];player=img;"><img class="alignnone size-full wp-image-4293" title="00 Method Signature" src="http://www.dataxstream.com/wp-content/uploads/2010/02/00-Method-Signature.jpg" alt="" width="605" height="163" /></a></p>
<p>The code is pretty straight forward.  To allow multiple interfaces to coexist in method CLEAR_IDOC_FIELDS, the TVARV variable that stores the fields to clear is in the format &#8216;ZHR_CLR_&#8217; concatenated with the IDOC message type.</p>
<pre style="background-color: #eaeaea; color: #222;">METHOD CLEAR_IDOC_FIELDS .
*----------------------------------------------------------------------*
* Class:     ZCL_IM_HRALE00OUTBOUNDIDOC                                *
* Method:    CLEAR_IDOC_FIELDS                                         *
* Author:    Craig Stasila                                             *
*----------------------------------------------------------------------*

  TYPES: BEGIN OF TY_FILTER,
           TABNAME   TYPE DFIES-TABNAME,
           FIELDNAME TYPE DFIES-FIELDNAME,
           POSITION  TYPE DFIES-POSITION,
           OFFSET    TYPE DFIES-OFFSET,
           LENG      TYPE DFIES-LENG,
        END OF TY_FILTER.

  DATA: WA_FILTER      TYPE TY_FILTER,
        LT_FILTER      TYPE TABLE OF TY_FILTER,
        LS_TABNAME     TYPE DDOBJNAME,
        LS_SAV_TABNAME TYPE DDOBJNAME.

  DATA: LS_NAME   TYPE TVARV-NAME,
        LT_TVARVC TYPE TABLE OF TVARVC,
        WA_TVARVC TYPE TVARVC.

  DATA: LT_DFIES TYPE TABLE OF DFIES,
        WA_DFIES TYPE DFIES.

  DATA: LR_SEGNAM TYPE RANGE OF EDIDD-SEGNAM,
        WR_SEGNAM LIKE LINE OF LR_SEGNAM.

  FIELD-SYMBOLS: &lt;FS&gt; TYPE LINE OF EDIDD_TT.

* Fields to clear are in variable
  CONCATENATE 'ZHR_CLR_' MESTYP INTO LS_NAME.

* Get list of fields to clear from TVARV
  SELECT * FROM TVARVC
    INTO TABLE LT_TVARVC
   WHERE NAME = LS_NAME
     AND TYPE = 'S'.

  CHECK SY-SUBRC = 0.

* Build list of fields to clear
  LOOP AT LT_TVARVC INTO WA_TVARVC.
    CLEAR WA_FILTER.
    SPLIT WA_TVARVC-LOW AT '-' INTO WA_FILTER-TABNAME WA_FILTER-FIELDNAME.
    CHECK SY-SUBRC = 0.

    COLLECT WA_FILTER INTO LT_FILTER.
  ENDLOOP.

  SORT LT_FILTER BY TABNAME.
  CLASS CL_ABAP_CHAR_UTILITIES DEFINITION LOAD.

* Get field offsets
  LOOP AT LT_FILTER INTO WA_FILTER.
    LS_TABNAME = WA_FILTER-TABNAME.

    IF LS_TABNAME NE LS_SAV_TABNAME.

      CALL FUNCTION 'DDIF_NAMETAB_GET'
        EXPORTING
          TABNAME   = LS_TABNAME
        TABLES
          DFIES_TAB = LT_DFIES
        EXCEPTIONS
          NOT_FOUND = 1
          OTHERS    = 2.

      IF SY-SUBRC &lt;&gt; 0.
        CONTINUE.
      ENDIF.

      SORT LT_DFIES BY TABNAME FIELDNAME.

    ENDIF.

    LS_SAV_TABNAME = LS_TABNAME.

    READ TABLE LT_DFIES INTO WA_DFIES
         WITH KEY TABNAME   = WA_FILTER-TABNAME
                  FIELDNAME = WA_FILTER-FIELDNAME
         BINARY SEARCH.

    CHECK SY-SUBRC = 0.

    WA_FILTER-POSITION = WA_DFIES-POSITION.
    WA_FILTER-OFFSET   = WA_DFIES-OFFSET / CL_ABAP_CHAR_UTILITIES=&gt;CHARSIZE.
    WA_FILTER-LENG     = WA_DFIES-LENG.

    MODIFY LT_FILTER FROM WA_FILTER.

* Build segment name range
    IF SY-SUBRC = 0.
      WR_SEGNAM-SIGN   = 'I'.
      WR_SEGNAM-OPTION = 'EQ'.
      WR_SEGNAM-LOW    = WA_FILTER-TABNAME.
      COLLECT WR_SEGNAM INTO LR_SEGNAM.
    ENDIF.
  ENDLOOP.

* Loop at IDOC to clear fields
  LOOP AT IDOC_DATA ASSIGNING &lt;FS&gt;.
    IF &lt;FS&gt;-SEGNAM IN LR_SEGNAM.
      LOOP AT LT_FILTER INTO WA_FILTER WHERE TABNAME = &lt;FS&gt;-SEGNAM.
        CLEAR &lt;FS&gt;-SDATA+WA_FILTER-OFFSET(WA_FILTER-LENG).
      ENDLOOP.
    ENDIF.
  ENDLOOP.
ENDMETHOD.</pre>
<p>I also added the following code to IF_EX_HRALE00OUTBOUND_IDOC~IDOC_DATA_FOR_RECEIVER_MODIFY:</p>
<pre style="background-color: #eaeaea; color: #222;">* Clear IDOC fields
CALL METHOD ME-&gt;CLEAR_IDOC_FIELDS
  EXPORTING
     IDOC_CONTROL = IDOC_CONTROL
     RECEIVER     = RECEIVER
     MESTYP       = IDOC_CONTROL-MESTYP
  CHANGING
     IDOC_DATA    = IDOC_DATA.</pre>
<p>Finally, I maintained the following TVARV variable:</p>
<p><a href="http://www.dataxstream.com/wp-content/uploads/2010/02/01-TVARV-Variable.jpg" rel="shadowbox[post-4289];player=img;"><img class="alignnone size-full wp-image-4311" title="01 TVARV Variable" src="http://www.dataxstream.com/wp-content/uploads/2010/02/01-TVARV-Variable.jpg" alt="" width="611" height="362" /></a></p>
<p>That&#8217;s all it takes!  Now individual field values can be easily be filtered from outbound HRMD_A IDOCs!.</p>
<p><em>UPDATE: </em>My colleague informed me that instead of using TVARV, I should continue to use BD53 to manage the IDOC reduction and change my code to look up the field reductions in TBD24.  This would be a great idea, but my full HRMD_A solution uses custom filter objects and a custom IDOC formatting function module.  <a href="http://www.dataxstream.com/2010/02/bd53-doesn%E2%80%99t-play-well-with-others/" target="_self">And BD53 does not play well with these customizations.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.dataxstream.com/2010/02/how-to-implement-field-level-hrmd_a-reduction/feed/</wfw:commentRss>
		<slash:comments>4</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[C#]]></category>
		<category><![CDATA[DataXstream]]></category>
		<category><![CDATA[IDOC receiver]]></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>
<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[post-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>
<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>
<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[post-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>
<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>
<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[post-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>
<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>
<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[post-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>
<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="padding-bottom: 0px;margin: 0px;padding-left: 0px;padding-right: 0px;float: none;padding-top: 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>
