ConradMollink
21st December 2007, 16:40
I am busy creating an AFS function for the maintain receipts session in Baan 4
tdpur4120m000

Sometimes the session zooms to the session tdilc4113s000.

Is there an easy way to determine if this session pops up?

mark_h
21st December 2007, 19:02
Search for my login(mark_h) and tdilc4113s000. You should find code on how I handle this situation. Basically I do a series of tests to see if I need to handle the subsession. I am not positive I have all possibilities covered, but it works for us.

mark_h
21st December 2007, 19:07
Never mind - the code is old in those other posts. Keep in mind I create a receipt first, then modify the receipt. I do this because we may have 4 lines on PO for 10 each, the vendor ships in 40 parts. On my receipt screen the user provides the po and 40(well a little more info than that, but not much) and I go receive all lines for them based off need date. Just how I solved it, but there might be a better way.

function extern modify_receipt( domain tcrcno receipt.number,
domain tcorno purchase.order,
domain tcpono purchase.line,
domain tcqiv1 packingslip.qty,
domain tcqiv1 received.qty,
domain tcdate received.date,
domain tdltc.clot purchase.lot,
domain tcdate purchaselot.date,
domain tcconv conv.factor,
domain tccuni purchase.unit,
domain tcitem purchase.item,
ref string msg())
{
string dummy(6), error_code(16)
domain tcorno get.orno
domain tcpono get.pono

select tiitm001.stgu, tiitm001.kitm
from tiitm001
where tiitm001._index1 = {:purchase.item}
as set with 1 rows
selectdo
endselect

msg = ""
boi.call = "tdboidll0011.Create"
stpapi.put.field("tdpur4120m000","tdpur045.reno",str$(receipt.number))
stpapi.put.field("tdpur4120m000","tdpur045.orno",str$(purchase.order))
stpapi.put.field("tdpur4120m000","tdpur045.pono",str$(purchase.line))
rc = stpapi.find("tdpur4120m000",msg)
if not isspace(msg) or rc<>1 then
stpapi.end.session("tdpur4120m000")
return
endif
stpapi.get.field("tdpur4120m000","tdpur045.orno",dummy)
get.orno = val(dummy)
stpapi.get.field("tdpur4120m000","tdpur045.pono",dummy)
get.pono = val(dummy)
| Prepare to handle lot controlled items.
if ((not isspace(purchase.lot) or conv.factor>1 or purchase.unit <> tiitm001.stgu)
and (tiitm001.kitm=tckitm.purchase or tiitm001.kitm = tckitm.manufacture)) then
stpapi.handle.subproc("tdpur4120m000","tdilc4113s000","add")
endif

stpapi.put.field("tdpur4120m000","tdpur045.diqu",str$(packingslip.qty))
stpapi.put.field("tdpur4120m000","tdpur045.date",str$(received.date))
stpapi.put.field("tdpur4120m000","tdpur045.dqua",str$(received.qty))
rc = stpapi.update("tdpur4120m000",1,msg)
if not isspace(msg) or rc<>1 then
if not isspace(purchase.lot) or conv.factor>1 then
stpapi.end.session("tdilc4113s000")
endif
stpapi.end.session("tdpur4120m000")
return
endif

| Need to handle the conversion factor.
if ((not isspace(purchase.lot) or conv.factor>1 or purchase.unit <> tiitm001.stgu)
and (tiitm001.kitm=tckitm.purchase or tiitm001.kitm = tckitm.manufacture)) then
stpapi.put.field("tdilc4113s000", "tdilc402.clot",purchase.lot)
stpapi.put.field("tdilc4113s000", "tdilc402.date",str$(purchaselot.date))
stpapi.put.field("tdilc4113s000", "tdilc402.qstr",str$(received.qty*conv.factor))
stpapi.put.field("tdilc4113s000", "tdilc402.qstc",str$(received.qty*conv.factor))
rc = stpapi.insert("tdilc4113s000",1,msg)
error_code = stpapi.get.mess.code("tdilc4113s000",msg)
if strip$(error_code) = "tdilc40062" then
msg = ""
endif
stpapi.end.session("tdilc4113s000")
endif
stpapi.end.session("tdpur4120m000")
}