creating a receipt of invoice with BOI

SOLVED

Hi, I'm trying to write a code to create a new invoice from PO

  1. set the key ReceiptType$
  2. set the key ReceiptNo$
  3. call setKey()
  4. set PurchaseOrderNo$
  5. set InvoiceNo$

Now i want to add the lines of the po to the receipt. In addition, i want it to be multiple POs.

I'm trying to use ApplyPurchaseOrderAdd, but it fails when I try to apply a PO which is full (fully received and invoiced), even though in Sage itself I can add this PO and invoice more than the ordered.

If I use ApplyPurchaseOrderUpdate, sam problem

If I use CopyPurchaseOrderLines it adds the lines, but makes the receipt as a single PO (the field MultiplePurchaseOrdersApplied$ will be "N", and it's read only so I can't set it), and also I get an error if i call this method with the PO number i used in step (4) above

how can I do what I want? and also, what is the difference between CopyFromPurchaseOrder to CopyPurchaseOrderLines?

Thank you in advance