Save data to UDT in customize function button rule
Hello Coresuite Community,
is there a way to add data to a UDT via code? I have created a function for calculating BOM and production order costs (material and ressources). The result of the calculation can be saved into a UDT. At the moment I found only the following way to save data to the UDT by code.
1. Open UDT by MenuItem.GetFromUID("UDT Menu ID").Activate();
2. Get Form and matrix of UDT
3. write data into UDT by SetValue()
This process is working but neither fast nor very clever solved.
Greetings Sebastian
-
Hallo Sebastian,
das geht mit dem General Service. Ich habe nur leider gerade kein Beispiel für ein UDT, nur für ein Objekt:SAPbobsCOM.GeneralService svc = SwissAddonFramework.B1Connector.GetB1Connector().Company.GetCompanyService().GetGeneralService("Dein UDO");
SAPbobsCOM.GeneralData data = (SAPbobsCOM.GeneralData) svc.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralData); data.SetProperty("Code", strNewSnr); data.SetProperty("Name", strNewSnr); data.SetProperty("U_C_DocNum", strDocNum); data.SetProperty("U_C_ItemCode", strItemCode);
data.SetProperty("U_C_ItemName", TextEdit.GetFromUID(pVal.Form, "8").Value); //3 if (iSnrAmount != 0)
data.SetProperty("U_C_Status", "nicht zugeordnet"); //3 else //4 data.SetProperty("U_C_Status", "zugeordnet"); //4 //SAPbobsCOM.GeneralData child = (SAPbobsCOM.GeneralData) svc.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralData); //2 wird gebraucht, falls UDFs in UDO-Child gefüllt werden müssen
SAPbobsCOM.GeneralDataCollection children = (SAPbobsCOM.GeneralDataCollection) data.Child("DeinUDOLine");for (int j = 0; j < iSnrAmount; j++) //2
children.Add(); //2
//2 child.SetProperty(); //wird gebraucht, falls Felder in Zeile gefüllt werden müssensvc.Add(data);
Ich hoffe das hilft Dir weiter.
Gruß
Daniel0 -
Hi Sebastian,
if it is “only” a UDT (not object) you could fill it by an Update/Insert query.
regards Lothar
0
Please sign in to leave a comment.
Comments
2 comments