Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Error to copy content of XML file to Cursor
Message
From
08/02/2022 14:11:51
Luis Santos
Biglevel-Soluções Informáticas, Lda
Portugal
 
 
To
08/02/2022 08:07:20
Lutz Scheffler (Online)
Lutz Scheffler Software Ingenieurbüro
Dresden, Germany
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01683464
Message ID:
01683479
Views:
26
>Hi Luis.
>
>I need to run the code and see what fails - to do it with just looking is to much for this day.
>
>>docomando fails while looking into the code ...
>>
>>looking through it w/o running it. Well that's large
>>
>>;)
>>
>>Hi Lutz,
>>
>>Thanks for your reply, but can you suggest me another method that be able to read all the XML file content inserting the values into my cursor crstmp !?
>>A small example based on my code would be fantastic :)
>>
>>Curiously, on my XML file i have 2 days : 05.02.2022 and 06.02.2022, this problem occurs only if i try to insert 1 Day, ex: 07.02.2022, but if i specifie from 05.02.2022 to 07.02.2022, everything work !!??
>>Sincerely, i don´t understand why ?
>>
>>I send you in attachment Zip file for theses 2 days.
>>
>>Best regards,
>>Luis
>>
>>Many thanks,
>
>Hi Lutz,
>
>I understand !
>
>I try this little approach using xmlAdapter:
>
>cFile = "c:\phc24\dossiers.xml"
>adapter = CREATEOBJECT("XMLAdapter")
>adapter.LoadXML(cFile,.T.)
>adapter.tables(1).ToCursor()
>
>But i receive this error:
>Index or experession does not match an existing member of the collection
>
>Sorry and thanks again,
>
>Luis

Luis,
to get rid of all overhead
What does a simple CURSORTOXML()?
XMLTOCURSOR("c:\phc24\dossiers.xml")
If this fails.
#1 Open the XML with a web-browser and see what happens
#2 Try to reduce the XML step by step - remove all records but one, and then field by field.

let me know the result - I can look into the file later on, but those are simple steps.

Hi Lutz,

If i use :
    XMLTOCURSOR("c:\phc24\dossiers.xml")
i have no error.
#1 i can open on browser the xml file corretly formatted without problems.
#2 I just keep one line to my xml file renaming it to dossiernew, also, i disabled the caaling to API.
the problem is when on the IF Clause , because if i comment them like in code above mking browse to crstmp return the result.
Local loJson
Local lcJsonStr
Local lnSuccess
Local loartigos
Local lnNumArtigos
Local i
Local loArtObj
Local lnDos
Local lnContador
Local lnArm
Local lnCl
Local lnEstabt

lnCl = 443
lnEstab = 7 &&Loja ECI Gaia
lnDos = 323 &&Sales Report

lnCl_l = 50002 &&80001
lnEstab_l = 0 &&0 &&Loja ECI Gaia
lnDos_l = 323  &&340 &&Sales Report

lnContador = 0
lnArm = 91 &&113  &&Loja ECI Gaia

*!* Qual a data da ultima alteração

Create Cursor xVars ( no N(5), tipo c(1), Nome c(40), Pict c(100), lOrdem N(10), tbVal m, nValor N(18,5), cValor c(250),mValor m, lValor l, dValor d )

Select xVars
Append Blank
Replace xVars.no With 1
Replace xVars.tipo With "D"
Replace xVars.Nome With "Desde a Data"
Replace xVars.Pict With "##.##.####"
Replace xVars.lOrdem With 1
Replace xVars.dValor With (Date() - 1)

m.mCaption = "Artigos alterados desde a datas...?"
m.escolheu=.F.
docomando("do form usqlvar with 'xvars',m.mCaption")

If m.escolheu=.T.

	Select xVars
	Go Top
	Locate For xVars.no=1
	pd_data=xVars.dValor
	If datavazia(xVars.dValor)
		pd_data = Date()-1
	Endif

	If pd_data <= Ctod('31.01.2020')
		msg("Não pode importar entradas com data inferior a 31-01-2020")
	Else

		Try
			Xmltocursor('dossiersnovo.xml','dossiersnew',512)
			*browse

			lnNumDossiers = Reccount("dossiersnew")
		Catch To oError When .T.
			lnNumDossiers=0
			msg("Não existem nada a importar!")

		Endtry

		If lnNumDossiers > 0

			* Criar cursor para conteudo do ficheiro
			Create Cursor crstmp (bostamp c(25), bistamp c(25), dataobra d ,ref c(18), qtt N(19,6), lote c(40), obrano c(10), lOrdem N(10), Design c(60))


			Select dossiersnew
			Scan

				*!* If Alltrim(dossiersnew.u_glnentr) = '5600000025963' And VAL(dossiersnew.qtt) <> 0  ««««--Probelm When i use this IF
					Select crstmp
					Append Blank
					Replace crstmp.dataobra With Ctod(Substr(dossiersnew.dataobra,9,2) +'.'+Substr(dossiersnew.dataobra,6,2) +'.'+Substr(dossiersnew.dataobra,1,4))
					Replace crstmp.bostamp With Alltrim(dossiersnew.bostamp)
					Replace crstmp.bistamp With Alltrim(dossiersnew.bistamp)
					Replace crstmp.ref With Alltrim(dossiersnew.ref)
					Replace crstmp.qtt With dossiersnew.qtt
					Replace crstmp.lote With Alltrim(dossiersnew.lote)
					Replace crstmp.obrano With astr(dossiersnew.obrano)
					Replace crstmp.Design With Alltrim(dossiersnew.Design)
					Replace crstmp.lOrdem With dossiersnew.lOrdem
				*!* Endif 

			Endscan


			* Criar dossier por bostamp distinto.

			Select crstmp
			browse   ««« - Work ok and return the data
			return
the error occur when using the IF With  " VAL(dossiersnew.qtt) <> 0 " after SCAN:

 If Alltrim(dossiersnew.u_glnentr) = '5600000025963' And VAL(dossiersnew.qtt) <> 0
Note : if i use only :  If Alltrim(dossiersnew.u_glnentr) = '5600000025963' , that work fine !

Linha: 76
Mensagem 1: Function argument value, type, or count is invalid.
Mensagem 2: create cursor dossiersnew from array _XMLArray_B8468283_C239_4DA8_B4B2_49FAD15EB656_
Many thanks,
Luis
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform