Skip to Content
0

Adding AR Invoice with BOM and Bins via DI-API

Mar 08, 2017 at 02:21 AM

190

avatar image

Hi everyone,

I'm trying to create AR Invoices with Kits and assigning bin location to the child items, but it seems that I'm missing something.

To reproduce it on the Demo DB (SAP Version: 9.1 PL09 and SQL Server 2012):

- Create a new Item "PARENT" as a sales & non stock

- Create the Bill of material with child items: C00001 & C00002; warehouse 05

- For warehouse 05, tab "Bin Locations", change the field: Auto Alloc on Issue to "Single Choice"

- Optional: Transfer stock to Bin: 05-A01-S01-L01 for items C00001 & C00002; (fyi: BinAbsEntry=2)

Simplified code:

SAP_Document = (SAPbobsCOM.Documents) ocompany.GetBusinessObject((BoObjectTypes)SAPbobsCOM.BoObjectTypes.oInvoices); SAP_Document.CardCode = "C20000";

SAP_Document.Lines.ItemCode = "PARENT"; // BOM Parent

SAP_Document.Lines.Quantity = 1;

SAP_Document.Lines.WarehouseCode = "05"; SAP_Document.Lines.BinAllocations.Quantity = 1; SAP_Document.Lines.BinAllocations.BinAbsEntry = 2; SAP_Document.Lines.BinAllocations.BaseLineNumber = 1; // Invoice Line Child C00001 SAP_Document.Lines.BinAllocations.Add();

SAP_Document.Lines.BinAllocations.Quantity = 1; SAP_Document.Lines.BinAllocations.BinAbsEntry = 2; SAP_Document.Lines.BinAllocations.BaseLineNumber = 2; // Invoice Line Child C00002

int Result = SAP_Document.Add();

string Error = ocompany.GetLastErrorDescription();

If I run the script without the BinAllocations section, I receive the error: "1470000341 - Fully allocate item \"C00001\" to bin locations in warehouse \"05\"" -> which is correct

If I run the script using the first three lines of the BinAllocation section (Quantity, BinAbsEntry and BaseLineNumber), then I receive the error: "1470000341 - Fully allocate item \"C00002\" to bin locations in warehouse \"05\"" -> which is correct, I have successfully assigned the bin for the first child, pending to assign the bin for the second child.

If I run the script using all the code, then I receive the error: External component has thrown an exception.

I have tried multiple options (BinAllocation.Add; Lines.Add, SetCurrentLine, etc); but I have been unable to create the document.

Note.- I have been able to create the document using DTW (DocumentLinesBinAllocation) with the same data, including BaseLineNumber 1 & 2.

Does someone know how to fix this problem?

Regards,

Hugo

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

0 Answers