cancel
Showing results for 
Search instead for 
Did you mean: 

oOrders Update() - error 1004

Lech
Discoverer
0 Kudos

Hi Everyone

To our application we are importing the Sale Order created in SAP.
When Sale Order is filled and ready to be send we are creating delivery document and sending it to SAP.
If one of the conditions is meet, I want to update the oOrders, one user field with value "Y". But when Update() is called I am getting error -1004 (the field I am trying to pass that value have not defined valid values). Below sample of the code.

 

//Update SAP
int erpDocEntry = mHelper.ConvertToInt32(dt.Rows[0]["ERP_DocEntry"]);
int erpDocLine = mHelper.ConvertToInt32(dt.Rows[0]["ERP_LineNum"]);

SAPbobsCOM.Documents sapSo = mObjects.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oOrders);
sapSo.GetByKey(erpDocEntry);
if (sapSo != null && sapSo.Lines.Count > 0)
{
    for (int j = 0; j < sapSo.Lines.Count; j++)
    {
        sapSo.Lines.SetCurrentLine(j);
        if (sapSo.Lines.LineNum == erpDocLine)
        {
            sapSo.Lines.UserFields.Fields.Item("U_DEM_NA").Value = "Y";
            int errUpdatingSO = sapSo.Update();
            if (errUpdatingSO != 0)
            {
               ErrCode = RetVal;
               mObjects.oCompany.GetLastError(out errUpdatingSO, out ErrMsg);
               TransLog.Fail((ErrMsg));
               Logger.Error(_retValue);
            }
            break;
        }
    }
}

Error at line 15: sapSo.Update();
error 1004

Also, I am new here and posting this here in the ERP Q&A.
Could you please confirm this is the best place to post questions with this subject?
And if there is a better place, can you please give details where.
Thanks all.

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Lech,

Yes, it is the correct place to post your question related to SAP Business One.

Can you please help to share the error message which you are getting?

You can get it using: string Error = oCompany.GetLastErrorDescription();

Kind regards,

ANKIT CHAUHAN

SAP Business One Support

View Entire Topic
ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Lech,

As I suspected, this issue is caused by some database corruption.

If you want to get it investigated, kindly create an incident for SAP Business One Support Team under the component SBO-SDK-DI.

Kindly mention the link of this discussion while creating the incident.

Kind regards,

ANKIT CHAUHAN

SAP Business One Support