tmannais
18th January 2018, 12:48
Hi,

I am using AFS to execute a form command in tfgld1401m000 to print a report but it doesn't display the report and there is no error either.
Here is the code:


function afs.non.finalize.transaction(domain tcmcs.str6 i.batch, domain tcmcs.str4 i.year, domain tcmcs.s512 i.content.line)
{
string non.finalize.code(13)
domain tcmcs.str256 error.msg.from.non.finalize
domain tcmcs.str256 error.msg
string user(15)
long company
boolean check.error.msg
check.error.msg = false
non.finalize.code = "tfgld1401m000" |* Non finalize
user = logname$
company = get.compnr()
|stpapi.find(non.finalize.code, error.msg.from.non.finalize)
stpapi.clear(non.finalize.code)
stpapi.put.field(non.finalize.code, "year.f", str$(i.year))
stpapi.put.field(non.finalize.code, "cono.f", str$(company))
stpapi.put.field(non.finalize.code, "cono.t", str$(company))
stpapi.put.field(non.finalize.code, "btno.f", str$(i.batch))
stpapi.put.field(non.finalize.code, "btno.t", str$(i.batch))
stpapi.set.report(non.finalize.code, "rtfgld140111000", "D", error.msg.from.non.finalize)
stpapi.form.command(non.finalize.code, 5, "exec.cont.process", error.msg.from.non.finalize)
if not isspace(error.msg.from.non.finalize) then
stpapi.recover(non.finalize.code, error.msg)
error.msg.from.non.finalize = "Cannot insert tfgld1401m000: " & error.msg.from.non.finalize
save.error.log(i.content.line, non.finalize.code, error.msg.from.non.finalize) |* table save log tfgld164 Import AP/AR
check.error.msg = true
endif
if check.error.msg = true then
stpapi.end.session(non.finalize.code, error.msg.from.non.finalize)
message("Some errors occur. Please see the log information.")
endif
stpapi.end.session(non.finalize.code, error.msg.from.non.finalize)
}


tfgld1401m000 is a standard session, and the report is correct and exists.
Please help.

Regards,
Thana

mark_h
18th January 2018, 14:23
Are those the only fields on the form? I have had cases where I have to put all the fields on the form to get the report to print - plus (not sure about your version) but in 4c4 users love to save defaults for sessions. So I always put all the fields to make sure those do not cause issues.

tmannais
19th January 2018, 03:39
I did what you suggested and it works like a charm.
Thank you again Mark. You are exactly right. This is a perfect solution.

Regards,
Thana