Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Cleaning my Cursor
Message
De
12/06/2014 14:10:11
 
 
À
12/06/2014 12:52:44
Luis Santos
Biglevel-Soluções Informáticas, Lda
Portugal
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:
01601794
Vues:
56
Is there any reason to make the myBI cursor READWRITEable?

I'm not sure I understood your code clearly and might be failling here with your question but, anyway, if you create a cursor with that name prior to SELECT INTO it, you can be sure that it will be empty before the selection.
CREATE CURSOR myBI (dummy M)
select bi.u_refpa as [RefPA], sum(epcusto) as 'CustComp' from bi where composto = .T. into Cursor myBI group by bi.u_refpa
>Hello comunity
>
>I have build this code to calculate the cost amount of my Final product, but i need to clean my cursor "myBI", because if i save my document, my cursor myBI show me the the correct values, but if i change theses valuse and save my document and make a BROW to my cursor, the same show me the old values.
>
>Here is my code:
>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
>
>Endif
>Fecha([_reforco])
>Fecha([_PCM])
>
>Procedure CalculaCustoPA
>Local myRefActual as String
>myRefActual = ''
>
>Select BO
>IF Inlist(bo.ndos,17)
>Select BI
>
>
> 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
> *Brow
> *return
> Select myBI
> Scan
> myRefActual = myBI.refPA
> Select BI
> 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
>
>Endif
>EndProc
>
>Could someone give me help to clean my cursor myBI before recreate them.
>
>Many thanks
>Luis Santos
----------------------------------
António Tavares Lopes
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform