gous99
8th January 2003, 23:01
Hi,

Is it possible to create AFS for tools sessions?

I tried with session ttadv6420m000, and it does not print anything, does not even give me any error message... Here is the code, I tried with both, stpapi.continue.process() as well as with stpapi.print.report() and nothing happens. It goes through the code, end the session with no problem, but it never print anything...

function start.process()
{
stpapi.put.field("ttadv6420m000", "cpac", "tp")
stpapi.put.field("ttadv6420m000", "vers", "B40o")
stpapi.put.field("ttadv6420m000", "rele", "22")
stpapi.put.field("ttadv6420m000", "cust", "prd")
stpapi.put.field("ttadv6420m000", "labels", "ttyeno.yes")
stpapi.put.field("ttadv6420m000", "forms", "ttyeno.yes")
stpapi.put.field("ttadv6420m000", "menus", "ttyeno.yes")
stpapi.put.field("ttadv6420m000", "reports", "ttyeno.yes")
stpapi.put.field("ttadv6420m000", "sessions", "ttyeno.yes")
stpapi.put.field("ttadv6420m000", "ifunctions", "ttyeno.yes")
stpapi.put.field("ttadv6420m000", "functions", "ttyeno.yes")
stpapi.put.field("ttadv6420m000", "scripts", "ttyeno.yes")
stpapi.put.field("ttadv6420m000", "charts", "ttyeno.yes")
stpapi.put.field("ttadv6420m000", "messages", "ttyeno.yes")
stpapi.put.field("ttadv6420m000", "questions", "ttyeno.yes")
stpapi.put.field("ttadv6420m000", "tables", "ttyeno.yes")
stpapi.put.field("ttadv6420m000", "domains", "ttyeno.yes")
stpapi.put.field("ttadv6420m000", "clan.f", "2")
stpapi.put.field("ttadv6420m000", "clan.t", "2")
stpapi.put.field("ttadv6420m000", "also.reln", "ttyeno.no")
stpapi.put.field("ttadv6420m000", "also.docu", "ttyeno.no")



stpapi.set.report("ttadv6420m000", "rttadv642001000", device, gapi.error.code)
if strip$(gapi.error.code) <> "" then
message("Could not open report")
message("The error is: " & gapi.error.code)
stpapi.end.session("ttadv6420m000")
else
|stpapi.continue.process("ttadv6420m000", gapi.error.code)
stpapi.print.report("ttadv6420m000", gapi.error.code)
if strip$(gapi.error.code) <> "" then
message("Could not process session Print Component by VRC")
message("The error is: " & gapi.error.code)
stpapi.end.session("ttadv6420m000")
endif
endif
stpapi.end.session("ttadv6420m000")
}

NPRao
8th January 2003, 23:13
Yes it is possible to make AFS/API for the tools sessions.

Refer to the thread on the board - AFS and ttstpapi (http://www.baanboard.com/baanboard/showthread.php?s=&threadid=1227&highlight=afs)

You might need to take precautions to remove the user defaults for that session and also to set the proper device or redirect to a file (the "D" doesnt work).

mark_h
9th January 2003, 00:38
NPR is correct - you can create AFS function servers on tools sessions. I know there has been a couple of posts on this in the past, so you might want to try searching this forum.

I also noticed like NPR that there is nothing defining device in the code, is this a mistake? I have created some function servers that ran to the device D, but none of them were tools sessions.

Mark

gous99
9th January 2003, 16:41
If the user slects to output to a file (ASCII device, for example), how do I set the location of the file, is it possible, or will it always be put in the home directory of the user under Fileout?

mark_h
9th January 2003, 18:30
Typically what I do in function servers that generate reports is to use spool.open. Something like rprt_id = spool.open("",spool.device,1) - this way the user gets to pick where the report is sent. If they want it in a file, then they pick ASCIF and change the FILEOUT to whatever filename and location they want. Of course your ASCIF device must have change allowed selected so they can change fileout.

Also when I hard code in the device of ASCIF I also set the spool.fileout variable to what I want it to be. Hope this helps.

Mark

gous99
9th January 2003, 18:33
Thanks.

mark_h
9th January 2003, 19:27
This is from a session that prints PO's:


rpt_id = spool.open("",spool.device,1)

| Make sure screen was not selected
if(orno.t - orno.f >10) then
select ttaad300.devt
from ttaad300
where ttaad300.devc = :spool.device
and ttaad300._compnr = 0
selectdo
endselect
if(ttaad300.devt = ttaad.devt.stepw.display) then
message("Only 10 Purchase Orders can be displayed on the screen")
rpt_id=0
endif
endif
if( rpt_id = 0) then | Status for cancel
choice.again()
endif
spool.close()
select.po.to.print()


Notice how I do spool.close before calling the subroutine to print the PO range.

Sample of ASCIF:

| Create temporary file for error records.
spool.device = "ASCIF" | To file
tmp.rpt.name = creat.tmp.file$(bse.tmp.dir$())
tmp.rpt.name = strip$(tmp.rpt.name)
spool.fileout = tmp.rpt.name

| Generate Report
stpapi.set.report("tppss9269m00b","rtppss92690100b",spool.device,errmsg)


In this example I create a temporary file to write the report to, then later in the report I copy it down to the users PC using server2client.

Mark