udfIsValidRentenVsnr
bln udfIsValidRentenVsnrV1 (str)
bln udfIsValidRentenVsnrV2 (str)
;------------------------------------------------------------------------------------------------------------------------------------------
#DefineFunction udfIsValidRentenVsnrV2 (strVsnr)
If StrLen (strVsnr) != 12 Then Return @FALSE
If !IsNumber (StrSub (strVsnr, 1, 8)) Then Return @FALSE
If !IsNumber (StrSub (strVsnr, 10, 3)) Then Return @FALSE
If IsNumber (StrSub (strVsnr, 9, 1)) Then Return @FALSE
arrN = ArrayFromStr ("0" : strVsnr : "0")
arrN[13] = arrN[12]
arrN[12] = arrN[11]
arrN[11] = 2 * arrN[10]
arrN[10] = (Char2Num (arrN[9]) - 64) mod 10
arrN[9] = 2 * (Char2Num (arrN[9]) - 64) / 10
arrN[7] = 2 * arrN[7]
arrN[5] = 7 * arrN[5]
arrN[4] = 5 * arrN[4]
arrN[3] = 2 * arrN[3]
arrN[1] = 2 * arrN[1]
For intN = 1 To 12
   arrN[intN] = (arrN[intN] / 10) + (arrN[intN] mod 10)
   arrN[0] = arrN[0] + arrN[intN]
Next
arrN[0] = arrN[0] mod 10
blnIsValidRentenVsnr = arrN[13] == arrN[0]
Return blnIsValidRentenVsnr
;..........................................................................................................................................
; This UDF "udfIsValidRentenVsnr" returns a boolean value @FALSE or @TRUE resp. 0 or 1
; which indicates if the given german social insurance number is valid or not.
;
; Diese Funktion prueft die Gueltigkeit der Deutschen Rentenversicherungsnummer.
; Vsnr = String[12] = "99999999X999", e.g. "53010209D048"
;
; Detlev Dalitz.20010727.20100205.
;..........................................................................................................................................
#EndFunction
;------------------------------------------------------------------------------------------------------------------------------------------


;------------------------------------------------------------------------------------------------------------------------------------------
#DefineFunction udfIsValidRentenVsnrV1 (strVsnr)
If StrLen (strVsnr) != 12 Then Return @FALSE
If !IsNumber (StrSub (strVsnr, 1, 8)) Then Return @FALSE
If !IsNumber (StrSub (strVsnr, 10, 3)) Then Return @FALSE
If IsNumber (StrSub (strVsnr, 9, 1)) Then Return @FALSE
intN1 = 2 * StrSub (strVsnr, 1, 1)
intN2 = StrSub (strVsnr, 2, 1)
intN3 = 2 * StrSub (strVsnr, 3, 1)
intN4 = 5 * StrSub (strVsnr, 4, 1)
intN5 = 7 * StrSub (strVsnr, 5, 1)
intN6 = StrSub (strVsnr, 6, 1)
intN7 = 2 * StrSub (strVsnr, 7, 1)
intN8 = StrSub (strVsnr, 8, 1)
intN9 = 2 * (Char2Num (StrSub (strVsnr, 9, 1)) - 64) / 10
intN10 = (Char2Num (StrSub (strVsnr, 9, 1)) - 64) mod 10
intN11 = 2 * StrSub (strVsnr, 10, 1)
intN12 = StrSub (strVsnr, 11, 1)
intN13 = 0
For intI = 1 To 12
   intN%intI% = (intN%intI% / 10) + (intN%intI% mod 10)
   intN13 = intN13 + intN%intI%
Next
intN13 = intN13 mod 10
blnIsValidRentenVsnr = StrSub (strVsnr, 12, 1) == intN13
Return blnIsValidRentenVsnr
;..........................................................................................................................................
; This UDF "udfIsValidRentenVsnr" returns a boolean value @FALSE or @TRUE resp. 0 or 1
; which indicates if the given german social insurance number is valid or not.
;
; Diese Funktion prueft die Gueltigkeit der Deutschen Rentenversicherungsnummer.
; Vsnr = String[12] = "99999999X999", e.g. "53010209D048"
;
; Detlev Dalitz.20010727.20100205.
;..........................................................................................................................................
#EndFunction
;------------------------------------------------------------------------------------------------------------------------------------------


; Test.

strVsnr = "53010209D000" ; @FALSE.
strMsgTitle = "Test Sozialversicherungsnummer"
strMsgText = strVsnr : @LF : ItemExtract (1 + udfIsValidRentenVsnrV2 (strVsnr), "ist falsch.,ist in Ordnung.", ",")
Message (strMsgTitle, strMsgText)

strVsnr = "53010209D048" ; @TRUE.
strMsgTitle = "Test Sozialversicherungsnummer"
strMsgText = strVsnr : @LF : ItemExtract (1 + udfIsValidRentenVsnrV2 (strVsnr), "ist falsch.,ist in Ordnung.", ",")
Message (strMsgTitle, strMsgText)


strVsnr = "53010209D000" ; @FALSE.
strMsgTitle = "Test Sozialversicherungsnummer"
strMsgText = strVsnr : @LF : ItemExtract (1 + udfIsValidRentenVsnrV1 (strVsnr), "ist falsch.,ist in Ordnung.", ",")
Message (strMsgTitle, strMsgText)

strVsnr = "53010209D048" ; @TRUE.
strMsgTitle = "Test Sozialversicherungsnummer"
strMsgText = strVsnr : @LF : ItemExtract (1 + udfIsValidRentenVsnrV1 (strVsnr), "ist falsch.,ist in Ordnung.", ",")
Message (strMsgTitle, strMsgText)
Exit
;------------------------------------------------------------------------------------------------------------------------------------------