Barcode Solution in Tally - My first ever code

Discussion in 'Free Source Codes' started by Bhawna, Jul 21, 2019.

    
  1. Bhawna

    Bhawna Member


    Friends - I am glad to share that , I have put together a TDL for printing Barcode from Tally

    Please note -
    1) I have created the TDL for my specific requirement for Printing the Barocode on 2 Inch by 1 Inch Label (image attached) .
    2) This is the first code that I have ever written . I sourced the base code from TDL Expert forum (thanks to all members who guided me) , went through multiple TDL pdfs provided by tally and did lot of trial and error.
    3) I believe the code can be improved further and could be made flexible to Print Barcode on any Label Size. Experts - Please do pour in your suggestions


    Barcode Output.JPG

    Barcode Label Size2.JPG Barcode Label Size1.JPG



    Code:
    ;; Sri Ganeshji : Sri Balaji : Sri Pitreshwarji : Sri Durgaji : Sri Venkateshwara
    
    /*
    Objective(s) :-
    -    To Print Barcode for the Stock Items
    
    Specific TDL Feature(s) used :-
    -    Repeat attribute at Part Level
    -   Explode attribute at Line Level
    -   Creation of new Style using Bar coding Font ‘IDAutomationHC39S’
    -   User Defined Function to replace "" (Space) with "=" symbol as this font ‘IDAutomationHC39S’ treats "=" as space.
    
    Last Updation :-
    -    Altered on 17/06/2010
    */
    
    ;; Adding Label Printing Report to the already existing Report
    
    [#Form: Purchase Color]
    
        Add     : Print : TSPL FFE LabelPrint
    Add    : Button : TSPL FFE LabelPrint
    [Button : TSPL FFE LabelPrint]
        Action    :print Report: TSPL FFE LabelPrint
        Key        :ctrl+F6
    ;;Label Printing Report
    
    [Report: TSPL FFE LabelPrint]
    
        Form         : TSPL FFE LabelPrint
        Object         : Voucher
    
    [Form: TSPL FFE LabelPrint]
    
        Part         : TSPL FFE LabelPrint
        Width : 125 MMS
        FullHeight : Yes
    
    
    [Part: TSPL FFE LabelPrint]
    
        Parts         : TSPL FFE LabelPrint1,TSPL FFE LabelPrint2
         Vertical        :No
        
    
    
    [Part: TSPL FFE LabelPrint2]
    Use: TSPL FFE LabelPrint1
    
    
    [Part: TSPL FFE LabelPrint1]
    
        Line         : TSPL FFE LabelPrint
        Repeat         : TSPL FFE LabelPrint : Inventory Entries
        Scroll         : Vertical
    
    
        [Line: TSPL FFE LabelPrint]
    
            Field             : TSPL FFE StkItemLabel1, TSPL FFE StkItemLabel2
                    Explode         : TSPL FFENLine
            Explode         : TSPL FFE MoreLabels : $$Number:$BilledQty > 1
            Space Bottom        : .75
        
    
    [Field         : TSPL FFE StkItemLabel2]
    Use        : Name Field
    Set as      : $StockItemName
    Style        : Normal
    Inactive    : Yes
    
    
    [Part    : TSPL FFENLine]
    Lines    : TSPL FFENLine3, TSPL FFENLine2
    
    
    [Line    : TSPL FFENLine2]
    Fields    : TSPL FFE StkItemLabel2
    Local    : Field : TSPL FFE StkItemLabel2: Set as : $TSPLFEEStkAlias:StockItem:$StockItemName
    Local    : Field : TSPL FFE StkItemLabel2: Inactive: $$IsEven:$$ExplodeLevel+1
    Height    : 5 MM
    
    [Line    : TSPL FFENLine3]
    Fields    : Info Field, TSPL FFERate
    Local    : Field : Info Field : Info : "Rate: Rs "
    Local    : Field : Info Field : Inactive: $$IsEven:$$ExplodeLevel+1
    Height    : 5 MM
    
    
    
    [Field    : TSPL FFERate]
    Use        : Short Name Field
    Set as      : $StandardPrice:StockItem:$StockItemName
    Inactive    : $$IsEven:$$ExplodeLevel+1
    Style        : Normal Bold
    Width         : 100 MMS
    
    
    
    [Part: TSPL FFE MoreLabels]
    
        Line : TSPL FFE MoreLabels
    
    
        [Line: TSPL FFE MoreLabels]
    
            Field              : TSPL FFE StkItemLabel1
            Explode: TSPL FFENLine
            Explode         : TSPL FFE MoreLabels : $$Number:$BilledQty > ($$ExplodeLevel+$$Line) *2
            Space bottom    : .75
        
    
            [Field: TSPL FFE StkItemLabel1]
            
                Use                    : Name Field
                Set as                 : "(" + @TSPLFEEBarcodeLF + ")"
                TSPLFEEBarcodeLF     : $$TSPLFFEBarcodeString:@TSPLFEEStkName
                TSPLFEEStkName        : If $$IsEmpty:($TSPLFEEStkAlias:StockItem:$StockItemName) then $StockItemName  +
                                      else ($TSPLFEEStkAlias:StockItem:$StockItemName)
                Style                : TSPL FFE BarCode
                Width : 125 MMS
    
    
    [Style: TSPL FFE BarCode]
    
        Font        : IDAutomationHC39S
        Height      : 14
    
    
    
    [#Object: StockItem]
    
        TSPLFEEStkAlias    : $$Alias
    
    ;; Function to replace space with "="
    
    
    [Function: TSPL FFE BarcodeString]
    
        Parameter : TSPLFFEEBarcodeInput : String
     
        Variable  : TSPLFFE Temp             : String
        Variable  : TSPLFFE Count             : Number
        Variable  : TSPLFFEEBarcodeOutput     : String
    
        10 : Set     :    TSPLFFE Temp     : ""
        20 : FOR TOKEN : TSPL TokenVar : ##TSPLFFEEBarcodeInput : " "
        30 : Set : TSPLFFE Temp : ##TSPLFFETemp + $$String:##TSPLTokenVar + "="
        40 : END FOR
        50 : SET : TSPLFFE Count : $$StringLength:##TSPLFFETemp
        60 : SET : TSPLFFEEBarcodeOutput : $$StringPart:##TSPLFFETemp:0:(##TSPLFFECount-1)
        70 : RETURN : ##TSPLFFEEBarcodeOutput
    
    ;; End-of-File
    
     

    Attached Files:

    Last edited: Jul 21, 2019


  2. nasir

    nasir Member


    how
    can we print bar code in invoice printing thnx
     


  3. Bhawna

    Bhawna Member


    I believe , you might need to create a TDL for invoice with additional line for Barcode Font. I do not know how to write a code for it .
    One work around could be to paste the Label on Invoice but that would be too cumbersome

    Experts - please pour in your suggestions
     


  4. ONKAR

    ONKAR Active Member


    @Bhawna , congratulation, good keep it up.
     


  5. balajimg

    balajimg Active Member


    This code is actually provided by Tally Solutions Pvt. Ltd. for demo purpose
     
    JCTS likes this.


  6. ganeshgk

    ganeshgk Member


    i want small size barcode font plesae help anyone
     


Share This Page