Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Cleaning my Cursor
Message
De
12/06/2014 17:47:40
Luis Santos
Biglevel-Soluções Informáticas, Lda
Portugal
 
 
À
12/06/2014 15:20:54
Lutz Scheffler
Lutz Scheffler Software Ingenieurbüro
Dresden, Allemagne
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01601791
Message ID:
01601799
Vues:
43
Hello Lutz

I make changes to my code , and i´am create a procedure to clean my cursor myBI, but without sucess.
here my problema:
I'm currently a problem with my code because I can not clean my cursor myBI.
I have a rule that when writing my document, add the cost price of components and updates the total unit cost of my finished product.
Components in the lines of my code I keep my finished product.
What happens is that if you change the document and change the cost price of my components, my cursor shows me the data it had before, and not the new values​​.
What I want, is to clear my cursor first, and re-create the same but with new values ​​that changed.

Here is my code with my changes:

Local TemReforço as double
Local myCustoComponentes as Double
Local myPA as string

TemReforço = 0.000
myCustoComponentes = 0.000
myPA = ''

IF Inlist(bo.ndos,17)
Select bi
Scan

If Upper(bi.familia) = 'COLARIN' and bi.producao = .T. and bi.u_refPA = myPA
Text to msel textmerge noshow
Select (Case when u_reforco = 'Sim' then 0.01 else 0.02 end ) as Reforco
from st (nolock) where st.ref = ?bi.ref
Endtext

If u_sqlexec(msel,[_reforco])
TemReforço = _reforco.reforco
Endif

Text to msel textmerge noshow
Select Isnull((Case when epcpond = 0 then epcusto else epcpond end),0) as epcpond,
Isnull((Case when pcpond = 0 then pcusto else pcpond end),0) as pcpond from st (nolock) where st.ref = ?bi.ref
Endtext

If u_sqlexec(msel,[_PCM])
myEpcm = _PCM.epcpond
mypcm = _PCM.pcpond
Endif

Replace bi.epcusto with myEpcm + TemReforço
Replace bi.pcusto with mypcm + (TemReforço * 200.482)

Endif

IF Upper(bi.unidade) = 'UN' and bi.familia = 'PUNH' and bi.producao = .T.
Select BI
Replace bi.epcusto with myEpcm + 0.005
Replace bi.pcusto with mypcm + (0.005 * 200.482)
Else
IF Upper(bi.unidade) = 'PAR' and bi.familia = 'PUNH' and bi.producao = .T.
Select BI
Replace bi.epcusto with myEpcm + 0.01
Replace bi.pcusto with mypcm + (0.01 * 200.482)
Endif
Endif

IF Upper(bi.unidade) = 'UN' and bi.familia = 'PAL' and bi.producao = .T.
Select BI
Replace bi.epcusto with myEpcm + 0.005
Replace bi.pcusto with mypcm + (0.005 * 200.482)
Else
IF Upper(bi.unidade) = 'PAR' and bi.familia = 'PAL' and bi.producao = .T.
Select BI
Replace bi.epcusto with myEpcm + 0.01
Replace bi.pcusto with mypcm + (0.01 * 200.482)
Endif
Endif

IF Upper(bi.unidade) = 'UN' and bi.familia = 'PLA' and bi.producao = .T.
Select BI
Replace bi.epcusto with myEpcm + 0.005
Replace bi.pcusto with mypcm + (0.005 * 200.482)
Else
IF Upper(bi.unidade) = 'PAR' and bi.familia = 'PLA' and bi.producao = .T.
Select BI
Replace bi.epcusto with myEpcm + 0.01
Replace bi.pcusto with mypcm + (0.01 * 200.482)
Endif
Endif
Endscan

DO CalculaCustoPA
select myBI
use
Endif
Fecha([_reforco])
Fecha([_PCM])

Procedure CalculaCustoPA
Local myRefActual as String
myRefActual = ''

Select BO
IF Inlist(bo.ndos,17)
Select BI

Create Cursor myBI (RefPA C(18), CustComp N(10,3))

DO ClearCursor && calling my proc to clean my cursor before recreate a new one with my new values

select bi.u_refpa as [RefPA], sum(epcusto) as 'CustComp' from bi where composto = .T.;
into Cursor myBI READWRITE group by bi.u_refpa

Select myBI
Scan
*msg(myBI.refPA)
myRefActual = myBI.refPA
Select BI
Scan
If bi.u_refpa = myRefActual and bi.producao = .T.
Replace bi.epcusto with bi.epcusto + myBI.CustComp
Replace bi.pcusto with bi.pcusto + (myBI.CustComp * 200.482)
Endif
Endscan
Endscan
Endif
EndProc

PROCEDURE ClearCursor && my new proc to try cleaning my cursor
select myBI
=CURSORSETPROP("Buffering", 3) && Line 1
SET SAFETY OFF
DELE ALL
ZAP
ENDPROC
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform