|
Alan, Sorry for being late to the party, but would something like this work for you. I have not tested it thoroughly though ( eg you need to validate that the string coming in has numerics only). This is based on the logic given in IBM DDS reference manual - CHECK keyword for display files. h NoMain d mod10 pr 10i 0 d string 100a const varying p mod10 b export d mod10 pi 10i 0 d string 100a const varying d sum s 10i 0 inz(0) d x s 10i 0 inz(2) d i s 10i 0 /free for i = 1 to %len(string); sum += %rem((%int(%subst(string:i:1))*x-1):9) + 1; x = 3-x; endfor; // Return the check digit return %rem((10-%rem(sum:10)-1):9)+1; /end-free p mod10 e you could call it as - d mod10 pr 10i 0 ExtProc('MOD10') d string 100a const varying d string s 10a varying d chkdigit s 10I 0 inz(0) /free string = '61248'; chkdigit = mod10(string); dsply %char(chkdigit); *inlr = '1'; /end-free ================================================================== Alan Shore wrote: ================================================================== date: Wed, 12 Apr 2006 16:28:46 -0400 from: Alan Shore <AlanShore@xxxxxxxx> subject: RE: Mod 10 check digit calculation Unfortunately - we don't have the RPG xTools. Hence my cry for help Alan ****************************************************************************** The information contained in this electronic communication and any accompanying document is confidential, may be attorney-client privileged, and is intended only for the use of the addressee. It is the property of Ryder System, Inc. Unauthorized use, disclosure or copying of this communication, or any part of it, is strictly prohibited and may be unlawful. If you have received this communication in error, please notify the sender immediately by return email, and destroy this communication and all copies of it, including all attachments. Electronic communication may be susceptible to data corruption, interception and unauthorized tampering and Ryder disclaims all liability of any kind for such actions or any consequences that may arise directly or indirectly therefrom. ******************************************************************************
As an Amazon Associate we earn from qualifying purchases.
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.