Quantcast
Channel: SCN : All Content - All Communities
Viewing all articles
Browse latest Browse all 7846

.Net Connector 3.0: change SO via BAPI_SALESORDER_CHANGE

$
0
0

Hi folks,

 

Huge number of questions were been asked about FM BAPI_SALESORDER_CHANGE.

Nevertheless, still I cannot solve my issue with changes in existing Sales Order by using .NET Connector 3.0.

I have a good working sample of how I'm changing SO Header data:

 

publicDataTable BAPI_SALESORDER_CHANGE(RfcDestination destination)
{
  
RfcRepository repo = destination.Repository;
  
IRfcFunction salesDoc = repo.CreateFunction("BAPI_SALESORDER_CHANGE");
  
IRfcFunction salesDocCommit = repo.CreateFunction("BAPI_TRANSACTION_COMMIT");
   salesDoc
.SetValue("SALESDOCUMENT","3939393837");

  
IRfcStructure salesHeader = salesDoc.GetStructure("ORDER_HEADER_IN");
   salesHeader
.SetValue("PURCH_NO_C","Order_01");
  
IRfcStructure salesHeaderINX = salesDoc.GetStructure("ORDER_HEADER_INX");
   salesHeaderINX
.SetValue("UPDATEFLAG","U");
   salesHeaderINX
.SetValue("PURCH_NO_C","X");

  
RfcSessionManager.BeginContext(destination);
   salesDoc
.Invoke(destination);
   salesDocCommit
.Invoke(destination);
  
RfcSessionManager.EndContext(destination);

  
IRfcTable returnTable = salesDoc.GetTable("RETURN");

  
returnConvertToDataTable(returnTable);  
}


It is works perfect, customer PO number has been changed successfully.

 

Now I'm doing the same, but would like to add new item to Sales Order:

 

 

publicDataTable BAPI_SALESORDER_CHANGE(RfcDestination destination)
{
   RfcRepository repo = destination.Repository;
  
IRfcFunction salesDoc = repo.CreateFunction("BAPI_SALESORDER_CHANGE");
  
IRfcFunction salesDocCommit = repo.CreateFunction("BAPI_TRANSACTION_COMMIT");
   salesDoc
.SetValue("SALESDOCUMENT","3939393837");



  
IRfcStructure salesHeader = salesDoc.GetStructure("ORDER_HEADER_IN");
  
IRfcStructure salesHeaderINX = salesDoc.GetStructure("ORDER_HEADER_INX");
   salesHeaderINX
.SetValue("UPDATEFLAG","U");

  
IRfcTable salesItems = salesDoc.GetTable("ORDER_ITEM_IN");
   salesItems
.Append();
   salesItems
.SetValue("ITM_NUMBER",130);
   salesItems
.SetValue("MATERIAL","000000000081828282");
   salesItems
.SetValue("TARGET_QTY",Convert.ToDecimal("1"));
  
IRfcTable salesItemsINX = salesDoc.GetTable("ORDER_ITEM_INX");
   salesItemsINX
.Append();
   salesItemsINX
.SetValue("UPDATEFLAG","I");
   salesItemsINX
.SetValue("ITM_NUMBER",130);
   salesItemsINX
.SetValue("MATERIAL","X");
   salesItemsINX
.SetValue("TARGET_QTY","X");
   RfcSessionManager.BeginContext(destination);
   salesDoc
.Invoke(destination); //HERE I'M GETTING ERROR
   salesDocCommit
.Invoke(destination);
  
RfcSessionManager.EndContext(destination);

  
IRfcTable returnTable = salesDoc.GetTable("RETURN");

  
returnConvertToDataTable(returnTable);

}

 

In this case I'm getting error "Screen output without connection to user" on invoke method calling. How to avoid this isse?

Can someone provide which fields needs to be flilled to add new item to sales order?

What I'm doing wrong?

 

Let me know if you need more info.


Viewing all articles
Browse latest Browse all 7846

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>