saumya
1st August 2013, 14:59
Hi All,

I have written AFS on session tfgld2215m000 "Post Imported Journal Transactions".

Session which will call this AFS, can be run in job as well manually.

Here I am printing multiple records in single report.
If Running in JOB, I have hardcoded device, but when running manually device will be asked to enter. Report printing is working perfact if I am using notepad/ascif. if I give Pdf or excel no report is printing. Please Help.

Below is the code I am executing:

select tfgld213.idno
from tfgld213
where tfgld213._index1 inrange :idno.f and :idno.t
and tfgld213.ttyp inrange :ttyp.f and :ttyp.t
and tfgld213.imst = tfgld.imst.free
order by tfgld213.idno
selectdo
rcd.count = rcd.count + 1
curr.idno.f = tfgld213.idno
error = ""
if rcd.count = 1 then
if job.process then
spool.id = spool.open(REPORT.TO.BE.OPEN, DEVICE.TO.BE.USED, 0)
else
spool.id = spool.open(REPORT.TO.BE.OPEN, "", 1)
endif
endif

tfgldf2215m00c.put.Identification_Number.idno.f(curr.idno.f)
tfgldf2215m00c.put.Identification_Number.idno.t(curr.idno.f)
tfgldf2215m00c.put.Print_only_errors(hold.print.only.errors)
tfgldf2215m00c.put.Audit(hold.audit)
tfgldf2215m00c.put.Remove_Document_Lines(hold.remove.doc.lines)
tfgldf2215m00c.set.report(REPORT.TO.BE.OPEN, spool.device, error)
if isspace(error) then
tfgldf2215m00c.Import(error)
if not isspace(error) then
mess("tfgld2215.03c",1, error)
|* AFS Error while Importing: $1%s
break
endif
else
tfgldf2215m00c.end()
mess("tfgld2215.02c",1, error)
|* AFS Error while opening Report: $1%s
break
endif
tfgldf2215m00c.end()
selecteos
mess("tccom99988", 0)
|* Process Completed
selectempty
mess("tcccps0001", 0)
|* No data within selection
endselect
spool.close()
}

mark_h
1st August 2013, 16:22
I don't think it is the AFS code at all. As far as I know when you run it as a scheduled job you do not have a client attached. Which means there is no excel and I assume no pdf creation tool that can be launched - since (and basing this off my system) devices like that tend to launch the executable for the tool. I do not know a good solution. What we did in one case was print the files to a unix directory. Then the users that want the reports can run a session to print them. In our case we just overwrite the files daily - then they can print to excel or a printer just the reports they want.

saumya
1st August 2013, 17:56
Hi Mark,

I run this session manually and give device as pdf. Report doesnt get generated.

Thanks.

saumya
1st August 2013, 17:57
AFS dll tfgldf2215m00c is created for session tfgld2215m000.

mark_h
2nd August 2013, 19:52
Where do you define spool.device and spool.fileout? Because using lower case for excel did not work for me.

spool.device = "excel"
spool.fileout ="testd"

BUT make it upper case and it worked just fine:

spool.device = "EXCEL"
spool.fileout ="testd"
stpapi.put.field("tcmcs0403m000","cwar.f"," ")
stpapi.put.field("tcmcs0403m000","cwar.t","ZZZ")
stpapi.set.report("tcmcs0403m000","rtcmcs040301000",spool.device,err)
stpapi.continue.process("tcmcs0403m000",err)
stpapi.end.session("tcmcs0403m000")