Enclosed in this document is a sample CL program for:
- Sending an AS/400 file to a PC desktop.
- Launching MS Word and running a letter mail merge using the "MERGELETTER" OLE command and the selected template file.
Using the mail merge CL sample:
- Create a TEMP directory on the C: drive of your PC.
- Detach the enclosed MERGE1.DOT template file to C:\TEMP
- Enter and compile the CL program listed below
- Make sure your PC has the "RJS FTP Server" component installed and running. V1.0.4 or above is required
- Run the CL program to transfer AS/400 file QIWS/QCUSTCDT to C:\TEMP\MERGE1.TXT and then launch MS Word to automatically merge the data in C:\TEMP\MERGE1.TXT with the document template: C:\TEMP\MERGE1.DOT
Creating an ODBC Data Source for MS Word Access
- From Windows desktop, select Start/Run and type: ODBCAD32.EXE
- Click "OK" to start the ODBC Administrator
- Click the "Add" button to create a new ODBC data source
- Select "Microsoft Text Driver" for the driver type and click the "Finish" button
- Enter "Text Files" for the data source name
- Click "OK" to create the new data source
Please contact RJS Software Systems Inc. with any questions you may have.
PGM
DCL VAR(&RTNIP) TYPE(*CHAR) LEN(15)
/*************************************************/
/* GET CURRENT WORKSTATION IP ADDRESS */
/*************************************************/
FTPIP DEVD(*) IPADDR(&RTNIP)
/*************************************************/
/* CONVERT FILE QCUSTCDT TO CSV FORMAT FOR MERGE */
/* AND SEND TO THE SELECTED REMOTE DIRECTORY */
/* */
/* NOTE: FOR THIS DEMO WE USE *DSP FOR THE LOG */
/* OPTION. THE LOG CAN BE DISABLED IN PRODUCTION */
/* NOTE: C: DRIVE IS THE PC DRIVE LOCATION FOR */
/* /TEMP/MERGE1.TXT. */
/*************************************************/
SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('Sending +
File to PC via FTP') TOPGMQ(*EXT) +
MSGTYPE(*STATUS)
FTPDBSND RMTSYS(&RTNIP) FILE(QIWS/QCUSTCDT) +
FLDDLM(*COMMA) COLHDG(*YES) +
RMTFIL('/TEMP/MERGE1.TXT') USR(TEST) +
PWD(TEST) LOGOPT(*DSP)
MONMSG MSGID(CPF0000) EXEC(SNDPGMMSG MSGID(CPF9898) +
MSGF(QCPFMSG) MSGDTA('Errors occurred +
while sending AS/400 file to remote PC') +
MSGTYPE(*ESCAPE))
/**********************************************/
/* ATTEMPT TO RUN MAIL MERGE INTO A NEW */
/* MS WORD DOCUMENT. */
/* PARAMETERS: */
/* 1.) MERGELETTER - THIS OPTION IS USED TO */
/* MERGE TO A NEW LETTER AND ALLOW THE */
/* USER TO REVIEW PRIOR TO PRINTING OR */
/* SAVING THE MS WORD DOCUMENT. */
/* 2.) TEMPLATE PC FILE NAME. */
/* 3.) MAIL MERGE DATA FILE NAME IN CSV FMT. */
/**********************************************/
SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) +
MSGDTA('Launching MS word Mail Merge') +
TOPGMQ(*EXT) MSGTYPE(*STATUS)
FTPRUNPC RMTSYS(&RTNIP) +
CMD('MERGELETTER~C:\TEMP\MERGE1.DOT~C:\TEMP+
\MERGE1.TXT') OPTION(*WORDOLE)
MONMSG MSGID(CPF0000) EXEC(SNDPGMMSG MSGID(CPF9898) +
MSGF(QCPFMSG) MSGDTA('Errors occurred +
while running mail merge porocessing.') +
MSGTYPE(*ESCAPE))
ENDPGM
Last Modified On:
No, open a new Support Case