Andy..
13th June 2013, 15:58
Hi, I know there's a way to do this but forgot and can't work out how to search for it.
I'm doing a query on the pegging tables, from main table to another table. The result I then need to search in the main table again to find the pegged order. Can someone please remind me how to do a subquery on the same table as the main query without losing the record pointer on the 'main' table?
Thanks
mark_h
13th June 2013, 16:12
Use an alias for the subquery.
Select a.item:item
from tibom010 a
where ....
Andy..
13th June 2013, 16:14
ah yes - that's it. Thanks Mark
vahdani
14th June 2013, 10:31
Hi Andy,
here my stab at the same problem. Here I try to find the pegged sales order for a production order:
function extern long tixsfdll4000.find.pegged.sales.order.for.prod.order(
domain tcpdno i.pdno,
ref domain tcorno o.orno,
ref domain tcpono o.pono)
{
domain tcqiv1 l.demand.quan
domain tcqiv1 l.supply.quan
RETIFNOK(tcmcs.dll0095.read.parm("cprpd000"))
select demand.orno:o.orno,
demand.pono:o.pono,
supply.quan:l.supply.quan,
cprrp040.quan:l.demand.quan
from cprrp041 supply,
cprrp040,
cprrp041 demand
where supply.plnc = :cprpd000.aplc
and supply.koor = tckoor.act.sfc
and supply.orno = :i.pdno
and supply.pono = 0
and supply.kotr = tckotr.receipt
and cprrp040.plnc = supply.plnc
and cprrp040.strn = supply.trns
and demand.plnc = cprrp040.plnc
and demand.trns = cprrp040.dtrn
and demand.koor = tckoor.act.sls
and demand.kotr = tckotr.requirement
selectdo
...
endselect
}