Code 128 / GS1-128 in NAV 2016

mrettlermrettler Member Posts: 17
Hi there,
I'm struggeling in implementing a Code 128 C in Navision.
The code128 file comes from this site : http://www.dafont.com/de/code-128.font

Currently I'm not able to place the right Start,Stop and FNC1 Character in Navision. I searched the whole web for a solution but i couldnt find it.

If i use the normal ASCII charset for that it doesent work. http://www.adams1.com/128table.html

Does anyone ever had the same issues? Or does anyone build his own Code128C BarCode in Navision?

Thanks in advance :)

Answers

  • xStepaxStepa Member Posts: 106
    edited 2017-06-21
    Hi, Code128 is not only about the start/stop characters. Also if you have font from GrandZebu, you are using wrong char table. You can find the correct one here:
    grandzebu.net/informatique/codbar-en/code128.htm

    Tested in NAV and works fine.
    Regards
    xStepa
  • mrettlermrettler Member Posts: 17
    Hi xStepa, thanks for your answer! I'll check that and will give you a feedback.
  • mrettlermrettler Member Posts: 17
    So i tested it with your char table and Code A and Code B are working fine. But when i try to use Code C with some FNC1-Flags in it, im not able to read the BarCode with an App like "Barcode Scanner".

    Here is my Code:
    LOCAL EncodeBarcode(pText : Text[250]) RetVal : Text[250]
    StartChar:= 210;
    StopChar:= 211; 
    
    //Checksum start for Code C
    Checksum :=105;
    counter :=0;
    FOR i:=1 TO STRLEN(pText) DO BEGIN
      counter += 1;
      //Check if Char is FNC1
      IF pText[i] <> 207 THEN BEGIN
        currenttxt:= STRSUBSTNO('%1%2',pText[i],pText[i+1]);
        EVALUATE(ChecksumInt, currenttxt);
        Checksum := Checksum +(counter * ChecksumInt); 
        i+=1;
      END 
      ELSE BEGIN
        Checksum := Checksum +(counter * 102); 
      END;
    END;
    ChecksumChar:= Checksum MOD 103;
    
    //Create ChecksumChar based on ASCII-Table
    CASE ChecksumChar OF
     0 : ChecksumChar := 212;
     1..94 : ChecksumChar += 32;
     95 : ChecksumChar := 200;
     96 : ChecksumChar := 201;
     97 : ChecksumChar := 202;
     98 : ChecksumChar := 203;
     99 : ChecksumChar := 204;
     100 : ChecksumChar := 205;
     101 : ChecksumChar := 206;
     102 : ChecksumChar := 207; 
     END;
    
    RetVal:=STRSUBSTNO('%1%2%3%4',StartChar,pText,ChecksumChar,StopChar);
    EXIT(RetVal);
    

    I call this function like this, where FNC1 hast the value 207:
    EncodeBarcode(STRSUBSTNO('%1%2%3', FNC1, '00', ItemLedgerEntryRec2."SSCC No."));
    

    I dont know why espacially the Code C does not work.
  • xStepaxStepa Member Posts: 106
    edited 2017-06-23
    You can't sum the pairs in your checksum - only the final chars ...
    (3754 => EV => 1*E + 2*V) - calculate the checksum from the result string:
    checksum := EncodedNumber[1] - ' ' - 73;
    
    FOR i := 2 TO STRLEN(EncodedNumber) DO BEGIN
      IF EncodedNumber[i] <= 126 THEN
        checksum += ((i-1) * (EncodedNumber[i] - ' '))
      ELSE
        checksum += ((i-1) * (EncodedNumber[i] - ' ' - 73));
    END;
    
    checksum := checksum MOD 103;
    
    IF checksum <= 126 THEN
      EncodedNumber += GetStringFromOrdinal(checksum + 32)
    ELSE
      EncodedNumber += GetStringFromOrdinal(checksum + 32 + 73);
    
    EncodedNumber += GetStringFromOrdinal(211); 
    
    EXIT(EncodedNumber);
    

    EDIT: Sorry, should be the same, but your RetVal seems to be wrong, since the pText is not encoded ...
    Regards
    xStepa
  • AitorEGAitorEG Member Posts: 342
    Hello,
    I've found this post due to a problem. In our customers with navision 2016-2018, we've installed the barcode management objects downloaded from this web page. Everything was working perfeclty, until one customer changed the requisites. Now, instead of Code128, they must print barcodes ein GS1-128. What changes must be do for this aim?

    Thank you all
Sign In or Register to comment.