/**
* \brief Validator Example : Check Digit
*
* This program takes a code as parameter (alphanumeric) and checks if the
* check digit is ok (modulus 10). If it ain't a valid code then the
* check digit will be calculated.
*
*
*
* Example: CALL VALID01 PARM('1234565')
*
* \author Mihael Schmidt
* \date 05.02.2011
*/
H dftactgrp(*no) actgrp(*caller)
*-------------------------------------------------------------------------
* PEP
*-------------------------------------------------------------------------
D VALID01 PR extpgm('VALID01')
D ean 13A
D VALID01 PI
D ean 13A
D
*-------------------------------------------------------------------------
* Prototypes
*-------------------------------------------------------------------------
D main PR
D ean 13A
*
/include 'rng/validator/checkdigit_h.rpgle'
/free
if (%parms() = 1);
main(ean);
else;
dsply %trimr('Syntax: CALL VALID01 PARM(''my_ean'')');
endif;
*inlr = *on;
/end-free
P main B
D PI
D ean 13A
*
D dsp S 50A
/free
if (rng_validator_modulus_isValid(ean));
dsply 'Check digit is ok.';
else;
dsply 'Code is invalid. Wrong check digit.';
dsp = 'The check digit should be ' +
%char(rng_validator_modulus_calculate(
%subst(%trim(ean) : 1 : %len(%trim(ean)) -1)));
dsply dsp;
endif;
/end-free
P E