Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Getting error (-4006) while creating a Journal Entry through DI API in C#

Hi,

I am trying to create a Journal Entry through SAP B1 DI API in ASP.Net using C#. In the form, I have a button. I have written the code for creating a Journal Entry to the OnClick event of that button. The required field Value (for objects) I have passed for both header level as well as Line Level.

But I am getting the error code (- 4006) where the Description is "update exchange rates".

I am sharing the Code here for better understanding.

SAPbobsCOM.Company ocompany = new SAPbobsCOM.Company();

            if (sapcon.ConnectSAPCompany(ref ocompany) == true)

            {

                try

                {

                    SAPbobsCOM.JournalEntries vJE = (SAPbobsCOM.JournalEntries)ocompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oJournalEntries);

                    sap_connection objSessionHelper = new sap_connection();

                    vJE.ReferenceDate = new DateTime(2015, 10, 25);

                    vJE.DueDate = new DateTime(2015, 10, 25);

                    vJE.TaxDate = new DateTime(2015, 10, 25);

                    vJE.Memo = "Test Message";

                   

                    vJE.TransactionCode = "INR";

                    vJE.Lines.BPLID = 235;

                    vJE.Lines.Credit = 3000;

                    vJE.Lines.Debit = 0;

                  

                   vJE.Lines.Add();

                    vJE.Lines.AccountCode = "700040";                   

                    vJE.Lines.Credit = 0;

                    vJE.Lines.Debit = 3000;

                  

                    vJE.Lines.Add();

                   

                    int i = vJE.Add();

                    if (i == 0)

                    {

                        ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('Journal Entry Created Successfully');", true);

                        return;

                    }

                    else

                    {

                        string des = ocompany.GetLastErrorDescription();

                        ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + des.ToString() + "');", true);

                    }

                }

                catch (Exception ex)

                {

                    ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + ex.ToString() + "');", true);

                }

            }

Any help is

Former Member
Not what you were looking for? View more on this topic or Ask a question