Bar Codes:

A barcode is an optical, machine-readable, representation of data; the data usually describes something about the object that carries the barcode.

In SAP Business One, you can use the Bar Codes window (Inventory → Bar Codes) to define Bar Codes for your items. Multiple bar codes are allowed for each single UoM of an item.

For more information on Bar Codes in SAP Business One, you can refer to following link:

http://help.sap.com/saphelp_sbo92/helpdata/en/e4/356617d8614e70a8fa4a1e204a0bb3/content.htm?frameset=/en/44/c4c1cd7ca22e17e10000000a114a6b/frameset.htm&current_toc=/en/b1/8fe14910cf46b9b2ff2de2f315e5a2/plain.htm&node_id=1492&show_children=false

Using Bar Code in SAP Business One SDK:

Bar Code is exposed a Service Type Object (BarCodesService) in SAP Business One SDK. You can use it following ways using DI API:

Create a Bar Code for an Item using DI API:

SAPbobsCOM.ICompanyService oCompanyService = (SAPbobsCOM.ICompanyService)oCompany.GetCompanyService();
SAPbobsCOM.BarCodesService oBarCodesService = (SAPbobsCOM.BarCodesService)oCompanyService.GetBusinessServiceSAPbobsCOM.ServiceTypes.BarCodesService);
SAPbobsCOM.BarCode oBarCode = (SAPbobsCOM.BarCode)oBarCodesService.GetDataInterface(BarCodesServiceDataInterfaces.bsBarCode);
SAPbobsCOM.BarCodeParams oBarCodeParams;
oBarCode.ItemNo = "A00002";
oBarCode.BarCode = "BA0002";
oBarCode.FreeText = "BarCode creation Using DI API";
oBarCode.UoMEntry = 3; //You need to provide 'UomEntry' from 'OUOM' table.
oBarCodesService.Add(oBarCode);

Update a Bar Code for an Item using DI API:

SAPbobsCOM.ICompanyService oCompanyService = (SAPbobsCOM.ICompanyService)oCompany.GetCompanyService();
SAPbobsCOM.BarCodesService oBarCodesService = (SAPbobsCOM.BarCodesService)oCompanyService.GetBusinessService(SAPbobsCOM.ServiceTypes.BarCodesService);
SAPbobsCOM.BarCode oBarCode = (SAPbobsCOM.BarCode)oBarCodesService.GetDataInterface(BarCodesServiceDataInterfaces.bsBarCode);
SAPbobsCOM.BarCodeParams oBarCodeParams;
oBarCodeParams = (SAPbobsCOM.BarCodeParams)oBarCodesService.GetDataInterface(BarCodesServiceDataInterfaces.bsBarCodeParams);
oBarCode = (SAPbobsCOM.BarCode)oBarCodesService.GetDataInterface(BarCodesServiceDataInterfaces.bsBarCode);
oBarCodeParams.AbsEntry = 11;
oBarCode = oBarCodesService.Get(oBarCodeParams);
oBarCode.ItemNo = "A00002";
oBarCode.BarCode = "BA0002";
oBarCode.UoMEntry = 3; //You need to provide 'UomEntry' from 'OUOM' table.
oBarCode.FreeText = "";
oBarCodesService.Update(oBarCode);

Delete a Bar Code using DI API:

SAPbobsCOM.ICompanyService oCompanyService = (SAPbobsCOM.ICompanyService)oCompany.GetCompanyService();
SAPbobsCOM.BarCodesService oBarCodesService = (SAPbobsCOM.BarCodesService)oCompanyService.GetBusinessService(SAPbobsCOM.ServiceTypes.BarCodesService);
SAPbobsCOM.BarCode oBarCode = (SAPbobsCOM.BarCode)oBarCodesService.GetDataInterface(BarCodesServiceDataInterfaces.bsBarCode);
SAPbobsCOM.BarCodeParams oBarCodeParams;
oBarCodeParams = (SAPbobsCOM.BarCodeParams)oBarCodesService.GetDataInterface(BarCodesServiceDataInterfaces.bsBarCodeParams);
oBarCode = (SAPbobsCOM.BarCode)oBarCodesService.GetDataInterface(BarCodesServiceDataInterfaces.bsBarCode);
oBarCodeParams.AbsEntry = 11; //You need to provide 'BcdEntry' from 'OBCD' table.
oBarCodesService.Delete(oBarCodeParams);
To report this post you need to login first.

6 Comments

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

  1. Uriel Irigoyen

    Thanks for the code although I can implement it, I have some doubts What is the function of SAPbobsCOM.BarCodeParams oBarCodeParams in Add fuction?.

     

    (0) 
    1. ANKIT CHAUHAN Post author

      Hi Uriel,

      BarCodeParams  holds the key to an existing bar code. This object is used to pass keys to and retrieve keys from BarCodesService methods.

      Although , it is not being used in Add method above.

      Kind regards,

      ANKIT CHAUHAN

      SAP SME Support

       

      (0) 
  2. Uriel Irigoyen

    Thanks ANKIT CHAUHAN

     

    Mr. Ankit Chauhan the example you are presenting here is not working for me! I have no idea why and i’m trying to figure that out. I was wondering if you have a manual or a link where i can access the manual you used for this example.

     

    (0) 
  3. ANKIT CHAUHAN Post author

    Hi Uriel,

    The provided sample is working for me in a DEMO Database on SAP Business One Version 9.2 PL07. The purpose of this post was to make it available for the partners/customers/SAP Users because it is not included in the SDK Help Center.

    Hopefully, it will be included soon in the SDK Help. Meanwhile, could you please try to post your sample code and the error message that you are getting?

    Kind regards,

    ANKIT CHAUHAN

    SAP SME Support

    (0) 
    1. Uriel Irigoyen

      Hi ANKIt

      The sample not work for me, the problem is my version SAP. the sample dont working in SAP 9.1 PL11

      This line does not work: SAPbobsCOM.ICompanyService oCompanyService = (SAPbobsCOM.ICompanyService)oCompany.GetCompanyService();

      Change line code for:   SAPbobsCOM.CompanyService oCompanyService = aSAP.CoEmpresa.GetCompanyService();

       

      (0) 
      1. ANKIT CHAUHAN Post author

        Hi Uriel,

        Definitely, a problem with your code only. It is working for me on SAP Business One Version 9.1 PL11.

        Would recommend you to go through with your code again.

        Kind regards,

        ANKIT CHAUHAN

        SAP SME Support

        (0) 

Leave a Reply