guilmor
4th October 2002, 18:14
Hello Baanboard!

I've been trying to create purchase orders by using dll created with ttstpcreatedll in Baan IV. I've been able to create order headers, but now I want to insert new order lines as well.
I used dll for session tdpur4101m000 to create headers.
After having a new header inserted, how do I call dll for tdpur4105s000 to create several order lines?

I've been reading Developers Guide for AFS, but I can't get on...
Here I copy the code for order headers. Any suggestions of order lines?

Thanks in advance.
Guilmor.

orno = 40 |*** serie repuestos
suno = "004469"
cotp = "CGR"
ncmp = 130
odat = date.num()
ddat = date.num()
cwar = "208"
ccty = "E"
ccur = "EUR"
odis = 0.0

dll4101.put.Purchase_Order(orno)
dll4101.put.Supplier(suno)
dll4101.put.tdpur040.cotp(cotp)
dll4101.put.tdpur040.comp(ncmp)
dll4101.put.tdpur040.prno(0) |**** contrato
dll4101.put.Order_Date(odat) |*** fecha de la orden
dll4101.put.Delivery_Date(ddat)
dll4101.put.tdpur040.cwar(cwar)
dll4101.put.Order_Discount(odis)
|*** dll4101.put.tdpur040.cpay("002")
dll4101.put.tdpur040.ccon(0) |*** comprador poner 0
dll4101.put.tdpur040.ccty(ccty)
dll4101.put.tdpur040.clan("E")
dll4101.put.tdpur040.cvyn(tcyesno.yes) |*** codigo de iva, SI

dll4101.insert(1,error)
dll4101.save(error)
orno = dll4101.get.Purchase_Order()


And now!?!?! :confused:

mark_h
4th October 2002, 18:36
Using continue is the same as clicking on the lines button. Here is some code from my create po and line session.


function create_single_po_line(domain tcorno po)
{
| First find the newly created purchase order
f4101m000.put.Purchase_Order(po) | Put in the series
ret.code = f4101m000.find()
if(ret.code <> 1) then
message("Find err: %s",fserr)
f4101m000.end()
return
endif
f4101m000.handle.sub.process( "tdpur4107s000", "add")
f4101m000.continue(fserr)
if(strip$(fserr)<>"") then
message("Error: %s",fserr)
f4101m000.end()
return
endif

| Add the line
f4107s000.handle.sub.process( "tdpur9151s00b", "add")
f4107s000.handle.sub.process( "tcmcs9551s00b", "add")
f4107s000.handle.sub.process( "tdpur4811s000", "add")
f4107s000.put.Project_Group(tipgc520.ccot)
f4107s000.put.tdpur041.item(tipgc520.item)
f4107s000.put.Ordered_Quantity(total.oqua)
f4107s000.put.Planned_Delivery_Date(tipgc520.pddt)
f4107s000.insert(1,fserr)


Good Luck!

Mark

guilmor
4th October 2002, 19:24
Mark:

I'm able to execute "continue", and then, debug the program, until it arrives at
zoom.to$("tdpur4105s000",z.session,.....)

My code:

dll4101.handle.subprocess("tdpur4105s000", "add")
dll4101.continue(err)

When continue is executed, I traced choice.cont.process from tdpur4101,
it is working until

zoom.to$("tdpur4105s000",z.session,.....)

then, hangs... :mad:

Forgot anything?

mark_h
4th October 2002, 20:11
Well you can try a stpapi.zoom like the example in the API document. I am on Baan 4c3 A&D 2.2b, I checked out tdpur4101 script and it has an activate instead of a zoom.to$.

I have never done it the way this mentions, this may be Baan 5 code. See how I have used it. Usually you have to feel your way through function servers and what works one time may not work the next.

Baan example:

stpapi.put.field("dtfsa1501m000", "dtfsa101.seno", str$(i.seno))
ret = stpapi.find("dtfsa1501m000", error.msg)
if ret = 1 then
stpapi.handle.subproc("dtfsa1501m000", "dtfsa1201m000", "add")
stpapi.zoom.option("dtfsa1501m000", 2, "dtfsa1201m000", error.msg)
stpapi.continue.process("dtfsa1201m000", error.msg)
endif


One I use in my create PO session:

stpapi.zoom.option("tdpur4107s000",1,"tdpur9151s00b",fserr)

| Add distribution.
| Setup controlling program for the distribution screen.
po.line = f9151s00b.get.Position_Number( )

add_peg_record()
f9151s00b.insert(1,fserr)


Good Luck!

Mark

lbencic
4th October 2002, 22:13
Can anything be done with the tdpur4107m000 version? That's a main session for putting in lines - although I have not used it myself.
It's just that the darn API's have 'issues' with zooming, depending on how the zoom is called. Easiest to stick to main sessions if possible.
I took this approach in Baan V, where they have very nice main sessions for maintaining SO Lines and PO Lines.