Skip to main content

Notifications

Announcements

No record found.

Business Central forum
Suggested answer

CAL coding , Navision 2018

Posted on by 70

Need to extract the Container ID field from the Warehouse Entry table , I want it to print as label and as well as barcode separately , both as separate fields . I want it as code please . 

Categories:
  • Yathish JR Profile Picture
    Yathish JR 70 on at
    RE: CAL coding , Navision 2018

    I want code for adding and extracting the Container ID field from the Warehouse Entry table please

  • Suggested answer
    Amit Baru Profile Picture
    Amit Baru 3,025 on at
    RE: CAL coding , Navision 2018

    Hi,

    Pls use two function for barcode generation.

    EAN13_10String(InputBarcode : Code[20]) : Text
    // In Separators '2' is used to identify line length for nicer look'n'feel
    LRSeparator := '202';
    CSeparator := '02020';
    Weight := '131313131313';

    // If barcode is already with Checksum digit at the end
    IF STRLEN(InputBarcode) = 13 THEN BEGIN
    EVALUATE(CheckDigit,COPYSTR(InputBarcode,13,1));
    CurrentBarcode := COPYSTR(InputBarcode,1,12);
    //Comparing checkdigit
    IF CheckDigit <> STRCHECKSUM(CurrentBarcode,Weight,10) THEN BEGIN
    ERROR(Text003);
    END;
    END ELSE BEGIN
    IF STRLEN(InputBarcode) <> 12 THEN
    ERROR(Text001,12);
    CurrentBarcode := InputBarcode;
    END;

    FOR Count := 1 TO STRLEN(CurrentBarcode) DO BEGIN
    //Checking if barcode constructed only of digits
    IF NOT (CurrentBarcode[Count] IN ['1','2','3','4','5','6','7','8','9','0']) THEN
    ERROR(Text002);
    END;

    //Initializing EAN13 structure
    InitEAN13Structure(Structure,Encoding);

    //Checkdigit again
    CheckDigit := STRCHECKSUM(CurrentBarcode,Weight,10);

    //Barcode to encode with checksum
    BarcodeWithCheckSum := COPYSTR(CurrentBarcode,2,STRLEN(CurrentBarcode)) + FORMAT(CheckDigit);

    //Structure to use (Left Part)
    EVALUATE(StructureIndex,FORMAT(CurrentBarcode[1]));
    StructureIndex := StructureIndex + 1;
    LeftStructure := Structure[StructureIndex];

    //Add Beginning lines
    EncodedBarcode := EncodedBarcode + LRSeparator;

    FOR Count := 1 TO STRLEN(BarcodeWithCheckSum) DO BEGIN
    //Add Middle Lines
    IF Count = 7 THEN BEGIN
    EncodedBarcode := EncodedBarcode + CSeparator;
    END;
    //Getting Barcode digit by index
    EVALUATE(NumberEval,FORMAT(BarcodeWithCheckSum[Count]));

    IF Count <= 6 THEN BEGIN
    //Left Part
    CASE LeftStructure[Count] OF
    'L': EncodedBarcode := EncodedBarcode + Encoding[NumberEval + 1][1];
    'G': EncodedBarcode := EncodedBarcode + Encoding[NumberEval + 1][2];
    END;
    END ELSE BEGIN
    //Right Part
    EncodedBarcode := EncodedBarcode + Encoding[NumberEval + 1][3];
    END;

    END;

    //Ending Lines
    EncodedBarcode := EncodedBarcode + LRSeparator;

    EXIT(EncodedBarcode);

    LOCAL InitEAN13Structure(VAR Structures : ARRAY [10] OF Text[6];VAR Encodings : ARRAY [10,3] OF Text[7])
    Structures[1] := 'LLLLLL';
    Structures[2] := 'LLGLGG';
    Structures[3] := 'LLGGLG';
    Structures[4] := 'LLGGGL';
    Structures[5] := 'LGLLGG';
    Structures[6] := 'LGGLLG';
    Structures[7] := 'LGGGLL';
    Structures[8] := 'LGLGLG';
    Structures[9] := 'LGLGGL';
    Structures[10] := 'LGGLGL';

    Encodings[1][1] := '0001101';
    Encodings[1][2] := '0100111';
    Encodings[1][3] := '1110010';
    Encodings[2][1] := '0011001';
    Encodings[2][2] := '0110011';
    Encodings[2][3] := '1100110';
    Encodings[3][1] := '0010011';
    Encodings[3][2] := '0011011';
    Encodings[3][3] := '1101100';
    Encodings[4][1] := '0111101';
    Encodings[4][2] := '0100001';
    Encodings[4][3] := '1000010';
    Encodings[5][1] := '0100011';
    Encodings[5][2] := '0011101';
    Encodings[5][3] := '1011100';
    Encodings[6][1] := '0110001';
    Encodings[6][2] := '0111001';
    Encodings[6][3] := '1001110';
    Encodings[7][1] := '0101111';
    Encodings[7][2] := '0000101';
    Encodings[7][3] := '1010000';
    Encodings[8][1] := '0111011';
    Encodings[8][2] := '0010001';
    Encodings[8][3] := '1000100';
    Encodings[9][1] := '0110111';
    Encodings[9][2] := '0001001';
    Encodings[9][3] := '1001000';
    Encodings[10][1] := '0001011';
    Encodings[10][2] := '0010111';
    Encodings[10][3] := '1110100';

    https://erpconsultors.com/generate-barcode-in-business-central/

    Regards

    Amit Sharma

    www.erpconsultors.com

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,532 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,501 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans