Search code examples
javajcobapiidoc

How to control transaction (commit/rollback) when reading an IDOC


When using JCo (3.x) to read IDOCs sent from a SAP server, what action should be taken to indicate the message has been properly received (i.e. commit)?

In Java I imagine something like:

public class MyHandler implements JCoIDocHandler {
  public void handleRequest(JCoServerContext serverCtx, IDocDocumentList documentList) {
    IDocDocumentIterator iterator = documentList.iterator();
    while (iterator.hasNext()) {
             IDocDocument doc = iterator.next();
             // some processing
    }
    // here I would like to say COMMIT
    // i.e., I confirm all the documents have been read
    // and our side takes ownership
  }   
}

This type of commit seems necessary if we want to make sure no message (IDOC) is lost, even if a bullet hits the CPU during some .hasNext() call. Or am I wrong?


Solution

  • In such cases SAP assumes that you send back IDOC with type of 'ALEAUD'. In this case sender system can change IDOCs statuses to 'document created in receiving system' (41). For more details look into "The advance Guide to inplementing SAP R/3's Application Link Anabling (ALE)" document