Information générale
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Network:
Windows 2008 Server
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
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement