countnikon
9th March 2011, 01:15
Hi All.

I'm having issues with printing a report using AFS. I have created the following function that prints to our Mail Merge printer for automatic invoice archiving.

function void start.report.mail.merge.sales()
{
|*********************************************************
error.msg.1 = ("Error Setting Report")
error.msg.2 = ("Error Printing Report")
error.msg.3 = ("Error Continuing Report")
|*********************************************************

spool.device = "MM71-S"
stpapi.set.report("tdsls9404m00o","rtdsls440401000",spool.device,error.msg.1)
stpapi.put.field("tdsls9404m00o","printed", str$(tcyesno.yes))
stpapi.put.field("tdsls9404m00o","definite", str$(tcyesno.yes))
stpapi.put.field("tdsls9404m00o","ttyp.f", "tupdx100.ttyp")
stpapi.put.field("tdsls9404m00o","ttyp.t", "tupdx100.ttyp")
stpapi.put.field("tdsls9404m00o","invn.f", str$(tupdx100.ninv))
stpapi.put.field("tdsls9404m00o","invn.t", str$(tupdx100.ninv))
stpapi.put.field("tdsls9404m00o","comp.f", "100")
stpapi.put.field("tdsls9404m00o","comp.t", "100")
|stpapi.print.report("tdsls9404m00o", error.msg.2)
|message("error message 2: "&error.msg.2)
stpapi.continue.process("tdsls9404m00o", error.msg.3)
message("error message 3: "&error.msg.3)
stpapi.end.session("tdsls9404m00o")
}

I can't figure out what is going wrong. I message the error variables and nothing shows up.

Any help would be appreciated.

grzegorz
9th March 2011, 12:44
To fill yes/no fields on form I used str$(etol(tcyesno.yes)), not str$(tcyesno.yes).

mark_h
9th March 2011, 15:41
To fill yes/no fields on form I used str$(etol(tcyesno.yes)), not str$(tcyesno.yes).

That is actually the correct format, but str$(tcyesno.yes) will also work. I use it all the time.

What I see is in your stpapi.set.report is rtdsls440401000 instead of a report for 9404. I assume this is maybe a customized session and is that really the correct report number? if it is the next thing I would suggest is that you make sure all the fields on the form are set with stpapi commands. Also not sure about the ttyp is it a string variable?