monica1
20th January 2005, 17:07
It's my first program using AFS, and I have a problem. I want to call a print report but it doesn`t work.


stpapi.put.field("cagldca038l00", "divisa", str$(etol(caimp.eur)))
stpapi.put.field("cagldca038l00", "anno", str$(year))
stpapi.put.field("cagldca038l00", "per", str$(prno))
stpapi.put.field("cagldca038l00", "spool.preview", str$(1))
stpapi.set.report("cagldca038l00", "rcagldca0381000", "HP4L", err.msg)
if isspace(err.msg) then
stpapi.form.command("cagldca038l00", 5, "exec.cont.process", err.msg)
endif
stpapi.end.session("cagldca038l00")


In the called session when go to execute(print.data) in choice.cont.process it returns to the principal script and execute stpapi.end.session.

Can somebody help me?
Thank you in advance,

monica

mark_h
20th January 2005, 18:55
Have you tried a stpapi.continue.process instead of the form command?. I do not think you have to use the stpapi.form.command to execute a continue.

Mark

monica1
20th January 2005, 19:07
If I use this stapi the variable err.msg return "Command disabled".

lbencic
20th January 2005, 19:36
The exec.cont.process should work if that's what is defined as the function name on the Form Commands. Is it saying 'command disabled' using the Form Command call too? Or is it blank..?

I had a similar problem in the Order Documents printing, when I debugged the called program it went through before.choice and after.choice sections, but NOT the on choice, which did the printing! In that case, the reports were confusing I guess, more than 1 report attached to the session, and which report that was getting printed is decided based on form field variables. Choosing the first report on the 'set.report' command did the trick for me, but others found they needed a patch to resolve.

So, no answer, just background and questions - is there more than 1 report attached to this session? If so, can you print any of the others? Can you call a custom version of the session that only has the 1 report attached..?

Also, if this is your first AFS - pls. make sure you have the most recent api solutions form the Baan support site. Make sure you can do a simple print, try Print Areas, to be sure your components are generally working.

monica1
21st January 2005, 11:17
My session only has 1 report.
I installed the last solution for AFS (131996stnd). I try without re-starting and it doen't work. I need to re-start my system and I can't do that until that night.

monica1
25th January 2005, 10:30
I have instaled the last solution for AFS (15555) and I re-start my system, but my program follows without working. The code of the called program where my main program exit is:

choice.cont.process:
on.choice:
compa = get.compnr()
execute(print.data)

choice.print.data:
on.choice:
if rprt_open() then
read.main.table()
rprt_close()
else
choice.again()
endif


when execute(print.data) the program don't go to the on.choice section it exit this program and go to the other one.

lbencic
25th January 2005, 17:04
Humph. More questions I guess, it seems like you are calling it right.
Did you try to do a simple print to Print Areas (tcmcs0445m000)? That will narrow down if the problem is in this session or in the AFS on your system.
If Areas work, we need to look at your session. It's a custom session are calling, what is that spool.preview variable supposed to do? I don't see it on a list of predefined report variables.

monica1
25th January 2005, 18:13
Don't work the Areas. If I try with stpapi.form.command don't message appear, but if I try with stpapi.print.report the error message returned is "Command disabled".

The spool.preview is a predefind variable. It's not in the list, but it is the check to preview the document before print it.

lbencic
25th January 2005, 18:36
ok, the api's do NOT like user interaction, I have not tried the print preview, but I would try to get it working without that first, then see if that will fly.

But..if you can't do Print Areas, you will not be able to do anything. What is your code? Post and I will try it on my Vb system. If it works here, then you still have an api / tools issue.

monica1
25th January 2005, 18:51
My code to print Areas is:
I try with 2 versions. The first one is:

stpapi.put.field("tcmcs0445000", "creg.f", " ")
stpapi.put.field("tcmcs0445000", "creg.t", "ZZZ")
stpapi.set.report("tcmcs0445000", "rtcmcs04451000", "HP4L", err.msg)
if isspace(err.msg) then
stpapi.form.command("tcmcs0445000", 5, "exec.cont.process", err.msg)
endif
stpapi.end.session("tcmcs0445000")


My second version is:

stpapi.put.field("tcmcs0445m000", "creg.f", " ")
stpapi.put.field("tcmcs0445m000", "creg.t", "ZZZ")
stpapi.set.report("tcmcs0455m000", "rtcmcs044501000", "HP4L", err.msg)
if isspace(err.msg) then
stpapi.print.report("tcmcs0445m000", err.msg)
endif
stpapi.end.session("tcmcs0445m000")

In this version the err.msg returns "Command disabled".

lbencic
25th January 2005, 19:47
Bah my Vb system is not happy right now. The first version works in Vc, which should be called the same, but with some fixes to your code. The second version, with print.report call, is a IV style call, use form.commands for Baan V.

Fixes to version 1 / Print Areas
1. Your session name is missing the 'm'
2. The report is 'rtcmcs044501000' , mistyped in your version

See if you can get it to work, but one think i found by accident in this little experiment, I had to have a report attached to my session before it would go to the print data section after 'choice continue process'. Try making sure you have a report attached to your test session - this may even be relevant to your original problem.