on 02-29-2024 9:27 AM
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.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I added what you asked for
This error message is about user defined field in the ORDR table, but in my original code i am trying to update value in the user defined field "U_DEM_NA" in the RDR1 table, which I am accessing from the ORDR object.
Am I right thinking I should first confirm I am setting the correct line when:
sapSo.Lines.SetCurrentLine(j);
Or can you see something else I cant?
Thank you very much for your help.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Lech,
From the first glance, there seems nothing wrong with your code.
To confirm, try to update any other field on header for example: NumAtCard property in DI code (Customer Ref. No. on Sales Order form) and check whether you have the same error message.
If yes, I feel that it is caused by some DB corruption.
Kind regards,
ANKIT CHAUHAN
SAP Business One Support
Hey Ankit
What I did I commented the line where trying to update value.
So what is really happening is I am getting the sale order object, not changing any values and updating it.
But this gives the same error
For now, thanks for your help. I will try something else or with different database.
Thanks again.
User | Count |
---|---|
107 | |
12 | |
10 | |
5 | |
5 | |
3 | |
3 | |
3 | |
3 | |
2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.