Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
8
Erster Beitrag:
vor 5 Jahren, 4 Monaten
Letzter Beitrag:
vor 3 Jahren, 11 Monaten
Beteiligte Autoren:
Ola, makaveiljojo, mariah313, Arie, GuenterP

[WD16] How to feed a correct code to a Code 128 bar code control in a report?

Startbeitrag von Ola am 14.07.2012 16:15

[WD16] How to feed a correct code to a Code 128 bar code control in a report?

Hi all,

I am adding a bar code control to an invoice report. According to our bank standards it must be a code 128 bar code, with character set C. It consists of the following elements:

1) START CODE C as the first character
2) the "beef", the actual data consisting of a total of 54 digits (no problems here)
3) Check digit calculated from 1 and 2 with modulo 103
4) End character

According to the documentation the elements 1, 3 and 4 are "part of the code 128 structure".

Questions:
A) How should I build the complete string for the bar code?
B) Is the modulo 103 check value calculated and added automatically or should I calculate it from the start code and the beef? Is there a simple algorithm to do this calculation?
C) Is the end character added automatically, or should I code it somehow? How?

Best regards
Ola

Antworten:

Hi Ola, I can't remember a lot about the EAN128 things, for sure there's a manual that lines out everything in your country. However, I have made several EAN128 programs mostly for printing the SSCC code, these are stickers for palettes to tell about their contents etc. I donate the code to you here, if it is of any use to you .. have fun! This is the code behind the button 'Print SSCC sticker':

// Bilde den SSCC-string
LPAL++
SSCC = "3"+Left(OURBBN,7)+NumToString(LPAL,"09d")+" "
Summe = 0
FOR ic = 1 TO 17
IF (ic/2) = IntegerPart(ic/2) THEN
// Gerade Zahl -> Multipliziere mit 1
Summe = Summe + Val(Middle(SSCC,ic,1))*1
ELSE
// Ungerade Zahl -> Multipliziere mit 3
Summe = Summe + Val(Middle(SSCC,ic,1))*3
END
END
Test = Summe modulo 10
Test = 10 - Test
IF Test = 10 THEN Test = 0
IF Test > 9 THEN Info("Prüfziffer falsch!")
SSCC = Left(SSCC,17) + NumToString(Test)



IF iConfigure() THEN
iCreateFont(1,14,iBold,"Arial")
iCreateFont(2,14,iNormal,iSwiss)
iCreateFont(3,22,iNormal,iSwiss)
iCreateFont(4,10,iNormal,iSwiss)

IF PREV THEN
iPreview(i100)
END

// jetzt wird gedruckt links oben
//----------------------------------------
Adr1X = LRAND+2
Adr1Y = ORAND+2
Adr2X = LRAND+2
Adr2Y = ORAND+2+7
iPrint(iFont(1)+iXPos(Adr1X)+iYPos(Adr1Y)+ADR1)
iPrint(iFont(1)+iXPos(Adr2X)+iYPos(Adr2Y)+ADR2)
iLine(Adr1X+2,Adr2Y+2+7,Adr1X+2+86,Adr2Y+2+7,1)
iPrint(iFont(2)+iXPos(Adr1X+3)+iYPos(Adr2Y+2+8)+"SSCC")
iPrint(iFont(3)+iXPos(Adr1X+3)+iYPos(Adr2Y+2+12)+SSCC)
iPrint(iFont(2)+iXPos(Adr1X+3)+iYPos(Adr2Y+2+20)+"CONTENT")
iPrint(iFont(3)+iXPos(Adr1X+3)+iYPos(Adr2Y+2+24)+"0"+sProdEAN)
iPrint(iFont(2)+iXPos(Adr1X+3)+iYPos(Adr2Y+2+32)+"BEST BEFORE QTY CHARGE")
iPrint(iFont(3)+iXPos(Adr1X+3)+iYPos(Adr2Y+2+36)+DateToString(MHD,"AA.MM.JJ")+" "+NumToString(iProdMenge,"6d"))
iPrint(iFont(2)+iXPos(Adr1X+3+58)+iYPos(Adr2Y+2+37)+NoSpace(sProdCharge))
iPrint(iFont(3)+iXPos(Adr1X+3)+iYPos(Adr2Y+2+44)+sProdBez)
iLine(Adr1X+2,Adr2Y+2+52,Adr1X+2+86,Adr2Y+2+52,1)
iPrintBarCode("020"+sProdEAN+"10"+NoSpace(sProdCharge),BC_EAN128,Adr1X+2,Adr2Y+2+54,Adr1X+2+86,Adr2Y+2+84,BC_CenterH)
iPrint(iFont(4)+iXPos(Adr1X+3+10)+iYPos(Adr2Y+2+84)+"(02)0"+sProdEAN+"(10)"+NoSpace(sProdCharge))
iPrintBarCode("00"+SSCC+"15"+Right(MHD,6)+"37"+NumToString(iProdMenge),BC_EAN128,Adr1X+2,Adr2Y+2+89,Adr1X+2+86,Adr2Y+2+119,BC_CenterH)
iPrint(iFont(4)+iXPos(Adr1X+3+10)+iYPos(Adr2Y+2+119)+"(00)"+SSCC+"(15)"+Right(MHD,6)+"(37)"+NumToString(iProdMenge))

// jetzt wird gedruckt rechts oben
//----------------------------------------
Adr1X = LRAND+2+105+VSTEG
Adr1Y = ORAND+2
Adr2X = LRAND+2+105+VSTEG
Adr2Y = ORAND+2+7
iPrint(iFont(1)+iXPos(Adr1X)+iYPos(Adr1Y)+ADR1)
iPrint(iFont(1)+iXPos(Adr2X)+iYPos(Adr2Y)+ADR2)
iLine(Adr1X+2,Adr2Y+2+7,Adr1X+2+86,Adr2Y+2+7,1)
iPrint(iFont(2)+iXPos(Adr1X+3)+iYPos(Adr2Y+2+8)+"SSCC")
iPrint(iFont(3)+iXPos(Adr1X+3)+iYPos(Adr2Y+2+12)+SSCC)
iPrint(iFont(2)+iXPos(Adr1X+3)+iYPos(Adr2Y+2+20)+"CONTENT")
iPrint(iFont(3)+iXPos(Adr1X+3)+iYPos(Adr2Y+2+24)+"0"+sProdEAN)
iPrint(iFont(2)+iXPos(Adr1X+3)+iYPos(Adr2Y+2+32)+"BEST BEFORE QTY CHARGE")
iPrint(iFont(3)+iXPos(Adr1X+3)+iYPos(Adr2Y+2+36)+DateToString(MHD,"AA.MM.JJ")+" "+NumToString(iProdMenge,"6d"))
iPrint(iFont(2)+iXPos(Adr1X+3+58)+iYPos(Adr2Y+2+37)+NoSpace(sProdCharge))
iPrint(iFont(3)+iXPos(Adr1X+3)+iYPos(Adr2Y+2+44)+sProdBez)
iLine(Adr1X+2,Adr2Y+2+52,Adr1X+2+86,Adr2Y+2+52,1)
iPrintBarCode("020"+sProdEAN+"10"+NoSpace(sProdCharge),BC_EAN128,Adr1X+2,Adr2Y+2+54,Adr1X+2+86,Adr2Y+2+84,BC_CenterH)
iPrint(iFont(4)+iXPos(Adr1X+3+10)+iYPos(Adr2Y+2+84)+"(02)0"+sProdEAN+"(10)"+NoSpace(sProdCharge))
iPrintBarCode("00"+SSCC+"15"+Right(MHD,6)+"37"+NumToString(iProdMenge),BC_EAN128,Adr1X+2,Adr2Y+2+89,Adr1X+2+86,Adr2Y+2+119,BC_CenterH)
iPrint(iFont(4)+iXPos(Adr1X+3+10)+iYPos(Adr2Y+2+119)+"(00)"+SSCC+"(15)"+Right(MHD,6)+"(37)"+NumToString(iProdMenge))

// jetzt wird gedruckt links unten
//----------------------------------------
Adr1X = LRAND+2
Adr1Y = ORAND+2+148+HSTEG
Adr2X = LRAND+2
Adr2Y = ORAND+2+7+148+HSTEG
iPrint(iFont(1)+iXPos(Adr1X)+iYPos(Adr1Y)+ADR1)
iPrint(iFont(1)+iXPos(Adr2X)+iYPos(Adr2Y)+ADR2)
iLine(Adr1X+2,Adr2Y+2+7,Adr1X+2+86,Adr2Y+2+7,1)
iPrint(iFont(2)+iXPos(Adr1X+3)+iYPos(Adr2Y+2+8)+"SSCC")
iPrint(iFont(3)+iXPos(Adr1X+3)+iYPos(Adr2Y+2+12)+SSCC)
iPrint(iFont(2)+iXPos(Adr1X+3)+iYPos(Adr2Y+2+20)+"CONTENT")
iPrint(iFont(3)+iXPos(Adr1X+3)+iYPos(Adr2Y+2+24)+"0"+sProdEAN)
iPrint(iFont(2)+iXPos(Adr1X+3)+iYPos(Adr2Y+2+32)+"BEST BEFORE QTY CHARGE")
iPrint(iFont(3)+iXPos(Adr1X+3)+iYPos(Adr2Y+2+36)+DateToString(MHD,"AA.MM.JJ")+" "+NumToString(iProdMenge,"6d"))
iPrint(iFont(2)+iXPos(Adr1X+3+58)+iYPos(Adr2Y+2+37)+NoSpace(sProdCharge))
iPrint(iFont(3)+iXPos(Adr1X+3)+iYPos(Adr2Y+2+44)+sProdBez)
iLine(Adr1X+2,Adr2Y+2+52,Adr1X+2+86,Adr2Y+2+52,1)
iPrintBarCode("020"+sProdEAN+"10"+NoSpace(sProdCharge),BC_EAN128,Adr1X+2,Adr2Y+2+54,Adr1X+2+86,Adr2Y+2+84,BC_CenterH)
iPrint(iFont(4)+iXPos(Adr1X+3+10)+iYPos(Adr2Y+2+84)+"(02)0"+sProdEAN+"(10)"+NoSpace(sProdCharge))
iPrintBarCode("00"+SSCC+"15"+Right(MHD,6)+"37"+NumToString(iProdMenge),BC_EAN128,Adr1X+2,Adr2Y+2+89,Adr1X+2+86,Adr2Y+2+119,BC_CenterH)
iPrint(iFont(4)+iXPos(Adr1X+3+10)+iYPos(Adr2Y+2+119)+"(00)"+SSCC+"(15)"+Right(MHD,6)+"(37)"+NumToString(iProdMenge))

// jetzt wird gedruckt rechts unten
//----------------------------------------
Adr1X = LRAND+2+105+VSTEG
Adr1Y = ORAND+2+148+HSTEG
Adr2X = LRAND+2+105+VSTEG
Adr2Y = ORAND+2+7+148+HSTEG
iPrint(iFont(1)+iXPos(Adr1X)+iYPos(Adr1Y)+ADR1)
iPrint(iFont(1)+iXPos(Adr2X)+iYPos(Adr2Y)+ADR2)
iLine(Adr1X+2,Adr2Y+2+7,Adr1X+2+86,Adr2Y+2+7,1)
iPrint(iFont(2)+iXPos(Adr1X+3)+iYPos(Adr2Y+2+8)+"SSCC")
iPrint(iFont(3)+iXPos(Adr1X+3)+iYPos(Adr2Y+2+12)+SSCC)
iPrint(iFont(2)+iXPos(Adr1X+3)+iYPos(Adr2Y+2+20)+"CONTENT")
iPrint(iFont(3)+iXPos(Adr1X+3)+iYPos(Adr2Y+2+24)+"0"+sProdEAN)
iPrint(iFont(2)+iXPos(Adr1X+3)+iYPos(Adr2Y+2+32)+"BEST BEFORE QTY CHARGE")
iPrint(iFont(3)+iXPos(Adr1X+3)+iYPos(Adr2Y+2+36)+DateToString(MHD,"AA.MM.JJ")+" "+NumToString(iProdMenge,"6d"))
iPrint(iFont(2)+iXPos(Adr1X+3+58)+iYPos(Adr2Y+2+37)+NoSpace(sProdCharge))
iPrint(iFont(3)+iXPos(Adr1X+3)+iYPos(Adr2Y+2+44)+sProdBez)
iLine(Adr1X+2,Adr2Y+2+52,Adr1X+2+86,Adr2Y+2+52,1)
iPrintBarCode("020"+sProdEAN+"10"+NoSpace(sProdCharge),BC_EAN128,Adr1X+2,Adr2Y+2+54,Adr1X+2+86,Adr2Y+2+84,BC_CenterH)
iPrint(iFont(4)+iXPos(Adr1X+3+10)+iYPos(Adr2Y+2+84)+"(02)0"+sProdEAN+"(10)"+NoSpace(sProdCharge))
iPrintBarCode("00"+SSCC+"15"+Right(MHD,6)+"37"+NumToString(iProdMenge),BC_EAN128,Adr1X+2,Adr2Y+2+89,Adr1X+2+86,Adr2Y+2+119,BC_CenterH)
iPrint(iFont(4)+iXPos(Adr1X+3+10)+iYPos(Adr2Y+2+119)+"(00)"+SSCC+"(15)"+Right(MHD,6)+"(37)"+NumToString(iProdMenge))

iEndPrinting()



von GuenterP - am 14.07.2012 16:48
Hi Guenter

And sorry if I can't express this clearly enough; this is my first real life exercise with bar codes ever.

Anyways, thanks for the full frontal salvo against my little fly:)

The problem is different, though. I have full documentation on how I must build the code, and I have no problems with it. The problem is the automation and syntax in Windev and its documentation. There are no samples on how to feed a Charset C code 128 to a bar code control in a report. There are only some (age old?) samples for iPrinting a code, and they don't seem to be applicable to feeding a bar code control in a report.

If I am lucky, the automatic handling of the bar code by WIndev MIGHT handle the problem, but I have no way knowing whether it does or not. Automation is good, but only when it is fully documented.

The "beef code" is all plain numeric, so logically it should be in charset C only, but not only logically but also mandatorily it must be in C, by the rule. From this it should follow, that there is a character "105" in the beginning, before the "beef code", indicating that charset C is used.

The main problem is this:
Is Windev's bar code control (in a report) able to decide from the plain numeric code that it must use character set C? If yes, good? But as long as I don't know that, I want to make sure the code is in charset C. So I am trying to feed the start code that defines the carset. If I try to add (everything separated to make them show correctly here)

""

(which is suggested in the help for iPrinting the bar code) to the beginning of the code, it shows as such also in the human representation of the code, and I don't think that is right.

Secondary problems are these:
Does Windev add the modulo 103 calculated check sum automatically after the beef code? Does Windev add the end character automatically? How can I know whether they are there or not? Should these be somehow visible in the human representation of the code?

This is an important code: it tells the customer how much he should pay, by which time, to which account and using what reference, so its got to be right beyond all doubts. I can't base it on guessing what Windev might or might not do automatically.

best regards
Ola

von Ola - am 16.07.2012 15:24
Ola,
maybe you don't expect PCSoft has done the job so well, but the help file is very clear about this. Check the "Code 128 bar code" section here http://doc.pcsoft.fr/en-US/?3046064

The barcode uses character set A by default. If you need set C you have to specify it in the description windows.
Also "A correction character is automatically generated. Its value is equal to the weighed sum of the values of characters modulo 103."

I used the EAN128 back in WD12 for printing SSCC labels. And it did the job.

von Arie - am 16.07.2012 17:25
Thanks Arie,

Ok, so the checksum is handled. Obviously also the end character. But I still have not found how to feed the character set C setting to the control. The description window of the control gives choices "Auto" and "Custom". If custom is selected then the character set command must be fed into the control as the first data of the string. This is supposedly something like

StartCode is string = "(START C)"
BarCode = StartCode + TheBeefCodeStringConsistingOf54NumericDigits

(replace the parenthesis around START C with arrowheads left and right). The problem still is the syntax. If I put the start code to the beginning of the string, it is repeated exactly the same in the human representation of the code, complete with the arrowheads. Otherwise the bar code looks OK. Is this correct?

The help is controversial. Excerpts from the help, first: "The set of characters used is automatically selected by WinDev, WebDev or WinDev Mobile to draw the smallest possible bar code.", then a few lines later: ""CODE A" set is used by default."

If I set StartCode = "" then the printed code will be more compact, and this suggests that Windev actually automatically selects C here to produce the smallest code. (C is the most compact charset in code 128, because only numbers are used.)

Obviously I have to make an invoice to myself and go and test its behaviour in a bank automat...

best regards
Ola

von Ola - am 16.07.2012 19:55
Another funny thing just surfaced:

OnTestMode the bar code is printed, but not in the executable!?!?

Ola

von Ola - am 18.07.2012 12:27
hey,you can take this code 128 in RDLC reports for example.

von mariah313 - am 23.09.2013 09:15
To get code 128 images, you will need to hava a code 128 font or code 128 control installed on your system, then the barcode generating function can be integrated into your project.
As for your second question,
Since Code 128 is self-checking, a check digit normally isn't necessary. However, a module 103 checksum digit may be added in applications that require an extremely high level of accuracy. It can be calculated as the following steps:

1.Retrieve the symbol character value respectively.
2.Each symbol character position is given a weighting. The start character position is weighted 1. Then, other positions from the beginning on the left with the first symbol character are weighted 1, 2, 3, 4, ..., n.
3.Multiply each character by its weighting in the barcode string.
4.Sum the products of calculation in step 3.
5.The sum of the products is then divided by 103.
6.The value of the remainder in step 4 is the value of the symbol check character. After that, you should find the corresponding checksum digit according to its ASCII value.

Little bit complicated but hope this helps.

von makaveiljojo - am 23.12.2013 03:38
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.