Tabla con los RUC de todas las empresas - Sunat

514 views
Skip to first unread message

LUIS GARCIA LLANOS

unread,
Feb 6, 2013, 6:49:49 PM2/6/13
to publice...@googlegroups.com
Amigos del foro:
Alguien que sepa como bajar la tabla de los ruc de las empreasas a nivel nacional
Gracias por la ayuda.

Luis Mata

unread,
Feb 7, 2013, 8:59:35 AM2/7/13
to publice...@googlegroups.com
Av. Wilson...

Richard Gaviria

unread,
Feb 7, 2013, 9:49:05 AM2/7/13
to publice...@googlegroups.com
Este código lo copié de alguna respuesta de este grupo, te permite hacer la consulta del ruc en línea con SUNAT usando el número de ruc, o puedes usar el número dni creando un código que recorra del 0 al 9 para obtener el código verificador.
 
Local XRUC As String
Declare Long
InternetAttemptConnect In "wininet" Long dwReserved
If InternetAttemptConnect(0) = 0
XRUC =
Thisform.Txruc.Value
#Define CRLF Chr(13)+Chr(10)
Local oErr As Exception
Local
cStr As Character
Local
SW As Boolean
SW = .T.
Local loXmlHttp As Microsoft.XMLHTTP,;
lcURL
As String,;
lcHTML
As String,;
lcTexto
As String,;
lcFile
As String
loXmlHttp = Createobject("Microsoft.XMLHTTP")
lcURL = "http://www.sunat.gob.pe/w/wapS01Alias?ruc="+XRUC
loXmlHttp.
Open("POST" , lcURL, .F.)
loXmlHttp.Send
* Wait Window "Consultando a la SUNAT..." Nowait
Do While loXmlHttp.readyState<>4 Or loXmlHttp.Status <>200
Enddo
lcHTML = loXmlHttp.Responsetext
lcTexto =
Chrtran(Alltrim(lcHTML),Chr(10),"")
*/Para los delimitadores
lcTexto = Strtran(lcTexto, "N&#xFA;mero Ruc. </b> " + XRUC + " -","RazonSocial:")
lcTexto =
Strtran(lcTexto, "Estado.</b>","Estado:")
lcTexto =
Strtran(lcTexto, "Agente Retenci&#xF3;n IGV.</strong>","ARIGV:")
lcTexto =
Strtran(lcTexto, "Direcci&#xF3;n.</b><br/>","Direccion:")
lcTexto =
Strtran(lcTexto, "Situaci&#xF3;n.<b> ","Situacion:")
lcTexto =
Strtran(lcTexto, "Tel&#xE9;fono(s).</b><br/>","Telefono:")
lcTexto =
Strtran(lcTexto, "Dependencia.","Dependencia:")
lcTexto =
Strtran(lcTexto, "Tipo.</b><br/> ","TipoPer:")
lcTexto =
Strtran(lcTexto, "DNI</b> : ","DNI:")
lcTexto =
Strtran(lcTexto, "Fecha Nacimiento.</b> ","FechNac:")
lcTexto =
Strtran(lcTexto, Space(05),Space(01))
lcTexto =
Strtran(lcTexto, Space(04),Space(01))
lcTexto =
Strtran(lcTexto, Space(03),Space(01))
lcTexto =
Strtran(lcTexto, Space(02),Space(01))
lcTexto =
Strtran(lcTexto, Chr(09),"")
*** RAZON SOCIAL ***
PosIni = At("RazonSocial:", lcTexto)+12
PosFin =
At("<br/></small>", lcTexto)-(At("RazonSocial:", lcTexto)+12)
xRazSocial =
Substr(lcTexto,PosIni,PosFin)
xRazSocial =
Strtran(xRazSocial,"&#209;","Ñ")
xRazSocial =
Strtran(xRazSocial , "&#xD1;", "Ñ")
xRazSocial =
Strtran(xRazSocial , "&#193;", "Á")
xRazSocial =
Strtran(xRazSocial , "&#201;", "É")
xRazSocial =
Strtran(xRazSocial , "&#205;", "Í")
xRazSocial =
Strtran(xRazSocial , "&#211;", "Ó")
xRazSocial =
Strtran(xRazSocial , "&#218;", "Ú")
xRazSocial =
Strtran(xRazSocial , "&#xC1;", "Á")
xRazSocial =
Strtran(xRazSocial , "&#xC9;", "É")
xRazSocial =
Strtran(xRazSocial , "&#xCD;", "Í")
xRazSocial =
Strtran(xRazSocial , "&#xD3;", "Ó")
xRazSocial =
Strtran(xRazSocial , "&#xDA;", "Ú")
lcFile= "Datos_Contribuyente.txt"
Strtofile(xRazSocial+Chr(13)+Chr(10), lcFile)
*** ESTADO ***
PosIni = At("Estado:", lcTexto)+7
PosFin = (
At("ARIGV", lcTexto)-32)-(At("Estado:", lcTexto)+7)
xEst =
Substr(lcTexto,PosIni,PosFin)
Strtofile(xEst+Chr(13)+Chr(10) , lcFile,1)
*** AGENTE RETENEDOR IGV ***
PosIni = At("ARIGV:", lcTexto)+18
PosFin =
At("ARIGV:", lcTexto)+20-(At("ARIGV:", lcTexto)+18)
xAR =
Substr(lcTexto,PosIni,PosFin)
Strtofile(xAR+Chr(13)+Chr(10), lcFile,1)
*** DIRECCION ***
PosIni = At("Direccion:", lcTexto)+10
PosFin =
At("</b></small><br/>", lcTexto)-38-(At("Direccion:",lcTexto)+10)
xDir =
Substr(lcTexto,PosIni,PosFin)
xDir =
Strtran(xDir, "&#209;", "Ñ")
xDir =
Strtran(xDir, "&#xD1;", "Ñ")
xDir =
Strtran(xDir, "&#193;", "Á")
xDir =
Strtran(xDir, "&#201;", "É")
xDir =
Strtran(xDir, "&#205;", "Í")
xDir =
Strtran(xDir, "&#211;", "Ó")
xDir =
Strtran(xDir, "&#218;", "Ú")
xDir =
Strtran(xDir, "&#xC1;", "Á")
xDir =
Strtran(xDir, "&#xC9;", "É")
xDir =
Strtran(xDir, "&#xCD;", "Í")
xDir =
Strtran(xDir, "&#xD3;", "Ó")
xDir =
Strtran(xDir, "&#xDA;", "Ú")
Strtofile(xDir+Chr(13)+Chr(10), lcFile,1)
*** SITUACION ***
PosIni = At("Situacion:", lcTexto)+10
PosFin =
At("</b></small><br/>", lcTexto)-(At("Situacion:", lcTexto)+10)
xCond =
Substr(lcTexto,PosIni,PosFin)
Strtofile(xCond+Chr(13)+Chr(10), lcFile,1)
*** TELEFONO ***
PosIni = At("Telefono:", lcTexto)+9
PosFin =
At("Dependencia:", lcTexto)-25-(At("Telefono:", lcTexto)+9)
xTelef =
Substr(lcTexto,PosIni,PosFin)
Strtofile(xTelef+Chr(13)+Chr(10), lcFile,1)
*** TIPO DE PERSONA ***
PosIni = At("TipoPer:", lcTexto)+8
PosFin =
At("DNI:", lcTexto)-29-(At("TipoPer:", lcTexto)+8)
xTipoPer =
Substr(lcTexto,PosIni,PosFin)
Strtofile(xTipoPer+Chr(13)+Chr(10), lcFile,1)
*** DNI ***
PosIni = At("DNI:", lcTexto)+4
PosFin =
At("FechNac:", lcTexto)-25-(At("DNI:", lcTexto)+4)
xDNI =
Substr(lcTexto,PosIni,PosFin)
Strtofile(xDNI+Chr(13)+Chr(10), lcFile,1)
*** FECHA DE NACIMIENTO ***
PosIni = At("FechNac:", lcTexto)+8
PosFin =
At("FechNac:", lcTexto)+18-(At("FechNac:", lcTexto)+8)
xFechNac =
Substr(lcTexto,PosIni,PosFin)
Strtofile(xFechNac, lcFile,1)
endif

 
A este código yo le hice algunas adaptaciones, pero esto es lo mas cercano al código original que copié, espero te sirva.

Saludos

Rick.

 

From: lm...@cclf.com.pe
To: publice...@googlegroups.com
Subject: Re: [vfp] Tabla con los RUC de todas las empresas - Sunat
Date: Thu, 7 Feb 2013 08:59:35 -0500

Roberto Lemos

unread,
Feb 7, 2013, 7:14:13 PM2/7/13
to publice...@googlegroups.com
Muy bueno el código estuve haciendo algunas pruebas, solo una duda, solo se puede extraer datos de los campos con TextBox, en el caso de los Combo, no retorna ninguna valor. alguna idea?
 
Saludos
 
Roberto Lemos

Richard Gaviria

unread,
Feb 7, 2013, 7:18:15 PM2/7/13
to publice...@googlegroups.com
A que combos te refieres?


 
Saludos

Rick.

 

To: publice...@googlegroups.com
Subject: Re: [vfp] Tabla con los RUC de todas las empresas - Sunat
Date: Thu, 7 Feb 2013 19:14:13 -0500

Roberto Lemos

unread,
Feb 7, 2013, 8:09:36 PM2/7/13
to publice...@googlegroups.com
Si ejecutas el ejemplo, no muestra si el contribuyente es Agente de Retencion o no

Richard Gaviria

unread,
Feb 7, 2013, 10:27:04 PM2/7/13
to publice...@googlegroups.com
Ahhhh, ok dejame verlo porque yo lo utilicé para validar los RUCS en mi planilla para C.A.S.

Saludos

Rick.



From: lemo...@gmail.com
To: publice...@googlegroups.com
Subject: Re: [vfp] Tabla con los RUC de todas las empresas - Sunat
Date: Thu, 7 Feb 2013 20:09:36 -0500
Reply all
Reply to author
Forward
0 new messages