on 09-25-2014 6:28 PM
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();
did your problem solve ? because i am also facing the same problem.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I was not able to solve it through native SDK. I really hope one day someone helps me with a better solution, but I was able to create this terrible, terrible "work around".
I commented these lines:
goodsReceiptProductionOrder.Lines.BaseEntry = productionOrderKey;
goodsReceiptProductionOrder.Lines.BaseType = 202;
After commenting those lines, after the "ProductionOrder.Add();" line in my last example, run this SQL if the new document creation was successful:
// Attempt to add the goods issued document
if (ResponseCode != 0)
{
// Something went wrong and your Goods Receipt document was not created successfully.
return;
}
// The new "Goods Receipt" document was created successfully.
else
{
string newCode = null;
// Get the newly created "Goods Receipt" document code
_SBO_Company.GetNewObjectCode(out newCode);
if (newCode != null)
{
int NewlyCreatedKey = Convert.ToInt32(newCode);
// Run this SQL in order to update the "Goods Receipt" document as a "Receipt from Production" document.
string SQL = @"
UPDATE
[IGN1]
SET
[BaseRef] = @productionOrderKey
, [BaseType] = '202'
, [BaseEntry] = @productionOrderKey
, [TreeType] = 'N'
WHERE [DocEntry] = @NewlyCreatedKey";
// TODO: Run the SQL query here
}
}
I removed the code the actually run the SQL statement against the SQL database. You'll need to fill in that part yourself.
Hi Garrett Hampton,
I get the solution.
If you are creating the Return component against production order u do not need to add Item Code. you need to fill the BaseLine and BaseEntry fields, you cannot input the ItemCode. The DI API will do that automatically to ensure data integrity. you can try this by removing Item row
// Add information about the production order
goodsReceiptProductionOrder.Lines.BaseEntry = productionOrderKey;
goodsReceiptProductionOrder.Lines.BaseType = 202;
// Add information about the item we are receiving
goodsReceiptProductionOrder.Lines.BaseLine = LineNum In production Order Row table of that Item
goodsReceiptProductionOrder.Lines.TransactionType = SAPbobsCOM.BoTransactionTypeEnum.botrntComplete;
goodsReceiptProductionOrder.Lines.Quantity = GI_Line.Quantity;
goodsReceiptProductionOrder.Lines.WarehouseCode = GI_Line.WarehouseCode;
-Regard
Vikas
User | Count |
---|---|
89 | |
7 | |
7 | |
4 | |
4 | |
3 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.