Omdat er in ons boekhoudpakket geen automatische manier is om dit op te vullen schreef ik een VBscript dat deze automatisch opvult. Deze gebruikt de webservice van ibanbic.
Ik heb eerst een periode getest voor ik de toestemming heb gevraagd. Vanaf dat ik deze teveel gebruikte kreeg ik automatische deze melding als antwoord :-)
MAIL ME TO UNLOCK - You have reached our fair-use daylimit of 2000 conversion. No problem if you want to use more. Just send me an email at info@ebcs.be or mds@ebcs.be, I will unblock your IP address
Ik roep dit script op met de parameter Klant of Leverancier
cscript D:\Scripts\Nav_BIC_opvullen.vbs Klant > "D:\Scripts\Log\%Date:~6,4%%Date:~3,2%%Date:~0,2%_%Time:~0,2%u%Time:~3,2%_IBANBIC_http_post.log"
Nav_BIC_opvullen.vbs
'Tabelnaam bepalen adhv parameter
Select Case Wscript.Arguments.Item(0)
Case "Leverancier"
BIC_invullen "XXXXXXX$Vendor Bank Account","Vendor"
Case "Klant"
BIC_invullen "XXXXXXX$Customer Bank Account","Customer"
End Select
'BBAN opzoeken om een IBAN + BIC request te doen.
Function BIC_invullen(Tabelnaam,Soort)
set Cn = createobject ("ADODB.connection")
Cn.Connectionstring = "Driver={SQL Server};Server=XXXXX;Database=XXXXX;Uid=XXXXX;Pwd=XXXXX;"
Cn.open
set rs = createobject("ADODB.Recordset")
set rs.activeconnection = cn
Set HTTP = CreateObject("MSXML2.XMLHTTP")
sql = "select [Country_region Code], ["& Soort &" No_],Code, Name,[Bank Account No_], IBAN, [SWIFT Code], " & _
"RIGHT(Replace(Replace( coalesce(NULLIF(IBAN,''), [Bank Account No_]),'-',''),' ',''),12) as Rekening " & _
"from ["& Tabelnaam &"] " & _
"where ([Bank Account No_] <> '' or IBAN <> '') and [SWIFT Code] = '' "
wscript.echo sql
rs.open(sql)
If not rs.eof and not rs.bof then
i = 0
do while not Rs.EOF
wscript.echo "[Start record "&i&"]"
i = i + 1
Bericht = "Value=" & rs("Rekening")
wscript.echo Bericht
Url = "http://www.ibanbic.be/IBANBIC.asmx/BBANtoIBANandBIC"
HTTP.Open "POST", Url, False
HTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded;charset=UTF-8"
HTTP.setRequestHeader "Content-Length", Len(Bericht)
HTTP.send(Bericht)
'WScript.Echo HTTP.status
If HTTP.status = 200 Then
WScript.Echo HTTP.Statustext
'WScript.Echo "OK en antwoord is: "
'WScript.Echo HTTP.responseBody
'WScript.Echo HTTP.responseText
Antwoord = HTTP.responseText
IBAN = Mid(Antwoord, instr(Antwoord,"<string xmlns=""http://tempuri.org/"">")+36, instr(Antwoord,"#")-instr(Antwoord,"<string xmlns=""http://tempuri.org/"">")-36)
IBAN = Replace(IBAN," ","")
BIC = Mid(Antwoord, instr(Antwoord,"#")+1, instr(Antwoord,"</string>")-instr(Antwoord,"#")-1)
BIC = Replace(BIC," ","")
wscript.echo "IBAN=" & IBAN & " - BIC=" & BIC
If BIC <> "" and IBAN <> "" Then
sql = "update ["& Tabelnaam &"] " & _
"set [IBAN] = '" & IBAN & "', [SWIFT Code] = '" & BIC & "' ,[Country_region Code] = 'BE' " & _
"where ["& Soort &" No_] = '" & rs(Soort &" No_")& "' " & _
"and [Code] = '" & rs("Code")& "'"
WScript.Echo sql
Cn.execute(sql)
End if
WScript.Echo
'WScript.Echo HTTP.getAllResponseHeaders
'WScript.Echo = "OK"
Else
WScript.Echo "FOUT"
WScript.Echo HTTP.Statustext
'WScript.Echo "An error (" & LTrim(Str(oHttp.status)) & ") has occurred connecting to the server."
End If
Rs.movenext
Loop
HTTP = nothing
Else
WScript.Echo "Geen Foute IBAN - BIC gevonden"
end if
rs.Close
Set rs = Nothing
Set objMail = Nothing
End Function
Geen opmerkingen:
Een reactie posten