I want to print multiple focexecs at the same time. A way I thought I could do it was to save the reports to disk and print the reports from disk. The reports are saved as PDF. The only trouble printing PDF reports you first have to display them in order to print them.
Here is my code:
-* File printrpts.fex -SET &FILE_NAME = 'C:\TEMP\' | REPORT1 || '.pdf'; FILEDEF REPORT1 DISK &FILE_NAME -RUN -SET &FILE_NAME = 'C:\TEMP\' | REPORT2 || '.pdf'; FILEDEF REPORT2 DISK &FILE_NAME -RUN ? FILEDEF -* -GOTO NOMORE TABLE FILE GGSALES SUM DOLLARS BY PRODUCT ON TABLE HOLD AS REPORT1 FORMAT PDF OPEN END -RUN -SET &FILE_NAME = 'C:\TEMP\' | REPORT2 || '.pdf'; FILEDEF REPORT2 DISK &FILE_NAME -RUN
TABLE FILE GGSALES SUM UNITS DOLLARS BY PRODUCT ON TABLE HOLD AS REPORT2 FORMAT PDF CLOSE END -RUN -DOS PRINT C:\TEMP\*.PDF -NOMORE
Lname Device Lrecl Recfm Append Filename ============================================================ REPORT2 DISK 0 V C:\TEMP\REPORT2.pdf REPORT1 DISK 0 V C:\TEMP\REPORT1.pdf PSCONNS DISK 100 V F:\ibi\srv71\wfs\edatemp\ts000 011\psconns.ftm 0 PDF FILE SAVED ... Unable to initialize device PRN
Can anyone give any suggestions how to print multiple fex's at the same time.This message has been edited. Last edited by: Kerry,
WebFocus 7.6.6 Oracle 10 Windows XP
May 16, 2007, 04:44 PM
Glenda
Jay,
We had the same problem here with HTML files. After hunting for software that would "send" unattended print and being told that there were none available, Brian (my co worker) would not accept this answer. Here is his solution:
Yes, this is a pain. We had a similar situation where one of our over night batch jobs needed to be printed and delivered to a user before they arrived at work. The print area was not too keen on having a file sent to them and opening it to print so we needed to come up with a way to print them in an unattended manner. Since this job runs with great regularity at around 3:00 am in the morning I came up with a VBScript that would submit the print around 4:00 am. This is not without faults do to set up but it works.
Hurdles: 1) Actually executing the Script 2) Data file is on Unix and Script requires a Windows platform 3) Selecting the correct printer - our print had to go to a mainframe printer and not a local printer attached to the machine 4) Box running the script has to have the desired printer defined 5) Script actually activates the Print Dialogue Box and requires the user to click the OK button
Solutions: 1) Our solution is to have a mainframe scheduler "ZEKE" execute the script. Others available are to have a machine's NT Scheduler execute the script or to set up a listener program on to a folder so that when a file appears in that folder to execute the script. (dont know how to set up the listener) 2) Expanded script to first FTP the file to a windows platform 3) Expanded script to select the desired printer 4) Went to that physical server and loaded that printer and set the default preferences so that when the script selected the printer, no preferences for that print job would need to be inputted. 5) This is the problematic one. The only way to get that blasted OK button to execute is to use "Send Key". Typically this is a HUGE "No No" in scripting due to security issues, but all it has to do is send an "Enter" command. Once the Print command is issued, time for rendering is needed so you have to have a sleep command to allow for rendering before the dialogue box appears. Also, if the box executing the script has a user on it, then when the Send Key command fires, the active app will receive an Enter command. When that dialogue box appears, you have to wait until the sleep command finishes and submits the enter key. This was solved by using a server that does not run apps or have a user sitting at it around 4 in the morning. Lastly, I had to set the default printer for that box back to its original setting so I needed some pre-information for that box.
D=Day(Date())
If M < 10 Then MM="0" & M Else MM=M End If If D < 10 Then DD="0" & D Else DD=D End If
FILE_DATE = Y & MM & DD
Dim BATCH_File, FUNCT_File BATCH_File="\\filepath\ftp.bat" FUNCT_File="\\filepath\ftp"
Dim m_fso, n_ts, m_ts
'--CREATE THE FILE SYSTEM OBJECT Set m_fso = CreateObject("Scripting.FileSystemObject")
'----CREATE THE BATCH FILE THAT RUNS THE FTP SCRIPT Set m_ts = m_fso.CreateTextFile(BATCH_File, True)
'----CREATE THE FTP SCRIPT DOCUMENT Set n_ts = m_fso.CreateTextFile(FUNCT_File, True)
'----WRITE THE BATCH FILE - THIS BATCH FILE IS ONLY TWO LINES LONG. ' IT CONTAINS THE CALL TO THE FTP SCRIPT AND THE LINE TO DELETE THE SCRIPT. m_ts.WriteLine("ftp -s:\\filepath\ftp")
'----THE FTP SCRIPT FILE CONTAINS COMMANDS THAT SHOW THE USERS LOGON ID AND PASSWORD ' SO THE SCRIPT FILE NEEDS TO BE DELETED AFTER COMPLETION m_ts.WriteLine("del \\filepath\ftp")
'----CLOSE THE BATCH FILE TEXT DOCUMENT m_ts.close
'----CLOSE THE FTP SCRIPT FILE TEXT DOCUMENT n_ts.close '----END OF FTP SCRIPT FILE WRITING
'----EXECUTE BATCH FILE Dim WSHShell Set WSHShell = CreateObject("Wscript.Shell") WSHShell.Run("\\filepath\ftp.bat > \\filepath\bat_out.txt") WScript.Sleep 10000 End Sub
'------------------------------------------------------------------------------------------------------------ ' PRINT SUBROUTINE '------------------------------------------------------------------------------------------------------------ Sub prt() '----GENERATE EXECUTION DATE TO MATCH TO IDCARD FILE Dim Y,M,D,DD,MM Dim Exec_Date Dim File_Date
Y=Year(Date()) M=Month(Date()) D=Day(Date())
If M < 10 Then MM="0" & M Else MM=M End If If D < 10 Then DD="0" & D Else DD=D End If
Exec_Date = Y & MM & DD
'------------------------------------------------------------------- ' READ NAME OF FILES IN THE IDCARD FOLDER TO LOCATE ' THE FILE WITH TODAYS EXECUTION DATE AND GIVE THE ' "GO" TO THE GO-NO-GO VARIABLE AND PROCESS PRINT '------------------------------------------------------------------- Dim TargetFolder Dim objShell Dim objFolder Dim colItems Dim i TargetFolder = "\\filepath" Set objShell = CreateObject("Shell.Application") Set objFolder = objShell.Namespace(TargetFolder) Set colItems = objFolder.Items For i = 0 to colItems.Count - 1
File_Date = Left(colItems.Item(i).name,8)
If File_Date = Exec_Date Then
colItems.Item(i).InvokeVerbEx("Print")
'----GIVE TIME FOR HTML RENDERING BEFORE SENDING COMMAND Dim WshShell Set WshShell = WScript.CreateObject("WScript.Shell") WScript.Sleep 105000 WshShell.SendKeys "{ENTER}" Else End If
Next End Sub
'------------------------------------------------------------------------------------------------------------ ' SET PRINTER TO 11TH FLOOR AND RUN SUBROUTINES '------------------------------------------------------------------------------------------------------------ '------------------------------------------------------------------- ' ENUMERATE PRINTERS AVAILABLE TO COMPUTER '------------------------------------------------------------------- 'Option Explicit Dim oPrinter, oNetwork, iCount Set oNetwork = WScript.CreateObject("WScript.Network") Set oPrinter = oNetwork.EnumPrinterConnections '------------------------------------------------------------------- ' SET DEFAULT PRINTER '------------------------------------------------------------------- Dim objPrinter Set objPrinter = CreateObject("WScript.Network") objPrinter.SetDefaultPrinter "\\SRVPRINT\Xerox..." '------------------------------------------------------------------- ' '------------------------------------------------------------------- ftp() prt() '------------------------------------------------------------------- ' RESET DEFAULT PRINTER '------------------------------------------------------------------- objPrinter.SetDefaultPrinter "\\SRVPRINT\grpqual"
Hope this helps you in some way.
Glenda and Brian
Glenda
In FOCUS Since 1990 Production 8.2 Windows
May 16, 2007, 05:08 PM
Darin Lee
A lot of this depends on the printers you have. I am assuming you are doing this without ReportCaster? (With ReportCaster, you can do this easily with a printer that has a printer queue for printing PDF docs.) One simple method would be to use the code you currently have and save the document as format .PS instead of .PDF. We found the output to be nearly identical. It must be sent to a postscript-enabled printer, but most (not all) of them are nowadays. It can just be copied to PRN and the printer handles the rest since the postscript is streaming code. We have used this method for several years now with great success.
Regards,
Darin
In FOCUS since 1991 WF Server: 7.7.04 on Linux and Z/OS, ReportCaster, Self-Service, MRE, Java, Flex Data: DB2/UDB, Adabas, SQL Server Output: HTML,PDF,EXL2K/07, PS, AHTML, Flex WF Client: 77 on Linux w/Tomcat
August 25, 2009, 09:31 AM
Ian Dalton
Hi Darin, Tried your tip below ie. using .ps fromat instead of .pdf format and it works well. There are very subtle differences between the 2 formats. Can you open .ps docs with any standard software so that we can view this output (as well as just sending straight to the printer) ? Regards, Ian
quote:
Originally posted by Darin Lee: A lot of this depends on the printers you have. I am assuming you are doing this without ReportCaster? (With ReportCaster, you can do this easily with a printer that has a printer queue for printing PDF docs.) One simple method would be to use the code you currently have and save the document as format .PS instead of .PDF. We found the output to be nearly identical. It must be sent to a postscript-enabled printer, but most (not all) of them are nowadays. It can just be copied to PRN and the printer handles the rest since the postscript is streaming code. We have used this method for several years now with great success.
_______________________ *** WebFOCUS 8.1.05M ***
August 25, 2009, 06:31 PM
Darin Lee
I believe the newer verions of Adobe Acrobat Reader will open .PS files now, but for years I have used utilities like GSview and Ghostscript for viewing them.
I would be interested to know if you have found any differences between the two. After several months of comparing the two, I quit and decided my rule of thumb was that they produced the same output. Have not done a comparison recently.
Regards,
Darin
In FOCUS since 1991 WF Server: 7.7.04 on Linux and Z/OS, ReportCaster, Self-Service, MRE, Java, Flex Data: DB2/UDB, Adabas, SQL Server Output: HTML,PDF,EXL2K/07, PS, AHTML, Flex WF Client: 77 on Linux w/Tomcat
August 27, 2009, 04:41 AM
Ian Dalton
Yes thanks Darin - I have installed Ghostview 8.64 and it works well.
_______________________ *** WebFOCUS 8.1.05M ***
August 27, 2009, 08:23 AM
Tony A
Ian,
You do not have your platform within your signature so I've no idea if this would suit you, but you can print PDFs to a default printer using VBScript (providing you have acrobat reader installed!) -
set oWsh = CreateObject ("Wscript.Shell")
oWsh.run """Acrobat.exe"" /p /h" [FullPath_and_FileName],,true
T
In FOCUS since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2
WebFOCUS App Studio 8.2.06 standalone on Windows 10