Code: Select all
/* ********************************************************************** */
FUNCTION cSEPAcaracteres( cCadena )
local nContador := 0
Local cCaracteresOK := "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
cCaracteresOk := cCaracteresOk + Lower( cCaracteresOk )
cCaracteresOk := cCaracteresOk + "1234567890"
cCaracteresOk := cCaracteresOk + "/-?:().,'+ "
If Len( cCadena ) > 0
cCadena := " " + cCadena + " "
While AT( "ç", cCadena) > 0
cCadena := Left( cCadena, AT( "ç", cCadena) -1 ) + "c" + Substr( cCadena, AT( "ç", cCadena) + 1 )
End
While AT( "Ç", cCadena) > 0
cCadena := Left( cCadena, AT( "Ç", cCadena) -1 ) + "C" + Substr( cCadena, AT( "Ç", cCadena) + 1 )
End
While AT( "ñ", cCadena) > 0
cCadena := Left( cCadena, AT( "ñ", cCadena) -1 ) + "n" + Substr( cCadena, AT( "ñ", cCadena) + 1 )
End
While AT( "Ñ", cCadena) > 0
cCadena := Left( cCadena, AT( "Ñ", cCadena) -1 ) + "N" + Substr( cCadena, AT( "Ñ", cCadena) + 1 )
End
For nContador := 2 To Len( cCadena )
If SubStr( cCadena, nContador, 1 ) $ cCaracteresOk
Else
cCadena := Left(cCadena, nContador - 1 ) + "-" + Substr( cCadena, nContador + 1 )
EndIf
Next
cCadena := SubStr( cCadena, 2 )
cCadena := Left( cCadena, Len( cCadena ) - 1 )
EndIf
Return cCadena
/* ********************************************************************** */
/* *********************************************************************************** */
FUNCTION cGetIdSEPABD( AMPAARRA )
Local cPais := "ES"
local cSufix := cGetSufixFact( AMPAARRA )
Local cNIF := cGetNifBD( AMPAARRA )
Local cDigit := cGetDigitIDSEPA( cNIF, cPais )
Return AllTrim( cPais + cDigit + cSufix + cNIF )
/* *********************************************************************************** */
FUNCTION cGetDigitIDSEPA( cNIF, cPais )
Local aLetras := {"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z" }
Local aValor := {10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35 }
Local cCadena := AllTrim(cNIF) + cPais + "00"
Local nContador := 0
Local cAux := ""
Local nModulo := 0
/* ES = 1428 */
cCadena := " " + cCadena + " "
For nContador := 1 to 26
If AT( aLetras[ nContador], cCadena ) > 0
cCadena := Left( cCadena, AT( aLetras[ nContador], cCadena ) - 1 ) + Str( aValor[ nContador ], 2, 0) + SubStr( cCadena, AT( aLetras[ nContador], cCadena ) + 1 )
EndIf
Next
cCadena := AllTrim( cCadena )
//** PASO 3 aplicar el modulo de 97 a la cantidad auxiliar - 10(ISO 7604)
cAux := Left( cCadena, 9 )
//208100217
cCadena := SubStr( cCadena, 10 )
//00000104602142800
nModulo := ( Val( cAux ) % 97 )
//resto de 208100217 / 97
While Len( cCadena ) > 8
If nModulo < 10
cAux := AllTrim(Str( nModulo, 2, 0 )) + Left( cCadena, 8 )
cCadena := SubStr( cCadena, 9 )
nModulo := ( Val( cAux ) % 97 )
Else
cAux := AllTrim(Str( nModulo, 2, 0)) + Left( cCadena,7 )
cCadena := SubStr( cCadena, 8 )
nModulo := ( Val( cAux ) % 97 )
Endif
End
cAux := AllTrim(Str( nModulo, 2, 0)) + cCadena
nModulo := ( Val( cAux ) % 97 )
nModulo := 98 - nModulo
If nModulo < 10
cAux := "0" + AllTrim(Str( nModulo, 2, 0))
Else
cAux := Str( nModulo, 2, 0)
Endif
Return cAux
/* *********************************************************************************** */