Hello Everyone,

Sample code to Update existing Item Batches Properties via DI API: Below is a sample C# code I wrote for updating an existing Item Batches properties for SAP 9.1.

private static void BatchUpdate()

{

SAPbobsCOM.CompanyService oCompanyService;

oCompanyService = oCompany.GetCompanyService();

SAPbobsCOM.BatchNumberDetailsService oBatchNumbersService;

oBatchNumbersService = oCompanyService.GetBusinessService(SAPbobsCOM.ServiceTypes.BatchNumberDetailsService);

SAPbobsCOM.BatchNumberDetailParams oBatchNumberDetailParams;

oBatchNumberDetailParams = oBatchNumbersService.GetDataInterface(SAPbobsCOM.BatchNumberDetailsServiceDataInterfaces.bndsBatchNumberDetailParams);

try

{

int docentry = 81; //Put here the actual AbsEntry of the Batchnumber record from table OBTN

oBatchNumberDetailParams.DocEntry = docentry;

SAPbobsCOM.BatchNumberDetail oBatchNumberDetail;

oBatchNumberDetail = oBatchNumbersService.Get(oBatchNumberDetailParams);

oBatchNumberDetail.BatchAttribute1 = “W1F”;

oBatchNumberDetail.UserFields.Item(“U_PalletID”).Value = “45109-07”;

oBatchNumbersService.Update(oBatchNumberDetail);

System.Runtime.InteropServices.Marshal.ReleaseComObject(oBatchNumberDetail);

}

catch (Exception e)

{

gApp.MessageBox(“An unknown error occurred in method BatchUpdate.

” + e.ToString(), 1, “Ok”, “”, “”);

}

finally

{

System.Runtime.InteropServices.Marshal.ReleaseComObject(oCompanyService);

System.Runtime.InteropServices.Marshal.ReleaseComObject(oBatchNumbersService);

System.Runtime.InteropServices.Marshal.ReleaseComObject(oBatchNumberDetailParams);

}

}

Hope this helps some of you

Regards,

Krishnan

New NetWeaver Information at SAP.com

Very Helpfull

 

 

User Rating: Be the first one !