david7
7th February 2012, 10:21
Hi all,
I am trying to print a PO (on Baan IV) using AFS but the device is not getting set correctly! It is always printing to "D" although I change it to something else. If I use the same code to print an Item Data report, the device is changed! Does anyone knows why?
Here is my Code:
| I added this line below after reading the suggestion in the forum
| It does not work with and without it!
stpapi.put.field("tdpur4401m000", "spool.device", spool.device)
stpapi.put.field("tdpur4401m000", "spool.fileout", spool.output)
stpapi.put.field("tdpur4401m000",input.fields1, input.values1)
stpapi.put.field("tdpur4401m000",input.fields2, input.values2)
stpapi.set.report("tdpur4401m000","rtdpur440101000",spool.device,error.msg.1)
stpapi.continue.process("tdpur4401m000", error.msg.3)
stpapi.end.session("tdpur4401m000")
I have noticed another thing with the print PO sesison that it always have "D" as a device! Normally when I use any other print session, I get my default device, and if I use another one, and the print session was still open, next time it will show me the last one was used. but not the Print PO session! This one always shows "D". Note that it is not the PO session alone that has this weird thing, there are some other print sessions from the distribution module.
Any ideas why?
- D7
mark_h
7th February 2012, 15:25
This is all I do:
spool.report = "rtdpur440101000"
stpapi.set.report("tdpur4401m000",spool.report,spool.device,errmsg)
if(strip$(errmsg)<>"") then
message(errmsg)
endif
No reason to put spool.fileout or spool.device. See if that works first. Also is this the only print session in this API session?
I have seen something like this before where people save defaults in ttstpsplopen. You really should not do that - the reason being is that can get corrupted. When this happens reports print incorrectly. So the second thing is to make sure you do not have any defaults for ttstpsplopen. So run ttstpdeldeflt and enter ttstpsplopen. Let it run for all companies. This is the first thing I do for any user calling about a printing problem.
david7
7th February 2012, 15:38
Thank you for your reply.
This is the only print session in this API! I have deleted all the defaults for ttstpsplopen for all companies and users, but the "D" is still there!
I have tried your code and it is still printing to "D"! My current code is:
stpapi.put.field("tdpur4401m000",input.fields1, input.values1)
stpapi.put.field("tdpur4401m000",input.fields2, input.values2)
spool.report = "rtdpur440101000"
stpapi.set.report("tdpur4401m000",spool.report,spool.device,error.msg.1)
if(strip$(error.msg.1)<>"") then
message(error.msg.1)
endif
stpapi.continue.process("tdpur4401m000", error.msg.3)
if not isspace(error.msg.3) then
message("error message 3: "&error.msg.3)
endif
stpapi.end.session("tdpur4401m000")
Any other ideas?
Juergen
7th February 2012, 15:48
Hi,
maybe a default setting for the order step.
Check printer setting for order step "tdpur4401m000" in session tcmcs0139m000 "Maintain Order Steps" .
Rgds,
Juergen
mark_h
7th February 2012, 15:48
Your not using spool.device or anything like that any where else in this session? Can you post all the code? Which version of Baan are you using? And do you have the latest patches - usually my last resort?
mark_h
7th February 2012, 15:53
Hi,
maybe a default setting for the order step.
Check printer setting for order step "tdpur4401m000" in session tcmcs0139m000 "Maintain Order Steps" .
Rgds,
Juergen
Really good point - never thought of that. Ours is empty for that session and I wonder if AFS could even override it. I know sometimes AFS can not do everything you can do manually.
david7
7th February 2012, 15:55
Hi,
maybe a default setting for the order step.
Check printer setting for order step "tdpur4401m000" in session tcmcs0139m000 "Maintain Order Steps" .
Rgds,
Juergen
Thank you for yopur reply!
It was that! I deleted the device from there and left it empty and it did work after that!
Is there any other way to bypass this without changing the Order Steps?
mark_h
7th February 2012, 16:39
If you run the session manually does it let you change the printer? I am not sure AFS can override that at this point. We have that field blank to start with.
david7
7th February 2012, 17:37
If you run the session manually does it let you change the printer? I am not sure AFS can override that at this point. We have that field blank to start with.
Thanks again for your replies.
Yes. It lets me change the printer (Now as I have blanked the field). Even when I had "D" there, I could also change it too.
Maybe something in the code to overwrite this default device?
mark_h
7th February 2012, 19:50
Interesting - I did not try to set the device, but the help says that is the printer that it must be sent to. I think, but do not know for sure - is that what happens is that you set the report in the AFS program and then when you give the continue command something in the source code pulls in the default printer. That would override what you sent. Do you own source code that you could debug and try to fix this? We don't own source code, but we have QKEY. In the past I have done stuff like this by importing or setting the device in the program I am calling. That is option 1 - using source code.
The second way I did something like this was I cloned the session to something like tdpur9901m000. Then just changed the API code and hard coded some of the values - like file copy, etc. I made sure it was not part of the PO process. Thought I would mention this as option 2. As a matter of fact the new session I used the same script as tdpur4401 - just changed the form and one of the reports a little.
david7
8th February 2012, 08:59
Interesting - I did not try to set the device, but the help says that is the printer that it must be sent to. I think, but do not know for sure - is that what happens is that you set the report in the AFS program and then when you give the continue command something in the source code pulls in the default printer. That would override what you sent. Do you own source code that you could debug and try to fix this? We don't own source code, but we have QKEY. In the past I have done stuff like this by importing or setting the device in the program I am calling. That is option 1 - using source code.
The second way I did something like this was I cloned the session to something like tdpur9901m000. Then just changed the API code and hard coded some of the values - like file copy, etc. I made sure it was not part of the PO process. Thought I would mention this as option 2. As a matter of fact the new session I used the same script as tdpur4401 - just changed the form and one of the reports a little.
Thank you mark again for your time and replies.
I do not have the source code. I will try to take a look at QKEY.
george7a
8th February 2012, 09:04
Thanks again for your replies.
Yes. It lets me change the printer (Now as I have blanked the field). Even when I had "D" there, I could also change it too.
Maybe something in the code to overwrite this default device?
I have found a way to bypass it from the code. You need to use AFS to overwrite this "new" device. This new device is taken from "tcmcs039.prtr", so in your code simply overwrite that with stpapi.put.field before stpapi.continue.process. The code will look like this:
| after setting the other fields
|..
|.
stpapi.set.report("tdpur4401m000",spool.report,spool.device,error.msg.1)
| overwriting the new device..
stpapi.put.field("tdpur4401m000","tcmcs039.prtr",spool.device )
stpapi.continue.process("tdpur4401m000", error.msg.3)
stpapi.end.session("tdpur4401m000")
It worked for me, I hope it works for you ;)
david7
8th February 2012, 10:24
I have found a way to bypass it from the code. You need to use AFS to overwrite this "new" device. This new device is taken from "tcmcs039.prtr", so in your code simply overwrite that with stpapi.put.field before stpapi.continue.process. The code will look like this:
| after setting the other fields
|..
|.
stpapi.set.report("tdpur4401m000",spool.report,spool.device,error.msg.1)
| overwriting the new device..
stpapi.put.field("tdpur4401m000","tcmcs039.prtr",spool.device )
stpapi.continue.process("tdpur4401m000", error.msg.3)
stpapi.end.session("tdpur4401m000")
It worked for me, I hope it works for you ;)
Thank you Geroge! It is working for me too :).
mark_h
8th February 2012, 15:33
Now that George is something I have never tried. Great Hack! I never even thought about trying a put field on the form for a variable in the session script. If I ever get to write another I will keep this in mind.
george7a
8th February 2012, 15:51
Now that George is something I have never tried. Great Hack! I never even thought about trying a put field on the form for a variable in the session script. If I ever get to write another I will keep this in mind.
Thanks Mark. Knowing that there are a lot of undocumented stuff (http://www.baanboard.com/baanboard/showthread.php?t=36550) in Baan (specially IV), I assumed this field must be read by the print session, then i tried to overwrite it and it worked ;)
mark_h
18th September 2012, 21:52
If you read the first page you will see that george posted a solution towards the bottom that worked for David.