This section shows how to write a sample console program that sends a STATUS IDoc.

The STATUS message type is used to manipulate the status of another outbound IDoc e.g., when a subsystem receives an IDoc and acknowledges the receive with a status change. STATUS is a simple IDoc that contains only one data record.

Note: Make sure to configure your SAP system to receive IDocs, see Setting Up Receiving IDocs.

Sending a STATUS IDoc #

  1. Open a client connection to the R/3 system using the R3Connection class.
  2. Inquire the IDoc number of the IDoc to be manipulated and read the input.
  3. Use the CreateIdoc method to instance a valid IDoc object. “SYSTAT01” is the IDoc type for the appropriate message type STATUS.

      static void Main(string[] args)  
      {  
         using (R3Connection con = new R3Connection("SAPServer", 00, "SAPUser", "Password", "EN", "800"))
         {
             con.Open(false);  
            
             Console.WriteLine("Which IDocnumber would you like to manipulate?");  
             string IdocNo = Console.ReadLine();  
            
             Idoc i = con.CreateIdoc("SYSTAT01","");
    
  4. Provide receiver and sender information as shown in the code below.

             // Fill Message Type 
             i.MESTYP = "STATUS"; 
      
             // Fill Information about IDoc Reciever 
             i.RCVPRN = "PT4_800"; // Partner number 
             i.RCVPRT = "LS"; // Partner type 
      
             // Fill information about idoc sender 
             i.SNDPOR = "ERPCONNECT"; // Partner port 
             i.SNDPRN = "ERPCONNECT"; // Partner number 
             i.SNDPRT = "LS"; // Partner type
    
  5. Fill in the following fields in segment E1STATS: the new status code (STATUS), date and time (LOGDAT, LOGTIM) and the number of the IDoc to be manipulated.
  6. Send the IDoc using the Send method.

             // Fill the right fields in the segments 
             i.Segments["E1STATS",0].Fields["LOGDAT"].FieldValue = "20210901";
             i.Segments["E1STATS",0].Fields["LOGTIM"].FieldValue = "152301"; 
             i.Segments["E1STATS",0].Fields["STATUS"].FieldValue = "12"; 
             i.Segments["E1STATS",0].Fields["DOCNUM"].FieldValue = IdocNo; 
      
             i.Send(); 
             Console.WriteLine("IDoc sent"); 
             Console.ReadLine();
             }
     }
    
  7. Run the program and check the result.
    The status code of the manipulated IDoc increases from 3 (Data passed…) to 12 (Dispatch OK).
    SAP-Send-IDoc-001