cancel
Showing results for 
Search instead for 
Did you mean: 

SAP Business One , Invoice Posting from SDK

Former Member
0 Kudos

SAP Business One , Invoice Posting from SDK

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Dickson,

              Dim oINV As SAPbobsCOM.Documents

            oINV = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices)

oINV.CardCode = "TEST"

oINV.Add

Regards,

Former Member
0 Kudos

Where is this DDL ?  I have downloaded the SDK , I also need to post the Invoice Lines, am using C#.NET VS 2010   Do you have a more a detailed sample code ?  Please help  Thank you .

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Dickson,

Go to your project properties, Add Reference, In COM tab there is a reference SAPbobsCOM. Use it. For entering the data.

Try this.

SAPbobsCOM.Documents Oje = (SAPbobsCOM.JournalEntries)SBO_Company.GetBusinessObject(BoObjectTypes.oInvoices);

                                SAPbobsCOM.Recordset oRecSet = (Recordset)this.SBO_Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);

                                string updating = "select U_IntlTtl from [@ChallanMaster] where U_TotalC1 = '" + ChallanNum + "'";

                                oRecSet.DoQuery(updating);

                                while (oRecSet.EoF == false)

                                {

                                    double Amount = Convert.ToDouble(oRecSet.Fields.Item("U_IntlTtl").Value); // This is for if you have any UDF

                                    Oje.Reference3 = ChallanNum;

                                   Oje.Lines.AccountCode = "CH0000ALL";

                                    Oje.Lines.Credit = Amount;

                                    Oje.Lines.Add();

                                    Oje.Lines.AccountCode = "LP0000ALL";

                                    Oje.Lines.Debit = Amount;

                                    Oje.Lines.Add();

                                    int ith = 0;

                                    try

                                    {

                                        ith = Oje.Add();

                                        if (ith != 0)

                                        {

                                            int irrcode;

                                            string errmsg;

                                            SBO_Company.GetLastError(out irrcode, out errmsg);

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

                                        }

                                    }

                                    catch (Exception ex)

                                    {

                                        Program.oMainSAPDI.ShowMessage(ex.Message, BoStatusBarMessageType.smt_Error);

                                    }

This code was for entering the data into Journal Entry through DIAPI. For invoices you can use Highlighted part above. While the other highlighted part is for entering the data into matrix line.

Hope it helps

Thanks

Former Member
0 Kudos

Thank, i have the DDL Now, and have just declare some variables ( Invoice Document ).  Seems like what you have given me is a journal entry .  What an Invoice and InvoiceLine post ?   Where do i configure the connection properties to SAP ?

Former Member
0 Kudos

oCompany is a varibale you had declared ?  SAPbobsCOM.Documents oINV = default(SAPbobsCOM.Documents);  oINV = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices);  It highlights the " oCompany "

Johan_H
Active Contributor
0 Kudos

Hi Dickson,

With the SDK come a set of examples for all basic operations. If you have installed the SDK, look for this path: C:\Program Files\SAP\SAP Business One SDK\Samples\COM DI\CSharp

You will find examples for connecting to the company object, how to create documents, etc, etc.

Ankit already gave you ready code. For all documents the principles are the same. In his code, just replace JournalEntries with Invoices

Regards,

Johan

Former Member
0 Kudos

Thank you ,  If stuck i will let you know ,

Former Member
0 Kudos

Something have not installed ? because i can't see samples .

Johan_H
Active Contributor
0 Kudos

If you installed the SDK installation package, then the correct link should be in your All Programs menu.

Start Menu > All Programs > SAP Business One > SDK

Former Member
0 Kudos

am doing very ok now .  infact i only have one item remaining the i post to SAP .  how do i handle IDocument_Lines ?

Former Member
0 Kudos

Is it read only ? or i can assign LineNum for invoice lines ?

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Dickson,

The code that I have given you Oje.Lines.Add(); is handling the Document Lines automatically. You just try this and will get the desired result.

Thanks

Johan_H
Active Contributor
0 Kudos

You don't have to set the LineNum property. It gets set automatically.

If you want to return to a certain line, for some reason, you can use the SetCurrentLine(1-based index number) method.

Former Member
0 Kudos

Sorry for not been clear , i meant this .  See below .  oINV.Lines.ItemCode = redLines["ItemCode"].ToString();                       oINV.Lines.LineTotal = double.Parse(redLines["LineTotal"].ToString());                       oINV.Lines.Price = double.Parse(redLines["Price"].ToString());                       oINV.Lines.Quantity = int.Parse(redLines["Quantity"].ToString());                       oINV.Lines.VatGroup = redLines["VATGroup"].ToString();                       oINV.Lines.AccountCode = redLines["AccountCode"].ToString();                       //IDocument_Lines k = IDocument_Lines redLines["LineNum"].ToString();                       oINV.Lines.LineNum = redLines["LineNum"].ToString();                        oINV.Lines.Add();  The LineNum is underlined . How do i assign LinNum ?

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Dickson,

There is no need to assign LineNum.

Thanks

Former Member
0 Kudos

Ok.  But i am getting data from another system, that also handles credit notes , referencing to the Invoice Line items, and it has invoice lines LineNum assigned .   Sample code for getting the LineNum generated ?  Advice, or i just ignore that bit ?

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi,

Just ignore that bit, and send another data that you want.

Thanks

Former Member
0 Kudos

Thank you so far, my invoices are working fine .  Lastly it's about posting Payments, PaymentOnInvoice and PaymentCheques .  How do i hand this at the same time ?

Former Member
0 Kudos

Hi Dickson,

     Please create new thread, this thread already mark as answered.

Regards,

Former Member
Former Member
0 Kudos

I have created ,  Kindly and assist me address the challenge .  http://scn.sap.com/thread/3203711

Answers (0)