smusba
14th November 2009, 11:10
Dear,

I want to convert the UOM to KGS for item > "5AAAAAAAAAAAA"
AND TO CONVERT UOM TO casE FOR ITEM < "5AAAAAAAAAAA".
tHIS IS MY SCRIPT.

my script is.



function double find.slsw()
{
extern domain tcorno countw
extern domain tccopr amprw
extern domain tcconv convw
countw = 0
amprw = 0.0
indtw = 0
convw =0.0

select tdsls032.*
from tdsls032
where tdsls032.cpls = "W01"
and tdsls032.item = :ticpr300.item
and tdsls032.stdt <= :indt.f
order by tdsls032.item desc, tdsls032.stdt desc, tdsls032.pric desc
as set with 1 rows
selectdo
if tdsls032.item < "5ISC37002008" then

select tiitm004.*,tdsls037.*
from tiitm004,tdsls037
|where tiitm004.basu = "KGS"
where tiitm004.unit = tdsls037.cuni
and tdsls037.cpls = :tdsls032.cpls
and tiitm004.basu = "KGS"
and tdsls037.item = :tiitm001.item
selectdo
if countw = 1 then
else
indtw = tdsls032.stdt
convw = tiitm004.conv
amprw = tdsls032.pric /convw
countw = countw + 1
endif
endselect
else

select tiitm004.*,tdsls037.cuni
from tiitm004,tdsls037
|where tiitm004.basu = "KGS"
|where tiitm004.unit = tdsls037.cuni
where tdsls037.cpls = :tdsls032.cpls
and tiitm004.basu = "CAS"
and tdsls037.item = :tiitm001.item
selectdo
if countw = 1 then
else
indtw = tdsls032.stdt
convw = tiitm004.conv
amprw = tdsls032.pric /convw
countw = countw + 1
endif
endselect
endif
endselect
convw =0.0
return(amprw)
}

sameer.don
14th November 2009, 11:24
if cone isnt working , the replace folloing line as
Line:
if tdsls032.item < "5ISC37002008" then

Replace With:
if strip$(shiftl$(tdsls032.item)) < "5ISC37002008" then

smusba
14th November 2009, 12:13
I didn't help

mark_h
17th November 2009, 16:03
How is the code not working? What item is failing?

kbartelds
18th November 2009, 16:50
and tdsls037.item = :tiitm001.item
shouldn't this be tiitm004.item or tdsls032.item?

Klaas

sameer.don
19th November 2009, 06:52
Smusba,
we need to know at what point exactly your code is facing problem.

Is it with item code comparision or is there the problem with SQL query.
Plz elaborate the problem in detail with and examle.

And if the proble is with the "if" statment, you must consider the alignment which matters during string comparision.
for eg. string "5Z" will be considered greater than string "5AAAAA" when it is left aligned.However, doamin tcitem being right aligned, " 5AAAAA "will be greater than " 5z". This is why I had suggested you to use strip$(shiftl$()) which left aligns the string removing trailing space.

But, we need an example of your problem to suggest you the solution.

smusba
21st November 2009, 07:00
Dear All,

Thank you guys. The problem was solved.


Regards,
Suhaib