× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Matt and mprice,

Thanks to both of you.

I liked aspects of both of yours, so I combined them and wrote my own.
Then I wrote a tester program to run through the 1374 items we get from
one supplier to see if my program was working properly. Out of the 1374,
ONE item had a different check digit than my program calculated. So I went
online to 2 separate websites and used their online calculator against this
item. My program is right. Woo hoo! That means the supplier has a wrong
GTIN number on file.

For the record, here is my program:

H NoMain

/Include QCpySrc,HDefault

* Get prototype(s)
/Define CpyClcChkDgt
/Include QProtoSrc,SubGTIN
/UnDefine CpyClcChkDgt

P/EJECT
//===============================================================
//
// Procedure : ClcChkDgt
// Description : Calculate check digit for a GTIN
//
//===============================================================

P ClcChkDgt B Export
D ClcChkDgt PI 1S 0
D GTIN 14S 0

D DS
D GTINField 14S 0
D GTINAry 1S 0 Dim(14) Overlay(GTINField)

D ChkDgt S 1S 0
D Sum S 3P 0

/FREE

GTINField = GTIN;

Sum = 3 * (GTINAry(1) +
GTINARY(3) +
GTINARY(5) +
GTINARY(7) +
GTINARY(9) +
GTINARY(11) +
GTINARY(13)) +
GTINAry(2) +
GTINAry(4) +
GTINAry(6) +
GTINAry(8) +
GTINAry(10) +
GTINAry(12);

Sum = %Rem(Sum:10);

If Sum > *Zero;
ChkDgt = 10 - Sum;
Else;
ChkDgt = *Zero;
Endif;

Return ChkDgt;

/END-FREE

P ClcChkDgt E


On Wed, Mar 28, 2012 at 5:08 PM, <mprice@xxxxxxxxx> wrote:

EVAL Sum = 3 * (UPC1 + UPC3 + UPC5
+ UPC7 + UPC9 + UPC11
+ UPC13)
+ UPC2 + UPC4 + UPC6
+ UPC8 + UPC10 + UPC12
EVAL Sum = %rem(Sum:10)
IF Sum > *zero
EVAL Chkdgt = 10 - Sum
ELSE
EVAL Chkdgt = *zero
ENDIF



Jeff Crosby <jlcrosby@xxxxxxxxxxxxxxxx>
Sent by: rpg400-l-bounces@xxxxxxxxxxxx
03/28/2012 04:56 PM
Please respond to
RPG programming on the IBM i / System i <rpg400-l@xxxxxxxxxxxx>


To
"RPG programming on the IBM i / System i" <rpg400-l@xxxxxxxxxxxx>
cc

Subject
RPG routine for GTIN






All,

Anyone have available (or know of someone who does) RPG routines to
calculate and/or verify the check digit in a GTIN?

I see the RPG xTools has it for $495, along with a lot of other stuff I
don't really need.

Thanks.

--
Jeff Crosby
VP Information Systems
UniPro FoodService/Dilgard
P.O. Box 13369
Ft. Wayne, IN 46868-3369
260-422-7531
www.dilgardfoods.com

The opinions expressed are my own and not necessarily the opinion of my
company. Unless I say so.
--
This is the RPG programming on the IBM i / System i (RPG400-L) mailing
list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.


--
This is the RPG programming on the IBM i / System i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.





As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.