take a look here
http://publib.boulder.ibm.
and
http://publib.boulder.ibm.
to get an idea how this can be done
then, in the trigger you just call your function like any other function
Function CheckDigitEAN13(PN12 As String) As Integer
Factor = 3
WeightedTotal = 0
For I = Len(PN12) To 1 Step -1
'Get the value of each number starting at the end
CurrentCharNum = Mid(PN12, I, 1)
'Multiply by the weighting factor which is 3,1,3,1...
'and add the sum together
WeightedTotal = WeightedTotal + CurrentCharNum * Factor
'Change factor for next calculation
Factor = 4 - Factor
Next I
'Find the CheckDigit by finding the number + WeightedTotal that = a multiple of 10
'Divide by 10, get the remainder and subtract from 10
I = (WeightedTotal Mod 10)
If I <> 0 Then
CheckDigit = (10 - I)
Else
CheckDigit = 0
End If
CheckDigitEAN13 = CheckDigit
End Function
*-------------------------------------------------------------------------
* Fields definitions
*-------------------------------------------------------------------------
D EAN13 DS 13
D EAN 1A DIM(13)
D CALC S 5S 0
D CTRL S 1S 0
*-------------------------------------------------------------------------
* Main line
*-------------------------------------------------------------------------
C EVAL CALC =
C %DEC(EAN(02):1:0) + %DEC(EAN(04):1:0) +
C %DEC(EAN(06):1:0) + %DEC(EAN(08):1:0) +
C %DEC(EAN(10):1:0) + %DEC(EAN(12):1:0)
C EVAL Calc = Calc * 3
C EVAL CALC = CALC +
C %DEC(EAN(01):1:0) + %DEC(EAN(03):1:0) +
C %DEC(EAN(05):1:0) + %DEC(EAN(07):1:0) +
C %DEC(EAN(09):1:0) + %DEC(EAN(11):1:0)
C EVAL Ctrl = 10 - %Rem(Calc:10)
C EVAL EAN(13) = %editc(Ctrl:'X')
C EVAL *InLr = *On
*-------------------------------------------------------------------------
* Klist + Plist definitions
*-------------------------------------------------------------------------
C *ENTRY PLIST
C PARM EAN13
Title | # Comments | Views | Activity |
---|---|---|---|
grant user read only access to DB2 V 8.02 | 10 | 934 | |
how can I create a record layout for this file? | 14 | 434 | |
sql duplicate rows from concatenated columns | 9 | 300 | |
Tricky SQL question | 13 | 382 |
Join the community of 500,000 technology professionals and ask your questions.
Connect with top rated Experts
6 Experts available now in Live!