cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with SAPIDOCReceiver

Former Member
0 Kudos

Hi,

I am developing an application that receives IDOC's logical it SAP, uses the SAP Net Connector with its SAPIDOCReceiver class.

As the example that we have of SAPIDOCReceiver, I obtain to receive a IDOC in my DotNet application and I saving in a physical directory.

Problem 1

How make I stop instead of saving this IDOC in physical archive, I only read this information thus that to arrive in my application to send them it a database, as for example SQL Server?

This IDOC thus that arrives in my application .Net this in an variable of the System.IO.TextWriter type and is exactly there my difficulty, in reading the information of the IDOC in this variable.

Problem 2

After to receive the IDOC, as I above explained (Problem 1) necessary to send the information for a database (SQL Server) in case that it gives some problem in this processing, necessary to return to the SAP that the processing of this IDOC did not occur successfully, changing the status of the IDOC in the SAP, with this I will be able to process again it. Exists some to make this?

Thank you.

Danilo

Accepted Solutions (0)

Answers (1)

Answers (1)

reiner_hille-doering
Active Contributor
0 Kudos

1: You could create your own class that inherits from TextWriter that directly writes into DB. You would hand in an instance of this class to SAPIDocReceiver.

Or you could use a StringWriter to buffer the data. Some pseudocode:

StringBuilder theIdoc = new StringBuilder();

void Execute()

{

SAPIdocReceiver receiver = new SAPIdocReceiver(...);

receiver.BeginReceive+=new ReceiveEventHandler(this.BeginReceive);

receiver.EndReceive+=new ReceiveEventHandler(this.EndReceveive);

// Add receiver to a host and start it

// ...

}

private void BeginReceive(object sender, ReceiveEventArgs e)

{

e.WriteTo = new StringWriter(this.theIdoc);

}

private void EndReceive(object sender, ReceiveEventArgs e)

{

WriteToDb(this.theIdoc.ToString());

}

2: I'm sure that there is a BAPI for this task, but I just don't know. Sorry.