RPGIV @ Work

A unique site for RPG and System i Lovers

Welcome!

Hi, this site will provide all what you need in System i and RPG developments.

My Name is Chamara Withanachchi, System i Expert and RPG Developer. And in the field for last 11 years.

I hope you will find lot of valuable information from this site

Generates the Modulus 10 check digit from RPG Print E-mail
User Rating: / 1
PoorBest 

Written by Chamara Withanachchi   
 D I               s              2s 0 Inz(1) 
 D Numbers         c                      Const('0123456789') 
 D Alpha#          s                      Like(My_Parm)Inz(*All'0')
 D Chr_Pos         s              2s 0 Inz 
 D My_Parm         S             15a   inz('0794730') 
             
  * Put the Base Number into an Array 
 D Original#       ds                  Inz 
 D  My_Number                    15s 3 
 D  Array                         1s 0 Dim(15) Overlay(My_Number) 
 
  * Check Digit(s) 
 D Digits          ds                  Inz 
 D  Chk_Digits                    2s 0 
 D  Check_Digit                   1s 0 Overlay(Chk_Digits:2) 
 
 * Position 
 D Position        ds                  Inz 
 D Pos                            2s 0 
 D Pos_Left                       1s 0 Overlay(Pos:1) 
 D Pos_Right                      1s 0 Overlay(Pos:2) 
 
  * Modulus10 Check Digit - Main logic 

 c                   Eval      My_Number = %Int(%trim(My_Parm))     
c For I = %elem(Array) DownTo 1 by 2
c Eval Pos = Array(I) * 2
c Eval Pos_Left = Pos_Left + Pos_Right
c Eval Array(I) = Pos_Left
c EndFor
c Eval Chk_Digits = 100 - %xFoot(Array)

* Return parm with check digit appended
c Eval My_Parm = %trim(My_Parm) +
c %char(Check_Digit)

c Eval *inLR =*On
User Comments

Please login or register to add comments

<Previous   Next>