Enterprise Resource Planning Blogs by Members
Gain new perspectives and knowledge about enterprise resource planning in blog posts from community members. Share your own comments and ERP insights today!
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member
0 Kudos
3,702

Hello Everyone,

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.\n\n" + 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

Labels in this area