smusba
26th February 2023, 10:47
In the below script the select statement should match only if the condition satisfy with 2 rows else the script should be ignored. Please support me to write the script.

function check.for.zero.price()
{
select al1401.orno,al1401.item,al1401.ttyp.c,min(al1401.pric):min.pric
from tdsls401 al1401
where al1401._index1 ={:g.orno}
and al1401.item =:g.item
and al1401.ttyp.c = :g.ttyp.c
group by al1401.orno,al1401.item,al1401.ttyp.c
as set with 2 rows
selectdo
endselect

if min.pric <> 0 then
c.flag = 9
|remarks = "Price"
endif

}

vahdani
26th February 2023, 13:37
Here is how I would do it:



function check.for.zero.price()
{
long l.number.of.rows

select count(*)l.number.of.rows,
min(al1401.pric):min.pric
from tdsls401 al1401
where al1401._index1 ={:g.orno}
and al1401.item =:g.item
and al1401.ttyp.c = :g.ttyp.c
selectdo
if l.number.of.rows = 2 then
if double.cmp(min.pric, 0.0, 0.001)= 0 then
|min.pric = 0.0!!
c.flag = 9
|remarks = "Price"
endif
endif
endselect
}