// Summary: <specify the procedure action>
// Syntax:
//[ <Result> = ] GP_ValidaRFC (<nTipoPersona>, <sParamRFC>)
//
// Parameters:
// nTipoPersona:
// sParamRFC: <specify the role of sRFC>
PROCEDURE GP_ValidaRFC(nTipoPersona,sParamRFC)
sRFC is string = sParamRFC
bValidaRFC is boolean = False
sLetra is string
sVerifica is string
sDigito is string = Right(sRFC,1)
nContador is int
nValor is int
nSuma is int = 0
nModulo11 is int
IF nTipoPersona = 1 THEN
IF Length(sRFC) = 13 THEN
bValidaRFC = True
END
ELSE
IF Length(sRFC) = 12 THEN
bValidaRFC = True
END
END
IF bValidaRFC = True THEN
IF Length(sRFC) = 12
sRFC = " " + sRFC
END
FOR nContador = 1 TO 12
sLetra = sRFC[nContador]
SWITCH sLetra
CASE "0": nValor = 0
CASE "1": nValor = 1
CASE "2": nValor = 2
CASE "3": nValor = 3
CASE "4": nValor = 4
CASE "5": nValor = 5
CASE "6": nValor = 6
CASE "7": nValor = 7
CASE "8": nValor = 8
CASE "9": nValor = 9
CASE "A": nValor = 10
CASE "B": nValor = 11
CASE "C": nValor = 12
CASE "D": nValor = 13
CASE "E": nValor = 14
CASE "F": nValor = 15
CASE "G": nValor = 16
CASE "H": nValor = 17
CASE "I": nValor = 18
CASE "J": nValor = 19
CASE "K": nValor = 20
CASE "L": nValor = 21
CASE "M": nValor = 22
CASE "N": nValor = 23
CASE "&": nValor = 24
CASE "O": nValor = 25
CASE "P": nValor = 26
CASE "Q": nValor = 27
CASE "R": nValor = 28
CASE "S": nValor = 29
CASE "T": nValor = 30
CASE "U": nValor = 31
CASE "V": nValor = 32
CASE "W": nValor = 33
CASE "X": nValor = 34
CASE "Y": nValor = 35
CASE "Z": nValor = 36
CASE " ": nValor = 37
CASE "Ñ": nValor = 38
OTHER CASE
END
nSuma = nSuma + ((14-nContador)*nValor)
END
nSuma = 11000 - nSuma
nModulo11 = modulo(nSuma, 11)
IF nModulo11 = 10 THEN
sVerifica = "A"
ELSE
sVerifica = nModulo11
END
IF sVerifica <> sDigito THEN
bValidaRFC = False
END
END
RESULT bValidaRFC