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

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply