baanfans
17th November 2005, 20:59
Hello all :cool:
I create a new session using AFS and session tfgld1101m000 - Transactions and tfacp1110s000 - Purchase invoices, in order to create automatically purchase and credit notes. When I launch command stpapi.form.command to execute subsession tfacp1110s000, the process takes longer than 5 minutes.
The syntaxs are:
stpapi.put.field("tfgld1101m000", "tfgld101.year", str$(year.o.disp))
stpapi.put.field("tfgld1101m000", "tfgld101.btno", str$(btno.o.disp))
stpapi.put.field("tfgld1101m000", "tfgld101.ttyp", tfgld750.ttyp.o)
ret.code = stpapi.find("tfgld1101m000", err.desc)
if ret.code = 1 then
stpapi.get.field("tfgld1101m000", "tfgld100.fprd", fprd.aux)
stpapi.get.field("tfgld1101m000", "tfgld100.rprd", rprd.aux)
endif
ret.code = stpapi.mark("tfgld1101m000", err.desc)
if not ret.code then
err.desc = "Batch: " & err.desc
return(false)
endif
stpapi.form.command("tfgld1101m000", 5, "exec.cont.process", err.desc)
Is in the last syntax where the process takes longer than 5 minutes to launch subsession tfacp1110s000...
Thanks a lot,
:)
mark_h
17th November 2005, 21:44
First please do not cross post - let the moderators decide where/when to move threads. I think this is the correct forum so you might what to go ahead and delete the other post.
As for your problem - I take it when running tfgld1101m000 manually it does not take 5 minutes to launch tfacp1110s000? I also do not see stpapi.handle.subproc( "tfgld1101m000", "tfacp1110s000","add") before the continue - not sure if this was just left out. You might also want to make sure all objects (session, stpapi, etc.) are current.
baanfans
17th November 2005, 22:17
Hello Mark..
When I run manually session tfgld1101m000 and launch tfacp1110s000, it takes longer 20 seconds to open it. Handle subproc is not necessary for the first record, in fact, when the subsession appears the record is saved sucessfully, for the next record then is necessary add a new record using handel subproc.
Finally, how delete the other post?
Thanks in advance,
mark_h
17th November 2005, 22:36
Go open the other post - at the top of the post is "thread tools". You should be able to delete the post. Put in a reason like - "Found better forum".
I am suprised you have control of tfacp1110s00 - all of my function servers do the following:
stpapi.end.session("tfgld1101m000")
stpapi.put.field("tfgld1101m000", "tfgld101.year", str$(use.year))
stpapi.put.field("tfgld1101m000", "tfgld101.btno", str$(use.batch))
stpapi.put.field("tfgld1101m000", "tfgld101.ttyp", "ZRC")
rc = stpapi.find("tfgld1101m000")
if(rc<>1) then
title("Tfgld1101m000 - Find values not found")
stpapi.end.session("tfgld1101m000")
return
endif
|************************************************************************************************
| Step 2. Handle sub session
|************************************************************************************************
stpapi.handle.subproc( "tfgld1101m000", "tfacp1110s000","add")
stpapi.continue.process( "tfgld1101m000", msg )
Maybe Baan 5 is different, but I thought in a case like this it is the same. For grins and giggles you might want to try it and see what happens. Also are you re-opening tfacp1110s000(tfgld1101m000) for each record to be processed?
Do you have source? If so you can put both sessions in debug mode and see what is causing the delay.
baanfans
17th November 2005, 23:05
Hello again Mark.
I deleted the other post...
CODE:
if not first.time then
|* Header transaction batch
stpapi.put.field("tfgld1101m000", "tfgld101.year", str$(year.o.disp))
stpapi.put.field("tfgld1101m000", "tfgld101.btno", str$(btno.o.disp))
stpapi.put.field("tfgld1101m000", "tfgld101.ttyp", tfgld750.ttyp.o)
ret.code = stpapi.find("tfgld1101m000", err.desc)
if ret.code = 1 then
stpapi.get.field("tfgld1101m000", "tfgld100.fprd", fprd.aux)
stpapi.get.field("tfgld1101m000", "tfgld100.rprd", rprd.aux)
endif
ret.code = stpapi.mark("tfgld1101m000", err.desc)
if not ret.code then
err.desc = "Cabecera lote: " & err.desc
return(false)
endif
stpapi.form.command("tfgld1101m000", 5, "exec.cont.process", err.desc)
first.time = true
else
stpapi.handle.subproc("tfgld1101m000", "tfacp1110s000", "ADD")
endif
isup.mod = shiftl$(strip$(tfgld754.isup.o)) & tfgld750.asot.o
ret = tt.align.according.domain(tfacp200.isup, isup.aux, "tfacp.isup")
ret = tt.align.according.domain(isup.mod, isup.mod, "tfacp.isup")
|* Purchase credit note header
db.set.to.default(ttfacp200)
db.set.to.default(ttflcv961)
stpapi.put.field("tfacp1110s000", "tfacp200.ttyp", tfgld750.ttyp.o)
stpapi.put.field("tfacp1110s000", "tfacp200.ninv", str$(seri.o.disp))
stpapi.put.field("tfacp1110s000", "tfacp200.appr", str$(etol(tfacp.inv.expence))) |* Factura de costo
stpapi.put.field("tfacp1110s000", "tfacp200.ifbp", tfgld754.ptbp.o)
stpapi.put.field("tfacp1110s000", "tfacp200.isup", isup.mod)
stpapi.put.field("tfacp1110s000", "tfacp200.refr", "")
stpapi.put.field("tfacp1110s000", "screen.amnt", str$(abs(tot.amnt)))
stpapi.put.field("tfacp1110s000", "tfacp200.lvat", str$(etol(tfacp.vatc.header))) |* Impuestos a nivel de línea
stpapi.put.field("tfacp1110s000", "tfacp200.vatc", "VEN") |* ******************* OJO
stpapi.put.field("tfacp1110s000", "tfacp200.cvat", "XX") |* ******************* OJO
stpapi.put.field("tfacp1110s000", "tfacp200.reas", tfgld752.reas.o)
stpapi.put.field("tfacp1110s000", "tflcv961.docd", str$(date.aux))
stpapi.put.field("tfacp1110s000", "tflcv961.recd", str$(date.aux))
stpapi.put.field("tfacp1110s000", "tflcv961.doct", str$(etol(tflcv.doct.credit)))
stpapi.put.field("tfacp1110s000", "tflcv961.nros", isup.aux)
stpapi.put.field("tfacp1110s000", "tflcv961.ttri", str$(etol(tflcv.ttri.invoice)))
stpapi.put.field("tfacp1110s000", "tflcv961.isup", isup.aux)
ret.code = stpapi.insert("tfacp1110s000", TRUE, err.desc)
if not ret.code then
ret.code = stpapi.recover("tfacp1110s000", err.desr)
err.desc = "Cabecera: " & err.desc
return(false)
endif
stpapi.get.field("tfacp1110s000", "tfacp200.ttyp", ttyp.aux)
stpapi.get.field("tfacp1110s000", "tfacp200.ninv", ninv.str)
ninv.aux = lval(ninv.str)
return(true)
}
function domain tcbool create.line.purchase.credit.notes()
{
|* Transactions lines
stpapi.form.command( "tfacp1110s000", 5, "exec.cont.process", err.desc)
db.set.to.default(ttfgld102)
stpapi.put.field("tfacp1120s000", "tfgld102.leac", tfgld750.leac.o)
stpapi.put.field("tfacp1120s000", "amount", str$(abs(tot.amnt)))
stpapi.put.field("tfacp1120s000", "tfgld102.dbcr", str$(etol(tfgld.dbcr.credit)))
stpapi.put.field("tfacp1120s000", "tfacp200.refr", "")
ret.code = stpapi.insert("tfacp1120s000", TRUE, err.desc)
if not ret.code then
ret.code = stpapi.recover("tfacp1120s000", err.desr)
err.desc = "Línea fra: " & err.desc
return(false)
endif
stpapi.end.session("tfacp1120s000")
return(true)
}
mark_h
17th November 2005, 23:16
Again - I am suprised that the first time through you have control of tfacp1110s000.
if not first.time then
|* Header transaction batch
stpapi.put.field("tfgld1101m000", "tfgld101.year", str$(year.o.disp))
stpapi.put.field("tfgld1101m000", "tfgld101.btno", str$(btno.o.disp))
stpapi.put.field("tfgld1101m000", "tfgld101.ttyp", tfgld750.ttyp.o)
ret.code = stpapi.find("tfgld1101m000", err.desc)
if ret.code = 1 then
stpapi.get.field("tfgld1101m000", "tfgld100.fprd", fprd.aux)
stpapi.get.field("tfgld1101m000", "tfgld100.rprd", rprd.aux)
endif
ret.code = stpapi.mark("tfgld1101m000", err.desc)
if not ret.code then
err.desc = "Cabecera lote: " & err.desc
return(false)
endif
stpapi.handle.subproc("tfgld1101m000", "tfacp1110s000", "ADD")
stpapi.form.command("tfgld1101m000", 5, "exec.cont.process", err.desc)
first.time = true
endif
I would expect it to look like the above. Whenever I do not include the stpapi.handle.subproc I lose control of what the session does - sometimes it works, but causes me problems. Some sub-sessions let you call them without a main session controlling them, but I do not like doing that. I would certainly try the above code - because it makes wonder if tfacp1110s000 is taking so long because of this. Again I am not familiar with Baan V but thought this type control was needed on both versions.