on 10-14-2013 2:49 PM
Hi all,
I have document UDO with Document and document LineTable (For Eg: [@OPRD] AND [@PRD1])
I have successfully added the record in UDO using DI API.
But how to update and remove record using DI API.
Please give me some suggestion.
Hi Pravin,
User the GeneralService.
(Remove)
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)
(Update)
Dim oGeneralService As SAPbobsCOM.GeneralService
Dim oGeneralData As SAPbobsCOM.GeneralData
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")
'Get UDO record
oGeneralParams = oGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralDataParams)
oGeneralParams.SetProperty("DocEntry", "2")
oGeneralData = oGeneralService.GetByParams(oGeneralParams)
'Update UDO record
oGeneralData.SetProperty("U_Room", "2")
oGeneralData.SetProperty("U_Price", "40")
oGeneralData.SetProperty("U_Name", "Guy")
oGeneralService.Update(oGeneralData)
More info is in the SDK Help Center (type GeneralService in the search box).
Best regards,
Pedro Magueija
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanx Pedro for your reply.
Please help me in removing particular row of child table.
SAPbobsCOM.Recordset orec;
SAPbobsCOM.GeneralService oGeneralService = null;
SAPbobsCOM.GeneralData oGeneralData = null;
SAPbobsCOM.CompanyService oCompanyService = null;
SAPbobsCOM.GeneralDataCollection oDocLinesCollection;
SAPbobsCOM.GeneralData oDocLineGeneralData;
oCompanyService = globals_Renamed.oCompany.GetCompanyService();
oGeneralService = oCompanyService.GetGeneralService("PRJEST");
SAPbobsCOM.GeneralDataParams oGeneralParams;
oGeneralData = ((SAPbobsCOM.GeneralData)(oGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralData)));
oGeneralParams = oGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralDataParams);
oGeneralParams.SetProperty("DocEntry", DocEntry);
oGeneralData = oGeneralService.GetByParams(oGeneralParams);
oDocLineGeneralData = (SAPbobsCOM.GeneralData)oGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralData);
oDocLinesCollection = oDocLineGeneralData.Child("PRJEST1");
oDocLinesCollection.Remove(oDAL.EditRowNo);
oGeneralService.Update(oGeneralData);
My code is giving me error.
Invalid row Number
HI PRAVIN TRY THIS ONE YOU CAN GET AN IDEA...
Hi Pravin,
The Remove method takes the index of the line on the collection. You should check where the line that you want to delete is in the collection, then use that index with Remove.
oDocLinesCollection.Remove(2); // would the delete the second (or third if the index is 0-based) row of the collection
That does not mean the LineId is 2. You can have a line with ID 2 and be the first one in the collection, if the others have previously been deleted.
Best regards,
Pedro Magueija
Thanks Pedro, it worked. It appears that i did not include the Delete upon registering, to avoid having the user messing around with data. Code Worked.
C# code based on Pedro's Post:
SAPbobsCOM.GeneralService oGeneralService;
SAPbobsCOM.GeneralDataParams oGeneralParams;
SAPbobsCOM.CompanyService sCmp;
sCmp = Globals.oCompany.GetCompanyService();
//Get a handle to the SM_MOR UDO
oGeneralService = sCmp.GetGeneralService("ENTER YOUR UDO ID");
//Delete UDO record
oGeneralParams = (SAPbobsCOM.GeneralDataParams)oGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralDataParams);
oGeneralParams.SetProperty("DocEntry", "2"); //← Deleting 2nd record
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
106 | |
14 | |
10 | |
5 | |
4 | |
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.