× 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.



EVERYONE has their own little version of mod 10 calculation.  Like an EDI
214 is standard.  Right!

here's an old version that doesn't use cool language features, and it works
only on 19 characters

d data01          DS
d  i19                    1     19  0 dim(19)
d  inp19                  1     19
d  o20                    1     20  0 dim(20)
d  out20                  1     20
Dstep1            s              3  0
Dstep2            s              3  0
Dstep3            s              3  0
Dstep4            s              3  0
Dstep5            s              1  0
Dx                s              2  0
c     *entry        plist
c                   parm                    pp19             19
c                   parm                    pp20             20
c                   eval         inp19=pp19
c
 **
 ** step 1 add up all odd digits
 **
c                   eval      x = 1
c                   eval      step1 = 0
c
c                   dow       x < 20
c                   eval      step1 = step1 + i19(x)
c                   eval      x = x+2
c                   enddo
c                   eval      step1 = step1 * 3
 **
 ** step 2 add up all even digits
 **
c                   eval      x =    2
c                   eval      step2= 0
c
c                   dow       x <= 18
c                   eval      step2= step2+ i19(x)
c                   eval      x = x+2
c                   enddo
c
 **
 ** step 3 add up step 1 & step 2
 **
c                   eval      step3 = step1 + step2
 **
 ** step 4 round to nearest ten
 **
c     step3         div       10            wk04              4 0
c                   mvr                     wk01              1 0
c                   if        wk01 <> 0
c                   eval      step4 = step3 + 10
c                   move      '0'           step4
c                   else
c                   eval      step4 = step3
c                   endif
 **
 ** step 5 subtract total from rounded number
 **
c                   eval      step5 = step4-step3
c                   eval      o20(20)=step5
 **
c                   eval      pp20 = out20
c                   eval      *inlr = '1'
c                   return

On 4/12/06, Michael_Schutte@xxxxxxxxxxxx <Michael_Schutte@xxxxxxxxxxxx>
wrote:
>
> You want a mod 10 calculation of a number right?
>
>
> 11 mod 10 = 1
>
> %Rem(11:10) = 1
>
> Am I missing something?
>
> Michael Schutte
> Work 614-492-7419
> email  michael_schutte@xxxxxxxxxxxx
>
> --
> This is the RPG programming on the AS400 / iSeries (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.
>
>


--
Art Tostaine (GMAIL)

As an Amazon Associate we earn from qualifying purchases.

This thread ...

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.