cancel
Showing results for 
Search instead for 
Did you mean: 

Update/Delete UDO line

Former Member
0 Kudos

Hello everybody,

I would like to know how to update or delete a specific line on a user defined object through DI API

So far I have managed to

//get the UDO
oGeneralService = oCompanyService.GetGeneralService("someUserObject");
//select a specific line from header
oGeneralParams = (SAPbobsCOM.GeneralDataParams)oGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralDataParams);
oGeneralParams.SetProperty("DocEntry", 1);
oGeneralData = oGeneralService.GetByParams(oGeneralParams);
//select the lines table
oChildren = oGeneralData.Child("LinesTable");
//but when I try to get the specific line from line id I get an invalid row error
oChildren.Item(LineId).SetProperty(U_Field, "test");

//finally update our UDO,
oGeneralService.Update(oGeneralData);

If anyone could provide a correct way to go to a specific line of UDO's lines and edit/remove it I would be grateful.

Kind regards,

Dimitris Theotokatos

Accepted Solutions (1)

Accepted Solutions (1)

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi,

Have you been able to check this?

UDO Update Data

Kind regards,

ANKIT CHAUHAN

SAP SME Support

Former Member
0 Kudos

Hello Ankit,

thank you for your reply.

My issue is not selecting a specific line from the UDO's header but selecting and editing/removing a line from a UDO's selected header lines table.

Kind regards,

Dimitris Theotokatos

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi,

In the provided link, there is already a sample which shows you how to update data on a specific line.

If you do not have that requirement, kindly help to provide a screenshot.

Kind regards,

ANKIT CHAUHAN

SAP SME Support

Former Member
0 Kudos

In the link provided if I select one of the links on selected answer, I get an error Page Not Found!

Can you please provide the updated links to the answers?

Kind regards,

Dimitris Theotokatos

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi,

Following code is mentioned there in the link:

SAPbobsCOM.GeneralService oGeneralService = null;
SAPbobsCOM.GeneralData oGeneralData = null;
SAPbobsCOM.GeneralDataParams oGeneralParams = null;
SAPbobsCOM.CompanyService sCmp = null;
SAPbobsCOM.GeneralData oChild = null;
SAPbobsCOM.GeneralDataCollection oChildren = null;
sCmp = SBO_Company.GetCompanyService();
oGeneralService = sCmp.GetGeneralService("UDOCODE");
oGeneralParams = ((SAPbobsCOM.GeneralDataParams)(oGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralDataParams)));
oGeneralParams.SetProperty("Code", ANYCode);
oGeneralData = oGeneralService.GetByParams(oGeneralParams);
oChildren = oGeneralData.Child("DETAILTABLEOFUDO");
oChild = oChildren.Item(LineID - 1);
oChild.SetProperty("U_Field1", VALUETOSET1);
oChild.SetProperty("U_Field2", VALUETOSET2);
oGeneralService.Update(oGeneralData);

Kind regards,

ANKIT CHAUHAN

SAP SME Support

Former Member
0 Kudos

Solved my issue by using record number instead of line id in

oChildren.Item(LineId).SetProperty(U_Field, "test");

so the correct code looks like

oChildren.Item(line_count).SetProperty(U_Field, "test");

Thanks a lot for your help!

Answers (1)

Answers (1)

former_member233854
Active Contributor
0 Kudos

Hi,

See the code below, got from SDK help

Dim oGeneralService As SAPbobsCOM.GeneralService
Dim oGeneralParams As 
SAPbobsCOM.GeneralDataParams

Dim sCmp As SAPbobsCOM.CompanyService
sCmp = 
oCompany.GetCompanyService

'Get a handle to the 
SM_MOR UDO
oGeneralService = sCmp.GetGeneralService("SM_MOR")

'Delete UDO 
record
oGeneralParams = 
oGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralDataParams)
oGeneralParams.SetProperty("DocEntry", "2")
oGeneralService.Delete(oGeneralParams)
ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi,

In your Subject, you have asked for Update/Delete both. Therefore, the Update script was provided.

Anyways, great to know that the issue has been solved for you!

Kind regards,

ANKIT CHAUHAN

SAP SME Support