smusba
25th May 2008, 11:51
Dear Gurus,

I had written a code on print cummulative average purchase price for only purchased item succesfully.
Now,the user want me to show the items both that are purchase and unpurchased items.
I have attached my source code . :)could you please help me out to code for unpurchased item. Thanx in advance.



Suhaib

mark_h
26th May 2008, 01:57
What are you calling unpurchased? How would you do it by hand? Look at the sessions that would provide you that information - find the tables you need. I do not think you will get someone to write the code for you, but we will assist as we can.

smusba
27th May 2008, 08:53
hi ,

I mean the data that is in tiitm001 of the type purchase is only displayed .
i want to display both purchase and generic in the same report. Here is my code

functions:
function read.main.table()
{
oqua = 0.0
toqua = 0.0
dqua = 0.0
tdqua = 0.0
bqua = 0.0
tbqua = 0.0
pric = 0.0
amta = 0.0
amnt = 0.0
tamta = 0.0
tamnt = 0.0
avgstd = 0.0
stdval = 0.0
tstdval = 0.0
fitr.f = tcfitr.on.order
fitr.t = tcfitr.result
item1 = ""
itemkgs = 0.0
itemqty = 0.0
itemamt = 0.0

select tdpur045.*
from tdpur045
where tdpur045.item inrange :item.f and :item.t
and tdpur045.date inrange :date.f and :date.t
and tdpur045.suno inrange :suno.f and :suno.t
and tdpur045.cwar inrange :cwar.f and :cwar.t
|and tdpur045.srnb > 0
|and tdpur045.invn <= 0
and tdpur045.spur > 3
order by tdpur045.item
selectdo

if item= tdpur045.item then
else

itemkgs = 0.0
itemamt = 0.0
endif

select tdpur041.*
from tdpur041
where tdpur041.orno = :tdpur045.orno
and tdpur041.pono = :tdpur045.pono
and tdpur041.item = :tdpur045.item
selectdo
kgs = tdpur041.cvqp * tdpur045.dqua
endselect

select tdpur040.*
from tdpur040
where tdpur040.orno = :tdpur045.orno
selectdo

tdpur045.amnt = tdpur045.amnt * tdpur040.ratp

endselect

itemkgs = itemkgs + kgs

itemamt = itemamt + tdpur045.amnt

select tccom020.*
from tccom020
where tccom020.suno = :tdpur045.suno
selectdo
endselect



select tiitm001.*
from tiitm001
where tiitm001.item = :tdpur045.item

selectdo
endselect

item = tdpur045.item
rprt_send()
endselect
}

mark_h
27th May 2008, 16:59
The problem is I do not know what you mean by generic on your system. What your report currently shows are receipts for purchased items. It is easy to combine a second set of data into the same report. I just do not know how to get the data on your system. Can't you just do a select on the item master for non-purchased parts?

What I typically do when combining to sets of data like this is to define rpt variable fields. So for example lets say I wanted to report Purchase Items from tdpu041 and manufacturing items from tisfc001 into the same report. Then I would define some report fields in the session script - example rpt.item, rpt.orno, rpt.qty. Then I would perform two selects like below(did not verify field names). I can explain what I do, but not do it for you since I do not know your system.

extern domain tcorno rpt.orno
extern domain tcitem rpt.item
extern domain tcmcs.long rpt.qty

| same report routine
select tisfc001.*
from tisfc001
where [some condition]
selectdo
rpt.item = tisfc001.mitm
rpt.orno = tisfc001.orno
rpt.qty = tisfc001.qrdr
rprt_send()
endselect
|now do same for tdpur041
select tdpur041.*
from tdpur041
where [some condition]
selectdo
rprt.item = tdpur041.item
.....
rprt_send()
endselect