Hello All,
I am trying to use the SAP Business One SDK to create a "Receipt from Production" on a disassembly production order with using "Return Components". I can create the receipt for production in SAP Business One Client, but I can not successfully save one using the SAP Business One SDK.
Basically we have a disassembly production order on "item A" which will be consumed to make "item B".
In SAP Business One Client, I click on "Receipt from Production", then click "Return Components", I enter in the production order ID and the appropriate components (Item B) show in the "Contents" tab.
In the SAP Business One SDK, when I assign a BaseEntry and BaseType to my Line for the Goods Receipt document, I can no longer assign an ItemCode to the line.
If I open SAP Business One client, and then "Receipt from Production" and do not click "Return Components" but just enter in my production order ID, I get the same thing. "Item A" will show up in the contents tab lines, instead of "Item B".
When I try to add an ItemCode in code (to over-ride the default selected item, "Item A" to "Item B") I get this error "The field should be empty if the document is referenced to a production order. [IGN1.ItemCode][line: 0]".
If I remove the line assigning the item code, I get this error "Referenced work order type cannot be Disassembly [OIGN.DocStatus][line: 1]".
The code I wrote is below.
So how can I, through the SAP Business One SDK, simulate a "Receipt from Production" with a "Return Components" on a disassembly production order? Keep in mind, I can do this successfully in the SAP Business One Client. I am trying to do this through the SAP Business One SDK.
// Prepare a Goods Receipt document
SAPbobsCOM.Documents goodsReceiptProductionOrder = (SAPbobsCOM.Documents)_SBO_Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInventoryGenEntry);
// Add information to the goods receipt document
goodsReceiptProductionOrder.DocDate = documentDate;
goodsReceiptProductionOrder.DocDueDate = documentDate;
goodsReceiptProductionOrder.DocType = SAPbobsCOM.BoDocumentTypes.dDocument_Items;
goodsReceiptProductionOrder.DocNum = NextDocNumber;
goodsReceiptProductionOrder.JournalMemo = "Receipt from Production";
// Add information about the production order
goodsReceiptProductionOrder.Lines.BaseEntry = productionOrderKey;
goodsReceiptProductionOrder.Lines.BaseType = 202;
// Add information about the item we are receiving
goodsReceiptProductionOrder.Lines.ItemCode = GI_Line.ItemCode;
goodsReceiptProductionOrder.Lines.Price = 0;
goodsReceiptProductionOrder.Lines.TransactionType = SAPbobsCOM.BoTransactionTypeEnum.botrntComplete;
goodsReceiptProductionOrder.Lines.Quantity = GI_Line.Quantity;
goodsReceiptProductionOrder.Lines.WarehouseCode = GI_Line.WarehouseCode;
// Add the line to the Goods Receipt
goodsReceiptProductionOrder.Lines.Add();
// Attempt to add the new item to the database
int ResponseCode = goodsReceiptProductionOrder.Add();