cancel
Showing results for 
Search instead for 
Did you mean: 

add unit of measure group definition through SDK

0 Kudos

Good day experts,

I'm trying to add units of measurements Group Definition through SDK.

I have data on my OUGP table, and I want to add some data to the UGP1.

My code so far

SAPbobsCOM.IUnitOfMeasurementGroupsService uomg_service = _oCompany.GetCompanyService().GetBusinessService(SAPbobsCOM.ServiceTypes.UnitOfMeasurementGroupsService);

SAPbobsCOM.UnitOfMeasurementGroup uomg = uomg_service.GetDataInterface(SAPbobsCOM.UnitOfMeasurementGroupsServiceDataInterfaces.uomgsUnitOfMeasurementGroup);

SAPbobsCOM.UoMGroupDefinition collection = uomg_service.GetDataInterface(SAPbobsCOM.UnitOfMeasurementGroupsServiceDataInterfaces.uomgsUnitOfMeasurementGroup);

uomg.GroupDefinitions.Add();
uomg.GroupDefinitions.Item(coleccion).AlternateUoM = 3;

However this line of code works uomg.GroupDefinitions.Item(coleccion) for an existing item...

Also the SDK tells me for the add method that I must update the group definition parent

any ideas?

Accepted Solutions (0)

Answers (2)

Answers (2)

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi alf.matute and delapec,

Add a UoM Group:

SAPbobsCOM.CompanyService oCompService = oCompany.GetCompanyService();
SAPbobsCOM.UnitOfMeasurementGroupsService oUoMGroupService = (SAPbobsCOM.UnitOfMeasurementGroupsService)oCompService.GetBusinessService(SAPbobsCOM.ServiceTypes.UnitOfMeasurementGroupsService);
SAPbobsCOM.UnitOfMeasurementGroup oUoMGroup = (SAPbobsCOM.UnitOfMeasurementGroup)oUoMGroupService.GetDataInterface(SAPbobsCOM.UnitOfMeasurementGroupsServiceDataInterfaces.uomgsUnitOfMeasurementGroup);
oUoMGroup.Code = "TEST";
oUoMGroup.Name = "TEST UOM";
oUoMGroup.BaseUoM = 9;
SAPbobsCOM.UnitOfMeasurementGroupParams oGrpParams = oUoMGroupService.Add(oUoMGroup);

Update an existing UoM Group:

SAPbobsCOM.CompanyService oComService = oCompany.GetCompanyService();
SAPbobsCOM.UnitOfMeasurementGroupsService oUmGrpService = oComService.GetBusinessService(SAPbobsCOM.ServiceTypes.UnitOfMeasurementGroupsService);
SAPbobsCOM.UnitOfMeasurementGroup oUomGroup = (SAPbobsCOM.UnitOfMeasurementGroup)oUmGrpService.GetDataInterface(SAPbobsCOM.UnitOfMeasurementGroupsServiceDataInterfaces.uomgsUnitOfMeasurementGroup);
SAPbobsCOM.UnitOfMeasurementGroupParams oUomParam = (SAPbobsCOM.UnitOfMeasurementGroupParams)oUmGrpService.GetDataInterface(SAPbobsCOM.UnitOfMeasurementGroupsServiceDataInterfaces.uomgsUnitOfMeasurementGroupParams);

oUomParam.AbsEntry = 4;
oUomGroup = oUmGrpService.Get(oUomParam);
oUomGroup.Code = "Test";
oUomGroup.Name = "Test2";
oUomGroup.BaseUoM = 8;
oUmGrpService.Update(oUomGroup);

Hope it helps!

Kind regards,

ANKIT CHAUHAN

SAP Business One Support

delapec
Discoverer
0 Kudos

Hola Luis, pudiste resolverlo?

Gracias!