-1004 Data Source - Value Not Found

Marcel Kieboom

Hi there,





I was wondering if anyone could help me with the following problem.

Within the coresuite optimizer I listen to a Desinger LayoutDef Event.

When the event occurs, I want to submit a trackingnumber to a delivery document.

Here is my code:



[CODE]

SAPbobsCOM.Company oCompany = SwissAddonFramework.B1Connector.GetB1Connector().Company;

SAPbobsCOM.Documents oDelivery = (SAPbobsCOM.Documents) oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oDeliveryNotes);

DocEntry = Int32.Parse(pVal.ReportEvent.GeneralData.SubmittedParams.GetParameterValue("DocEntry"));

ObjType = Int32.Parse(pVal.ReportEvent.GeneralData.SubmittedParams.GetParameterValue("ObjType"));

oDelivery.GetByKey(DocEntry);

oDelivery.TrackingNumber = "My Tracking Number";

Error = oDelivery.Update();

[/CODE]



However in some cases, the Error variable will be filled with: -1004 which means: Data Source - Value Not Found.

This is actually the same when I want to update an Business Partner and fill a user defined field:



Does anyone know what the problem is?



[CODE]



SAPbobsCOM.Company oCompany = SwissAddonFramework.B1Connector.GetB1Connector().Company;

SAPbobsCOM.BusinessPartners oBP = (SAPbobsCOM.BusinessPartners) oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oBusinessPartners);

oBP.GetByKey("##CustmerNumber##");

oBP.UserFields.Fields.Item("U_UDF").Value = "MYVALUE";

result = oBP.Update();

[/CODE]



Our SAP Version: 8.81 PL 07

Coresuite version: 3.30





Thanks!



Kind regards,





Marcel

Paolo Manfrin

Hi Marcel,

as far as I know this seems to be due to the fact that DocEntry is not the right one.

Did you try to keep tract of such DocEntry before opening the report?



I would suggest to do



[CODE]

DocEntry = Int32.Parse(pVal.ReportEvent.GeneralData.SubmittedParams.GetParameterValue("DocEntry"));

SwissAddonFramework.Messaging.Debug.WriteMessage("Document Docentry: " + DocEntry.ToString(), SwissAddonFramework.Messaging.Debug.DebugLevel.Always);

[/CODE]



and when you detect which DocEntry is used try to replicate using such DocEntry.



Another issue I can see in your code is that you do not release the SAP object.

It is good practice to always finish your code with:



[CODE]

oBP = null;

GC.Collect();

[/CODE]



This is required due to the fact that SAP is not releasing properly all the objects in memory and when you have heavy usage the memory might be leaking generating such kind of errors.

I experienced this when updating huge amount of data.



hth

paolo
0

Comments

0 comments

Please sign in to leave a comment.

Didn't find what you were looking for?

New post