tmannais
24th May 2018, 13:37
Hi,

I am struggling to print preview in a session using AFS. This is the current code.


|stpapi.handle.subproc(session.code, session.code, "add")
stpapi.set.report(session.code, "rtdsls140101000", "DOCMAN", error.msg)
if not isspace(error.msg) then
error.msg = "Cannot set report: " & error.msg
stpapi.end.session(session.code)
return(error.msg)
endif
|stpapi.put.field(session.code, "spool.preview", "1") | Set Print Preview
|stpapi.print.report(session.code, error.msg)
stpapi.form.command(session.code, 2, "tdsls1401m200", error.msg) | "tdsls1401m200" is the form command of the preview button inside print menu
if not isspace(error.msg) then
error.msg = "Cannot print preview: " & error.msg
stpapi.end.session(session.code)
return(error.msg)
endif
stpapi.end.session(session.code)
return(error.msg)


What I have tried:
- use stpapi.handle.subproc() with stpapi.print.report() and/or stpapi.form.command().
- use stpapi.print.report() alone, which displays a little session that allow me to select preview to print but after that it gives no report.
- use stpapi.put.field(session.code, "spool.preview", "1") with the printing functions above.
- print with/without stpapi.handle.subproc().
- changing printing device ranging from "D", "PDF", "SSRS", and "DOCMAN"(this is the device I aimed to use).
- stpapi.handle.subproc() to "tdsls1401m200" with action "add", and "send" because "tdsls1401m200" is the session of the preview print.

Nothing works. I really need your help. I just want to print out to device "DOCMAN" from only print preview by using AFS.

mark_h
24th May 2018, 23:22
I do not know this session, but I can do it in 4c4 to a windows printer like this:


spool.device = "WINTESTPRINTER"
spool.preview = true
| spool.device ="D66"

| spool.preview = false
stpapi.put.field("tuudi0420m000","user.f","")
stpapi.put.field("tuudi0420m000","user.t","ZZZZZZZZl")
stpapi.set.report("tuudi0420m000","rtuudi042011000",spool.device,err)
stpapi.continue.process("tuudi0420m000",err)
stpapi.end.session("tuudi0420m000")
}

tmannais
25th May 2018, 05:00
Thanks mark_h. I tried what you suggested but It didn't work.
I also tried putting in all of the fields in the print session. It also didn't work.

mark_h
25th May 2018, 14:12
Does it even work if you send it to a printer or the display?

tmannais
28th May 2018, 04:19
Yes. When I tested it by manually put the fields and click the buttons, it worked fine.

tmannais
28th May 2018, 06:39
I tried changing session to print preview. It is now "tdsls1500m100".
This is current code:

spool.preview = 1
stpapi.put.field(session.code, "tdsls100.qono", str$(i.sales.quotation))
stpapi.find(session.code, error.msg)
if not isspace(error.msg) then
error.msg = "Cannot find record: " & error.msg
stpapi.end.session(session.code)
return(error.msg)
endif
stpapi.mark(session.code, error.msg)
if not isspace(error.msg) then
error.msg = "Cannot mark record: " & error.msg
stpapi.end.session(session.code)
return(error.msg)
endif
stpapi.set.report(session.code, "rtdsls140101000", "D", error.msg)
if not isspace(error.msg) then
error.msg = "Cannot set report: " & error.msg
stpapi.end.session(session.code)
return(error.msg)
endif
stpapi.print.report(session.code, error.msg)
if not isspace(error.msg) then
error.msg = "Cannot print preview: " & error.msg
stpapi.end.session(session.code)
return(error.msg)
endif
stpapi.end.session(session.code)
return(error.msg)

With this code, it displays a option window that contains "preview" option in it (See attached image). However, I have to click it manually and, moreover, nothing happens after that and the session is closed without errors.
What I need is just to print to that preview option with correct result.

mark_h
29th May 2018, 01:18
That is an issue to start with - when you run AFS code nothing should pop up in the foreground. So not sure what is up with that. The screen that pops up almost looks like the screen that if you run manually it would pop up and ask you which report to run. So you find a sales quote, mark it, then I suppose you hit something like continue. When you run it manually does that same screen pop up? Also is it launching another session to do the printing?

The code I posted was setting the preview on ttstpspool device session. That is where I can select a windows printer and check print preview. This looks different that what I was thinking.

tmannais
30th May 2018, 05:12
I find a Sales Quote, mark it, and then I try to print preview that's where the screen pops up. When I run it manually, after I click the preview menu in order to print preview it skips the screen and go straight to report selection and then followed by the device selection session.

mark_h
30th May 2018, 14:49
You click the preview menu - is that a button or on the tools menu? Maybe this is something you have to run before you do the report command in the AFS code.

tmannais
31st May 2018, 04:29
It is a tools menu called Action in LN Web UI. I attached an image so you can see what it looks like. However, this Action tools menu does not exist in BECS(Worktop). I mean it has its session and all but there is no menu or anything similar to this in LN Web UI. The closet thing it has is to print normally and choose preview option. I couldn't do that with AFS either.
In addition, I asked Infor Extreme Support about the DOCMAN device. He told me that this device specifically cannot be scripted to print as device DOCMAN because BECS(Worktop) cannot even handle the device. Device DOCMAN can only be used in LN Web UI on LN 10.3 or higher only.
So, in this case, I want to reduce the scope just to be able to print the preview with other normal device such as D, PDF, and SSRS. Don't bother with DOCMAN anymore. (but I really need that if it is somehow possible)

mark_h
31st May 2018, 16:19
Wow - that is way out of my league. Anyway you do same type stuff with dal2 functionality?

tmannais
1st June 2018, 04:28
I haven't tried achieving this with DAL2 because I thought it cannot be done like that but I will give it a try.