jdhaan
16th May 2002, 12:55
Is there someone who knows if you can call AFS dll's from report scripts?
I've tried to do this, for inserting in table tpppc211, but AFS is always returning "Item not allowed". The AFS dll is called from a report script.
When I call the same dll with the same data from a program script AFS is creating the record succesfull.
mark_h
17th May 2002, 21:02
I have never really thought about running a FS in a report. I will have to remember that as a possible solution later on.
Anyway I did a quick test. I put the following code into a report:
#pragma used dll ottstpapihand
before.program:
stpapi.put.field("tpptc1230m000","cprj.f"," LSIM5")
stpapi.put.field("tpptc1230m000","cprj.t"," LSIM5")
stpapi.set.report("tpptc1230m000","rtpptc123001000",spool.device,errmsg)
stpapi.continue.process("tpptc1230m000", errmsg)
if(strip$(errmsg)<>"") then
message(errmsg)
endif
It worked just fine - except the report from the Generate control session was at the beginning of my report. So it makes me wonder if for some reason or other the item that you are putting onto the session might not be what the session is expecting. Have you run the report in debug mode to check the items? Also I put my code in the before.program section, so I really do not know how it would effect the FS in other sections. Maybe if you post the code someone may see something that is causing the problems.
Good Luck!
Mark
jdhaan
21st May 2002, 11:13
The problem is, when I try to debug the report script, I get an overflow error when I ask the value of a field variable and the Baan session has to be killed.
This is why I assume, that AFS will not work from a report script.
Looking at the AFS log, the field for the item has the right value:
LOGGING STARTED
16-05-2002
12->get.fields
12<-get.fields0tpppc211.cprj1tpppc211.cspa1tpppc211.cact1tpppc211.item0
tpppc211.item.segment.11tpppc211.item.segment.21tpppc211.sern1tpppc211.cstl1
tpppc211.ccco1tpppc211.desc1tpppc211.quan
1tpppc211.cuni1tpppc211.curc1tpppc211.pric1tpppc211.amoc1tpppc211.curs1
tpppc211.pris1tpppc211.amos1tpppc211.rgdt
1tpppc211.year1tpppc211.peri1tpppc211.fyea1
tpppc211.fper1tpppc211.entu1tpppc211.cdoc1tpppc211.otbp1tpppc211.ifbp1
>tpppc2111s000 put.field:tpppc211.cprj E10071
>tpppc2111s000 put.field:tpppc211.sern 2
>tpppc2111s000 put.field:tpppc211.cspa 0001
>tpppc2111s000 put.field:tpppc211.cact
>tpppc2111s000 put.field:tpppc211.item 2.10071.81518
>tpppc2111s000 put.field:tpppc211.rgdt 730986
>tpppc2111s000 put.field:tpppc211.quan 100
>tpppc2111s000 put.field:tpppc211.cuni pcs
>tpppc2111s000 put.field:tpppc211.cstl
>tpppc2111s000 put.field:tpppc211.ccco 420
>tpppc2111s000 put.field:tpppc211.desc Stock item/10/Appelboor standa
>tpppc2111s000 put.field:tpppc211.curc EUR
>tpppc2111s000 put.field:tpppc211.pric 0
>tpppc2111s000 put.field:tpppc211.amoc 0
>tpppc2111s000 put.field:tpppc211.curs EUR
>tpppc2111s000 put.field:tpppc211.pris 0
>tpppc2111s000 put.field:tpppc211.amos 0
>tpppc2111s000 put.field:tpppc211.entu 200
>tpppc2111s000 put.field:tpppc211.cdoc
>tpppc2111s000 put.field:tpppc211.otbp
>tpppc2111s000 put.field:tpppc211.ifbp
>tpppc2111s000 insert
12->add.set+save
12<-add.set+save10
<tpppc2111s000 Item not allowed
>tpppc2111s000 save
12->update.db
12<-update.db0
<tpppc2111s000
>tpppc2111s000 end.session
12->end.program
12<-end.program0
Also when I manually start the session and add this record, there is no problem with the item code.
mark_h
21st May 2002, 18:06
We have something like this with our Purchase Order report. When we run it in debug at a certain point you get an overflow and the report just shuts down. I have to debug using messages and such. I have never really solved this problem. I figured it had something to with corrupting memory or something like that. I keep hoping that one of the tools releases will fix the problem, but no luck so far.
I did have a couple of ideas you could try if you want - I am not sure if they will work. First since you know your session works, take the code and create a dll. Then remove all the code from the report script and just put in the code for the DLL - of course passing all the parameters you need. This idea may work. Hopefull by pulling all that code out of the script and putting it in a DLL may solve the overflow problem.
Another idea is to try activating your session that works. I am not sure if you could export variables from a report script to a session. I think this probably would not work, but thought I still should mention it.
Not real good solutions, but I do think trying the first suggestion is worth the try. Good Luck!
Mark
jdhaan
22nd May 2002, 09:22
I've created an independent session,
copied the report script to the program script,
did some modifications,
and now it is working fine.
Thanks for your help Mark.