on 06-30-2017 11:14 AM - last edited on 02-03-2024 8:37 PM by postmig_api_4
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
101 | |
12 | |
11 | |
6 | |
6 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.