smusba
2nd April 2012, 11:09
Dear Gurus,
I have a script which gives me the Supplier movement detail but if "DEBIT AND CREDIT" are both zero then it doesnot print the report. Kindly verify my script for the same.
functions:
function read.main.table()
{
cbal = 0.0
dbal = 0.0
|clbal = 0.0
select tccom020.* from tccom020
where tccom020._index1 inrange {:cuno.f} and {:cuno.t}
|where tccom020._index1 = {:cuno.f}
order by tccom020._index1
selectdo
|op.bal()
op.bal = opbal(tccom020.suno)
balance = 0
debit = 0
credit = 0
clbal = op.bal
if op.bal >= 0.0 then
dbal = op.bal
cbal = 0.0
else
cbal = op.bal*-1
dbal = 0.0
endif
select tfacp200.*
from tfacp200
where tfacp200._index2 = {:tccom020.suno}
and (tfacp200.tdoc = "")
|or tfacp200.tpay = tfacp.tpay.normal
|or tfacp200.cdam <> 0)
|and tfacp200.year = :year
|and tfacp200.prod between :prod.f and :prod.t
and tfacp200.docd between :indt.f and :indt.t
order by tfacp200.suno,tfacp200.docd
selectdo
balance = 0.0
debit = 0.0
credit = 0.0
balance = 0
select sum(tfacp200.amth):balance
from tfacp200
where tfacp200._index1 = {:tfacp200.ttyp, :tfacp200.ninv, :tfacp200.line}
and tfacp200.tdoc <> ""
and tfacp200.docd between :indt.f and :indt.t
selectdo
endselect
if tfacp200.amth + balance = 0 then
continue
endif
tfacp200.amth = tfacp200.amth + balance
tfacp200.amth = tfacp200.amth * -1
if tfacp200.amth < 0 then
credit = tfacp200.amth * -1 + tfacp200.cdam
else
debit = tfacp200.amth + tfacp200.cdam
endif
balance = debit - credit
clbal = clbal+balance
rprt_Send()
continue
if tfacp200.tpay = tfacp.tpay.assignment and tfacp200.docn > 0 then
else
if tfacp200.tpay = tfacp.tpay.invoice then
credit = tfacp200.amth
debit = 0
balance = debit - credit
clbal = clbal+balance
endif
if tfacp200.tpay = tfacp.tpay.credit then
if tfacp200.docn > 0 and not isspace(tfacp200.tdoc) then
else
if tfacp200.amth > 0 then
credit = tfacp200.amth
debit = 0
balance = debit - credit
clbal = clbal+balance
else
debit = tfacp200.amth*-1
credit = 0
balance = debit - credit
clbal = clbal+balance
endif
endif
endif
if (tfacp200.tpay = tfacp.tpay.normal
or tfacp200.tpay = tfacp.tpay.advance
or tfacp200.tpay = tfacp.tpay.unallocated) then
debit = tfacp200.amth*-1
credit = 0
balance = debit - credit
clbal = clbal+balance
endif
if credit = 0.0 and debit = 0.0 then
else
rprt_send()
|initialise()
endif
endif
endselect
if indt.f <> 0 then
select tfacp200.*
from tfacp200
where tfacp200._index2 = {:tccom020.suno}
and (tfacp200.tpay in (14, 2))
|or tfacp200.tpay = tfacp.tpay.normal
|or tfacp200.cdam <> 0)
|and tfacp200.year = :year
|and tfacp200.prod between :prod.f and :prod.t
and tfacp200.docd between :indt.f and :indt.t
order by tfacp200.suno,tfacp200.docd
selectdo
balance = 0.0
debit = 0.0
credit = 0.0
balance = 0
select tfacp200.amth:balance, tfacp200.tpay
from tfacp200
where tfacp200._index1 = {:tfacp200.ttyp, :tfacp200.ninv, :tfacp200.line}
and tfacp200.tdoc = ""
and tfacp200.docd < :indt.f
selectdo
tfacp200.amth = tfacp200.amth * -1 |+ tfacp200.cdam
debit = tfacp200.amth
balance = debit - credit
if tfacp200.amth < 0 then
credit = abs(tfacp200.amth)
debit = 0
endif
clbal = clbal+balance
|*if balance = 0.0 then
if credit = 0.0 and debit = 0.0 then
else
rprt_Send()
endif
endselect
endselect
endif
endselect
}
function double opbal(domain tcsuno cuop)
{
extern domain tfgld.amnt bal,debit.amt,credit.amt
extern domain tfgld.prod prod.f1,prod.t1,prod1
prod1 = prod.f - 1
if prod1 = 0 then
prod.f1 = 1
prod.t1 = 12
else
prod.f1 = 1
prod.t1 = prod1
endif
fyer = year - 1
indt = indt.f - 1
bal = 0.0
select sum(tfacp200.amth):tfacp200.amth, sum(tfacp200.cdam):tfacp200.cdam
|select tfacp200.suno,tfacp200.docd,tfacp200.amth,tfacp200.ttyp,tfacp200.ninv,tfacp200.balh,tfacp200.prod,tfacp200.year
from tfacp200
where tfacp200._index2 = {:cuop}
|and tfacp200.tdoc = ""
|and tfacp200.year <= :fyer
|and tfacp200.prod between :prod.f1 and :prod.t1
and tfacp200.docd < :indt.f
|order by tfacp200.suno,tfacp200.docd
selectdo
|*bal = bal - tfacp200.amth + tfacp200.cdam
|*continue
if tfacp200.tpay = tfacp.tpay.invoice then
credit.amt = tfacp200.amth
debit.amt = 0
bal = bal + debit.amt - credit.amt
|cl.bal = cl.bal+balance.amt
endif
if (tfacp200.tpay = tfacp.tpay.credit and tfacp200.docn = 0) then
if tfacp200.amth > 0 then
credit.amt = tfacp200.amth
debit.amt = 0
bal = bal + debit.amt - credit.amt
|cl.bal = cl.bal+balance.amt
else
debit.amt = tfacp200.amth * -1
credit.amt = 0
bal = bal + debit.amt - credit.amt
|cl.bal = cl.bal+balance.amt
endif
endif
if (tfacp200.tpay = tfacp.tpay.normal
or tfacp200.tpay = tfacp.tpay.advance
or tfacp200.tpay = tfacp.tpay.unallocated) then
debit.amt = tfacp200.amth*-1
credit.amt = 0
bal = bal + debit.amt - credit.amt
|cl.bal = cl.bal+balance.amt
endif
endselect
return(bal)
}
I have a script which gives me the Supplier movement detail but if "DEBIT AND CREDIT" are both zero then it doesnot print the report. Kindly verify my script for the same.
functions:
function read.main.table()
{
cbal = 0.0
dbal = 0.0
|clbal = 0.0
select tccom020.* from tccom020
where tccom020._index1 inrange {:cuno.f} and {:cuno.t}
|where tccom020._index1 = {:cuno.f}
order by tccom020._index1
selectdo
|op.bal()
op.bal = opbal(tccom020.suno)
balance = 0
debit = 0
credit = 0
clbal = op.bal
if op.bal >= 0.0 then
dbal = op.bal
cbal = 0.0
else
cbal = op.bal*-1
dbal = 0.0
endif
select tfacp200.*
from tfacp200
where tfacp200._index2 = {:tccom020.suno}
and (tfacp200.tdoc = "")
|or tfacp200.tpay = tfacp.tpay.normal
|or tfacp200.cdam <> 0)
|and tfacp200.year = :year
|and tfacp200.prod between :prod.f and :prod.t
and tfacp200.docd between :indt.f and :indt.t
order by tfacp200.suno,tfacp200.docd
selectdo
balance = 0.0
debit = 0.0
credit = 0.0
balance = 0
select sum(tfacp200.amth):balance
from tfacp200
where tfacp200._index1 = {:tfacp200.ttyp, :tfacp200.ninv, :tfacp200.line}
and tfacp200.tdoc <> ""
and tfacp200.docd between :indt.f and :indt.t
selectdo
endselect
if tfacp200.amth + balance = 0 then
continue
endif
tfacp200.amth = tfacp200.amth + balance
tfacp200.amth = tfacp200.amth * -1
if tfacp200.amth < 0 then
credit = tfacp200.amth * -1 + tfacp200.cdam
else
debit = tfacp200.amth + tfacp200.cdam
endif
balance = debit - credit
clbal = clbal+balance
rprt_Send()
continue
if tfacp200.tpay = tfacp.tpay.assignment and tfacp200.docn > 0 then
else
if tfacp200.tpay = tfacp.tpay.invoice then
credit = tfacp200.amth
debit = 0
balance = debit - credit
clbal = clbal+balance
endif
if tfacp200.tpay = tfacp.tpay.credit then
if tfacp200.docn > 0 and not isspace(tfacp200.tdoc) then
else
if tfacp200.amth > 0 then
credit = tfacp200.amth
debit = 0
balance = debit - credit
clbal = clbal+balance
else
debit = tfacp200.amth*-1
credit = 0
balance = debit - credit
clbal = clbal+balance
endif
endif
endif
if (tfacp200.tpay = tfacp.tpay.normal
or tfacp200.tpay = tfacp.tpay.advance
or tfacp200.tpay = tfacp.tpay.unallocated) then
debit = tfacp200.amth*-1
credit = 0
balance = debit - credit
clbal = clbal+balance
endif
if credit = 0.0 and debit = 0.0 then
else
rprt_send()
|initialise()
endif
endif
endselect
if indt.f <> 0 then
select tfacp200.*
from tfacp200
where tfacp200._index2 = {:tccom020.suno}
and (tfacp200.tpay in (14, 2))
|or tfacp200.tpay = tfacp.tpay.normal
|or tfacp200.cdam <> 0)
|and tfacp200.year = :year
|and tfacp200.prod between :prod.f and :prod.t
and tfacp200.docd between :indt.f and :indt.t
order by tfacp200.suno,tfacp200.docd
selectdo
balance = 0.0
debit = 0.0
credit = 0.0
balance = 0
select tfacp200.amth:balance, tfacp200.tpay
from tfacp200
where tfacp200._index1 = {:tfacp200.ttyp, :tfacp200.ninv, :tfacp200.line}
and tfacp200.tdoc = ""
and tfacp200.docd < :indt.f
selectdo
tfacp200.amth = tfacp200.amth * -1 |+ tfacp200.cdam
debit = tfacp200.amth
balance = debit - credit
if tfacp200.amth < 0 then
credit = abs(tfacp200.amth)
debit = 0
endif
clbal = clbal+balance
|*if balance = 0.0 then
if credit = 0.0 and debit = 0.0 then
else
rprt_Send()
endif
endselect
endselect
endif
endselect
}
function double opbal(domain tcsuno cuop)
{
extern domain tfgld.amnt bal,debit.amt,credit.amt
extern domain tfgld.prod prod.f1,prod.t1,prod1
prod1 = prod.f - 1
if prod1 = 0 then
prod.f1 = 1
prod.t1 = 12
else
prod.f1 = 1
prod.t1 = prod1
endif
fyer = year - 1
indt = indt.f - 1
bal = 0.0
select sum(tfacp200.amth):tfacp200.amth, sum(tfacp200.cdam):tfacp200.cdam
|select tfacp200.suno,tfacp200.docd,tfacp200.amth,tfacp200.ttyp,tfacp200.ninv,tfacp200.balh,tfacp200.prod,tfacp200.year
from tfacp200
where tfacp200._index2 = {:cuop}
|and tfacp200.tdoc = ""
|and tfacp200.year <= :fyer
|and tfacp200.prod between :prod.f1 and :prod.t1
and tfacp200.docd < :indt.f
|order by tfacp200.suno,tfacp200.docd
selectdo
|*bal = bal - tfacp200.amth + tfacp200.cdam
|*continue
if tfacp200.tpay = tfacp.tpay.invoice then
credit.amt = tfacp200.amth
debit.amt = 0
bal = bal + debit.amt - credit.amt
|cl.bal = cl.bal+balance.amt
endif
if (tfacp200.tpay = tfacp.tpay.credit and tfacp200.docn = 0) then
if tfacp200.amth > 0 then
credit.amt = tfacp200.amth
debit.amt = 0
bal = bal + debit.amt - credit.amt
|cl.bal = cl.bal+balance.amt
else
debit.amt = tfacp200.amth * -1
credit.amt = 0
bal = bal + debit.amt - credit.amt
|cl.bal = cl.bal+balance.amt
endif
endif
if (tfacp200.tpay = tfacp.tpay.normal
or tfacp200.tpay = tfacp.tpay.advance
or tfacp200.tpay = tfacp.tpay.unallocated) then
debit.amt = tfacp200.amth*-1
credit.amt = 0
bal = bal + debit.amt - credit.amt
|cl.bal = cl.bal+balance.amt
endif
endselect
return(bal)
}