Using FDMERGE multi-threaded forms merge command for merging forms on the fly from a CL or RPG program
From Support
Overview As of version 3.64 of the WINSPOOL library coupled with the WinSpool/400 Electronic Forms Print Server, iSeries users can use the new FDMERGE CL command to merge a text based (SCS) spool file natively on the iSeries with a form overlay and either capture or print the results via one of the following options: 1.) Doc can be captured and merged to the IFS as a PDF or PCL file. 2.) Doc can be captured and merged into an output queue on the iSeries as a PDF or PCL file. 3.) Doc can be captured and merged and printed directly on any PC or network printer connected to the PC print server.
The FDMERGE command can be called interactively or can be embedded into a CL or RPG program to merge form documents as the text spool files are generated on the AS/400 or iSeries system.
NOTE: The FDMERGE command is located within the WINSPOOL library and replaces the FDMRGSPLF command in functionality. FDMRGSPLF suffered from the inability to be multi-threaded. FDMERGE talks to an ASP.Net web application so several iSeries jobs can be merging documents at the same time. However we recommend around 4-8 threads maximum per print server PC. Number of threads can be controlled from the iSeries by creating a job queue where FDMERGE commands are submitted to with a maximum number of active jobs.
Software Requirements
iSeries Software Requirements 1.) WINSPOOL library V3.64 or above. 2.) OS/400 V5R1 and above.
PC Requirements 1.) VB5 Runtime Files 2.) .Net Framework Version 1.1 3.) .Net Framework Version 2.0 4.) WinSpool/400 Report Download 5.) WinSpool/400 Electronic Forms 6.) RJS Forms Merge Engine (Should already get installed with WinSpool Electronic Forms.) 7.) FormDocs software. 8.) RJSFormServer ASP.Net Application installed in C:\INETPUP\wwwroot\RJSFormServer
FDMERGE Parameters (Merge Spool with Form Overlay) Spooled file - Spool file name
Job name/user/number - Enter the appropriate job information.
Spooled file number - Enter a spool file number to capture.
Form overlay template name - Enter the prefix to be used when locating the FormsDocs overlay template on the forms print server in C:\Program Files\FormDocs\Templates directory. Example: If INVOICE is entered, the print server will look for a template named: INVOICE.FDT and a text layer file of INVOICE.TLR
Note: The default FormDocs template directory can be change in the RJSFormServer ASP.Net application by editing the Web.Config file setting.
Special values:
- SPOOL - Substitute spool file (Default),
- USERDATA - Substitute user data value,
- FORMTYPE - Substitute form type,
- JOBNAME - Substitute job name.
Form destination option - This setting determines where the merged output will go during the form overlay process.
- IFSFILE - The document will go to the IFS output file specified in the IFS merged output file name parameter. (Default)
- PCPRINTER - The document will print on the PC printer connected to the PC forms print server based on the info passed on the Form merge printer driver parameter.
- DESTOUTQ - The document will be re-spooled into an iSeries output queue for printing or distribution based on the destination output queue info. The original spool file name, user data, form type and user defined data valued can be retained.
Form merge data output format - This setting determines the data format output when a document is merged.
PDF - Document will be converted to PDF when PDF is specified and the Form merge printer driver name is set to *NONE. PCL - Document will be converted to PCL, Postscript or whatever based on the PC printer driver specified and the Form merge printer driver name parameter. Example: If HP LaserJet 4 is specified, the data output will be created in PCL format.
TIF - Not supported yet. FDD - Not supported yet. CSV - Not supported yet.
Form merge printer driver name - Enter a valid printer driver connected to the electronic forms print server locally or via the network. This setting can be used to print directly to a network printer or to format the distributed output file data based on the printer driver. This is a nice way to capture PCL or Postscript data into an output file after a form is merged. (Default = *NONE)
Example: If HP LaserJet 4 is specified, the data output will be created in PCL format.
IFS merged output file name - IFS output file name used if *IFSFILE is selected for the form destination option. (Default = *NONE)
PC/LAN merged output file name - PC or LAN UNC file name or path used if *PCFILE is selected for the form destination option. (Default = *NONE)
Replace IFS or PC output file - *NO - Do not replace existing file. (Default) *YES - Replace existing file.
Merge dest output queue - Enter an output queue and library name for the queue where the report will be re-spooled to in PDF or PCL format if *DESTOUTQ is chosen for the form destination option.
Spool file name - Spool file name for new spool (*SAME - Keep same value as original spool)
User data - User data value for new spool (*SAME - Keep same value as original spool)
Form type - Form type for new spool (*SAME - Keep same value as original spool)
User defined data - User defined data value for new spool (*SAME - Keep same value as original spool)
Hold spool file - Hold spool file when generated (*SAME - Keep same value as original spool, *NO, *YES)
Save spool file - Save spool file after printing (*SAME - Keep same value as original spool, *NO, *YES)
Copies - Number of print copies. Default - 1
Delete original spool file - Delete spool file after merging. Default-*NO (*NO, *YES)
Display HTTPresponse log - Display the reponse received from the RJSFormServer ASP.Net application. Used for testing or debugging purposes Default-*NO (*NO, *YES)
Example Command Calls to FDMERGE
Writing merged electronic form document to an IFS File in PDF Format Run the FDMERGE command to Merge an iSeries text report with a form overlay named INVOICE.FDT and place the resulting file in /test.pdf in the IFS
FDMERGE FILE(INVOICE) JOB(110513/DICK/QPADEV0007) SPLNBR(38) MRGOPTION(*IFSFILE) MRGDTAFMT(PDF) MRGIFSFILE('/test.pdf') REPLACE(*YES) RMTSYS('125.1.1.33') USR(USER) PWD(PASSWORD) LOGOPT(*NONE)
Writing merged electronic form document to an output queue in PDF Format Run the FDMERGE command to Merge an iSeries text report with a form overlay named INVOICE.FDT and place the resulting PDF formatted file into the selected output queue. The spool file name, user data, form type and user defined data information are preserved.
FDMERGE FILE(INVOICE) JOB(110513/DICK/QPADEV0007) SPLNBR(38) MRGOPTION(*DESTOUTQ) MRGDTAFMT(PDF) MRGPRTDRV(*NONE) REPLACE(*NO) MRGOUTQ(QGPL/SAMPLES) RMTSYS('125.1.1.33') USR(USER) LOGOPT(*NONE)
Writing merged electronic form document to an output queue in PCL Laserjet Format Run the FDMERGE command to Merge an iSeries text report with a form overlay named INVOICE.FDT and place the resulting PCL formatted file into the selected output queue. The spool file name, user data, form type and user defined data information are preserved. Note that this example uses a printer driver named: HP LaserJet 4 to tell the print server to convert the data stream to PC based on the HP driver installed on the print server PC.
Note: This process will fail if you don't have the specified printer driver loaded on the selected PC. If you want to format your report in Postscript, PCL or some other variation,simply install the selected printer driver on the print server PC and specify the printer name on the MRGPRTDRV parameter.
FDMERGE FILE(INVOICE) JOB(110513/DICK/QPADEV0007) SPLNBR(38) MRGOPTION(*DESTOUTQ) MRGDTAFMT(PCL) MRGPRTDRV('HP LaserJet 4') REPLACE(*NO) MRGOUTQ(QGPL/SAMPLES) RMTSYS('125.1.1.33') USR(USER) LOGOPT(*NONE)
Printing merged electronic form document directly via a printer connected to the print server PC Run the FDMERGE command to Merge an iSeries text report with a form overlay named INVOICE.FDT and print the resulting PCL formatted file using the selected PC printer. Note that this example uses a printer driver named: HP LaserJet 4 to tell the print server to convert the data stream to PC based on the HP driver installed on the print server PC and print it right away.
Note: This process will fail if you don't have the specified printer driver loaded on the selected PC. If you want to format your report in Postscript, PCL or some other variation,simply install the selected printer driver on the print server PC and specify the printer name on the MRGPRTDRV parameter.
FDMERGE FILE(INVOICE) JOB(110513/DICK/QPADEV0007) SPLNBR(38) MRGOPTION(*PCPRINTER) MRGDTAFMT(PCL) MRGPRTDRV('HP LaserJet 4') RMTSYS('125.1.1.33') USR(USER) LOGOPT(*NONE)
Initial PC Server Setup
1.) Install and license WinSpool Electronic Forms Print Server on PC
2.) Install Microsoft IIS Web Server on Windows XP or Windows 2003 PC. (Not tested with Vista yet.)
3.) Install .Net Runtime 1.1 and 2.0 if not already installed.
4.) Unzip and install ASP.Net Web Application for Forms Server http://downloads.rjssoftware.com/files/ws_eforms/rjsformserver/rjsformserver.exe
Unzip file to c:\inetpub\wwwroot\RJSFormServer
5.) Start IIS Manager program via Start/Settings/Control Panel/Administrative Tools/Internet Information Services.
6.) Expand default web site, then right-click the RJSFormServer directory and select Properties to show info for the RJSFormServer web application directory.
7.) On the Virtual Directory or Directory tab under Application Settings, click the Create button.
8.) Under Application Protection, select: Low (IIS Process). Then click Apply.
9.) Click the Directory Security tab. Under Anonymous access and authentication control, click Edit.
10.) Type in a Windows Local Administrator level or Power User user ID and password. Uncheck Allow IIS to control password. Click OK. Click OK again.
Note: For Windows 2000, You MUST use the <Domain>\Administrator account. If you are not on a domain, ONLY the <Local>\Administrator user can be entered here. All other users will cause errors when accessing the printers.
11.) Edit C:\INETPUB\wwwroot\RJSFormServer\Web.Config with Windows notepad or Wordpad to make sure all directories exist that are listed under application settings.
TempDirectory - C:\RJSTEMP (May need to manually create.) FormDocsDirectory - C:\Program Files\FormDocs FormDocsTemplateDirectory - C:\Program Files\FormDocs\Templates
12.) While editing Web.Config, enter a valid Windows User/Password for Identity Impersonate. This allows our ASP.Net application to access the RJSFormsMerge ActiveX object.
Note: Use the same userid and password we used to set up Anonymous access and authentication control above.
Note: For Windows 2000, You MUST use the <Domain>\Administrator account. If you are not on a domain, ONLY the <Local>\Administrator user can be entered here. All other users will cause errors when accessing the printers.
Example using MYUSER and MYPASSWORD:
Ex: <identify impersonate ="true" userName="MYUSER" password="MYPASSWORD" />
13.) In order to be able to use the Forms Merge Engine ActiveX, you must configure local permissions to allow the user specified for Anonymous access in IIS to access ActiveX and other operating system programs as needed
Launch the policy editor via: Start/Settings/Control Panel/Administrative Tools/Local Security Policy.
Under Local Policies/User Rights Assignment, double-click on Act as part of the operating system.
Add the same user that was specified under Anonymous access and authentication control in IIS Manager.
Note: Use the same userid and password we used to set up Anonymous access and authentication control above.
Note: For Windows 2000, You MUST use the <Domain>\Administrator account. If you are not on a domain, ONLY the <Local>\Administrator user can be entered here. All other users will cause errors when accessing the printers.
14.) Restart IIS Web Server processes.
Note: This is a required step or you may get ActiveX errors when trying to run a forms merge.
Select Start/Run and type COMMAND. Click OK to open the DOS window.
Run each of the following DOS commands:
net stop w3svc
net stop iisadmin
net start iisadmin
net start w3svc
15.) Make sure that the default Windows printer points to an actual printer or you may see FDD.EXE log up in the Windows task list.
You can get to the printer list via Start/Settings/Printers and Faxes. Then right-click on the printer you want to be the default printer and select "Set as Default Printer."
Note: Do NOT ignore this step.
16.) Open Internet Exporer and run the following URL from the forms server PC
http://localhost/RJSFormServer/mergeForm.aspx
17.) If you see: ERROR: FormDocsTemplate parameter is required, then all is good.
If you see an Unable to create activeX error after running FDMERGE command, make sure to completely restart IIS service from IIS Manager again.
This completes the initial PC server setup.
Initial iSeries Setup
1.) Install updated WINSPOOL library V3.64 and above and make sure that the FDMERGE command exists in the library.
2.) Determine the IP address where the RJSFormServer ASP.Net program is loaded, by going to the PC and typing IPCONFIG <enter> from the DOS command line.
3.) Set the data are which points to the print server where IIS is loaded based on the determined PC IP address.
Example using port 80: CHGDTAARA DTAARA(WINSPOOL/FDMRGHOST) VALUE('http://1.1.1.1')
Example using port 1080: CHGDTAARA DTAARA(WINSPOOL/FDMRGHOST) VALUE('http://1.1.1.1:1080')
4.) Set the HTTP timeout data area
Example set to 60 seconds: CHGDTAARA DTAARA(WINSPOOL/FDTIMEOUT) VALUE(60)
5.) Create sample INVOICE report on the iSeries for testing
ADDLIBLE WINSPOOL
WSPTEST1 OUTQ(WSPEFORM) OUTQLIB(QGPL)
6.) Run a merge on the sample report.
FDMERGE FILE(INVOICE) JOB(*) SPLNBR(*LAST) MRGOVERLAY(*SPOOL) MRGOPTION(*I
FSFILE) MRGDTAFMT(PDF) MRGPRTDRV(*NONE) MRGIFSFILE('/TEST.PDF') REPLACE(*YES) DSPLOG(*YES)
You will get a CPF9898 if errors occur. Otherwise the PDF should exist after command completion.
Note: For testing we enabled on the DSPLOG parameter
Note: The benchmark with a Pentium 3.0ghz PC yielded a merge of our sample invoice between 3-5 seconds.
