!--a11y-->
SAPIDocReceiver 
The SAPIDocReceiver class is a TRFC server implementation used to receive SAP intermediate documents from an SAP system. An example of an IDOC might be a customer sales order or a material master record. IDOC records are typically used in EDI scenarios. See the IdocReceiverService sample for example code.
|
[C#] public class SAPIDocReceiver : SAP.Connector.SAPServer |
Public Constructors
|
public SAPIDocReceiver ( string[] args , SAP.Connector.SAPServerHost host ) |
Creates a new SAPIDocReceiver and attaches to a SAPServerhost. Gets the connection information from args. |
|
public SAPIDocReceiver ( string[] args ) |
Creates a new SAPIDocReceiver and does not attach to a SAPServerhost. Gets the connection information from args. |
|
public SAPIDocReceiver ( System.String ConnectionString , SAP.Connector.SAPServerHost host ) |
Creates a new SAPIDocReceiver and attaches to a SAPServerhost. Gets the connection information from a connection string. |
|
public SAPIDocReceiver ( System.String ConnectionString ) |
Creates a new SAPIDocReceiver and does not attach to a SAPServerhost. Gets the connection information from args. |
|
public SAPIDocReceiver ( ) |
Creates a new SAPIDocReceiver without connection information. Does not attach to a SAPServerhost. |
Public Events
|
public event SAP.Connector.SAPIDocReceiver.ReceiveEventHandler BeginReceive |
Raised when the IDOC transmission from SAP is first received. You must define an event handler for this event in your code. |
|
public event SAP.Connector.SAPIDocReceiver.ReceiveEventHandler EndReceive |
Called at the end of the transmission. You must define an event handler for this event in your code. |
Remarks
SAPIDocReceiver is based on SAPServer and can be managed just like other SAPServerclasses (added to hosts, started and stopped, etc.) The SAPIDocReceiver adds the BeginReceive and EndReceive events to the base implementation. These events are called when an IDOC transmission is first received and after the transmission is completed respectively. The complexity of working with IDOCs is in large part managed by the component’s internal implementation details.
Example
For a complete example see the sample IdocReceiverService.
Creating the variables for IDOC receiver and registering the event handlers
|
private SAPServerHost host; private SAP.Connector.SAPIDocReceiver idocrec; private System.IO.StreamWriter sw; SAPIDocReceiver idocrec = new SAPIDocReceiver(args, host); idocrec.BeginReceive += new SAPIDocReceiver.ReceiveEventHandler(this.idoc_BeginReceive); idocrec.EndReceive += new SAPIDocReceiver.ReceiveEventHandler(this.idoc_EndReceive);
|
Example: BeginReceive event handler
|
private void idoc_BeginReceive(object sender, SAP.Connector.SAPIDocReceiver.ReceiveEventArgs e) { // this method is called when an idoc is received. // we tell the idoc receiver to write to a stream writer EventLog.WriteEntry("Idoc Service", "idoc begin receive"); sw = new System.IO.StreamWriter(@"C:\temp\idocs.txt", true, System.Text.Encoding.ASCII);
e.WriteTo = sw; } |
Example: EndReceive event handler
|
private void idoc_EndReceive(object sender, SAP.Connector.SAPIDocReceiver.ReceiveEventArgs e) { // this method is called when idoc is done being received // we can close the stream writer now EventLog.WriteEntry("Idoc Service", "idoc end receive"); sw.Close(); } |