Enclosed in this document is a sample CL program for:
 
  1. Sending an AS/400 file to a PC desktop. 
  2. 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:
 
  1. Create a TEMP directory on the C: drive of your PC.
  2. Detach the enclosed MERGE1.DOT template file to C:\TEMP
  3. Enter and compile the CL program listed below
  4. Make sure your PC has the "RJS FTP Server" component installed and running. V1.0.4 or above is required
  5. 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
 
  1. From Windows desktop, select Start/Run and type: ODBCAD32.EXE
  2. Click "OK" to start the ODBC Administrator
  3. Click the "Add" button to create a new ODBC data source
  4. Select "Microsoft Text Driver" for the driver type and click the "Finish" button
  5. Enter "Text Files" for the data source name
  6. 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                                                     

 


Still have questions? We can help. Submit a case to Technical Support.

Last Modified On: December 10, 2016