cancel
Showing results for 
Search instead for 
Did you mean: 

Create an AP Invoice based on a Purchase Order using SDK

rajesh_khater
Active Participant
0 Kudos

Hi,

What are the steps to create an AP Invoice based on a Purchase Order using DI API?

Which methods of which objects to use and what parameters to pass?

Thanks.

Accepted Solutions (1)

Accepted Solutions (1)

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Rajesh,

Here is a sample to create an Invoice based on a Sales Order. The same way you can change as per your requirement:

SAPbobsCOM.Documents oInvoice = default(SAPbobsCOM.Documents);

            oInvoice = (SAPbobsCOM.Documents)SBO_Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices);

            oInvoice.CardCode = "C000003";

            oInvoice.DocDueDate = DateAndTime.Now;

            oInvoice.Lines.BaseType = Convert.ToInt32(SAPbobsCOM.BoObjectTypes.oOrders);

           oInvoice.Lines.BaseEntry = Convert.ToInt32(3616);

           oInvoice.Lines.BaseLine = 1;

            oInvoice.Lines.Quantity = 3;

            oInvoice.Lines.Add();

            oInvoice.Lines.BaseType = Convert.ToInt32(SAPbobsCOM.BoObjectTypes.oOrders);

            oInvoice.Lines.BaseEntry = Convert.ToInt32(3616);

            oInvoice.Lines.BaseLine = 2;

            int kth = 0;

            kth = oInvoice.Add();

            if (kth != 0)

            {

                int irrcode;

                string errmsg;

                SBO_Company.GetLastError(out irrcode, out errmsg);

                Program.oMainSAPDI.ShowMessage(errmsg, BoStatusBarMessageType.smt_Error);

            }

The main thing to remember is Base Type, Based Entry and Base Line.

Hope it helps.

Thanks & Regards

Ankit Chauhan

rajesh_khater
Active Participant
0 Kudos

Ok. This is helpful.

BaseEntry is the DocEntry of the Purchase Order, am I right?

And regarding BaseLine, if I have to replicate the SAP application functionality, do I have to loop through all the Lines in the Purchase Order, and set the BaseLine in AP Invoice?

Thanks.

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Rajesh,

Yes, Base Entry will be the DocEntry of the Purchase Order by which you want to create the A/P Invoice.

Also for Base Line you can loop through all lines or can pick the information in the SQL Query.

It totally depends on you that how do you want to achieve it.

Also once your problem is resolved please help to close the thread.

Thanks & Regards

Ankit Chauhan

rajesh_khater
Active Participant
0 Kudos

Problem solved Ankit and thread closed

Can you also look into some of my other threads, especially:

and

Thanks.

Answers (0)