Sample FTP/400 Remote Command Server Calls using the FTPRUNPC command - Support

Sample FTP/400 Remote Command Server Calls using the FTPRUNPC command

From Support

Jump to: navigation, search

Overview

The FTP/400 Remote Command Server is an easy way to call PC programs from the AS/400. It's also a great way to integrate AS/400 screen applications with PC applications. You can end the days of users retyping data by integrating the FTP/400 Remote Command Server into your applications.

Contact RJS Software Systems with your enhancement ideas for this product. We'll be continually enhancing the software and adding additional capabilities.

Example - Integrated Word Processing into an Order Entry Application:

A customer service rep entering an order on the AS/400 can hit a function key that automatically calls a CL program to launch MS Word, Load a selected letter template and then automatically fill in the selected customer information. What a time saver this could be.

Example - Launch a Nightly PC Application Job:

The AS/400 job scheduler can be used to kick off a nightly process on a Windows 95/98/NT/2000 PC. The AS/400 process can continue right away or wait for the PC job to finish. This is a nice way to run nightly file downloads or other processes on the PC directly from the AS/400.

FTPRUNPC Command Samples


*SHELL Sample

1.) The following *SHELL example launches a PC program using the Windows shell command. The AS/400 does not wait for the command to finish.

Note: To launch a program with the *SHELL option, the entire command line and path should be specified. A program call may work without the path of the EXE is in the users PC search path, but it's safer to specify the full command line if you're not sure. A program name/document name combination can also be passed.

FTPRUNPC CMD('C:\WINNT\NOTEPAD.EXE') OPTION(*SHELL)  

FTPRUNPC CMD(NOTEPAD.EXE) OPTION(*SHELL)  

FTPRUNPC CMD('C:\WINNT\NOTEPAD.EXE C:\TEST.TXT') OPTION(*SHELL)  

*SHELLWAIT Sample

2.) The following *SHELLWAIT example launches a PC program using the Windows shell command. The AS/400 will wait for the command to finish.

Note: To launch a program with the *SHELLWAIT option, the entire command line and path should be specified. A program call may work without the path of the EXE is in the users PC search path, but it's safer to specify the full command line if you're not sure.

FTPRUNPC CMD('C:\WINNT\NOTEPAD.EXE') OPTION(*SHELLWAIT) 

*LAUNCH Sample

3.) The following *LAUNCH example launches a selected PC document. The associated application will be opened based on the file extension. In this example the .DOC extension will open MS Word. The AS/400 does not wait for the command to finish.

Note: To launch a program with the *LAUNCH option, the document path must be specified. UNC paths or drive letters can be used. If a drive letter is used, the drive letter must already be mapped on the selected PC.

Note: If the document type doesn't have an associated program in Windows, the document may not launch.

FTPRUNPC CMD('t:\wpdocs\agchem01.doc') OPTION(*LAUNCH)

FTPRUNPC CMD('\\server\wpdocs\agchem01.doc') OPTION(*LAUNCH)   

*LAUNCHWAIT Sample

4.) The following *LAUNCHWAIT example launches a selected PC document. The associated application will be opened based on the file extension. In this example the .DOC extension will open MS Word. The AS/400 will wait for the command to finish.

Note: To launch a program with the *LAUNCHWAIT option, the document path must be specified. UNC paths or drive letters can be used. If a drive letter is used, the drive letter must already be mapped on the selected PC.

Note: If the document type doesn't have an associated program in Windows, the document may not launch.

FTPRUNPC CMD('t:\wpdocs\agchem01.doc') OPTION(*LAUNCHWAIT)

FTPRUNPC CMD('\\server\wpdocs\agchem01.doc') OPTION(*LAUNCHWAIT)   

*LAUNCHEXEC Sample

5.) The following *LAUNCHEXEC example launches a selected program or document using the Windows ShellExec operation. This option is very flexible because you can specify either a PC file/document name or program name/command line to launch. The AS/400 does not wait for the command to finish.

Note: To launch a program with the *LAUNCHEXEC option, the program name or document path must be specified. UNC paths or drive letters can be used. The drive letter must already be mapped on the selected PC.

Note: If the document type doesn't have an associated program in Windows, the document may not launch.

FTPRUNPC CMD('t:\wpdocs\agchem01.doc') OPTION(*LAUNCHEXEC)
FTPRUNPC CMD(NOTEPAD.EXE) OPTION(*LAUNCHEXEC)   

*WEBSITE Sample

6.) The following *WEBSITE example launches a selected website using the default Windows browser. The AS/400 does not wait for the command to finish. This is a great way to integrate web sites into AS/400 applications.

FTPRUNPC CMD('http://www.rjssoft.com') OPTION(*WEBSITE)

*WORD Sample

7.) The following *WORD example launches MS Word on the PC. The AS/400 does not wait for the command to finish. This is a great way to quickly launch MS Word.

FTPRUNPC CMD() OPTION(*WORD)

*EXCEL Sample

8.) The following *EXCEL example launches MS Word on the PC. The AS/400 does not wait for the command to finish. This is a great way to quickly launch MS Word.

FTPRUNPC CMD() OPTION(*EXCEL)

*MSGBOX Sample

9.) The following *MSGBOX example pops up a message box on the user PC and they must press OK before the AS/400 job will continue.

FTPRUNPC CMD('This is a test message') OPTION(*MSGBOX)

*CLIPCLEAR Sample

10.) The following *CLIPCLEAR example clears the Windows clipboard.

FTPRUNPC CMD() OPTION(*CLIPCLEAR)

*CLIPSET Sample

11.) The following *CLIPSET example clears the Windows clipboard and sets the clipboard with the selected text..

FTPRUNPC CMD('Test Clipboard Data') OPTION(*CLIPSET)

*CLIPAPPEND Sample

12.) The following *CLIPAPPEND example adds to any existing text in the clipboard.

FTPRUNPC CMD('Test Clipboard Data') OPTION(*CLIPAPPEND)

*WORDOLE Sample

13.) The following *WORDOLE commands allow users to interact with MS Word. Currently the basic WORD OLE commands allow users to create simple mail merge documents. RJS will be expanding this support based on customer feedback. The following examples launches Word with a selected mail merge template and then fills in the template document.

These commands can be strung together in a CL program to create a specific mail merge application.

This command launches MS Word:

FTPRUNPC CMD('WORDLAUNCH') OPTION(*WORDOLE)

This command opens the selected template:

FTPRUNPC CMD'(WORDOPENTEMPLATE~C:\TESTMEMO.DOT') OPTION(*WORDOLE)

This command finds the selected bookmarks within the document template and inserts the passed data into the word document. When embedded in a CL program the text values can be substituted with CL variables: FTPRUNPC CMD('WORDINSERTBOOKMARK~TO_FIELD~Valued Customer~FROM_FIELD~RJS Software~CC_FIELD~Nobody Else~RE_FIELD~This is a FTP Remote Command Server MS Word Test') OPTION(*WORDOLE)

This command inserts the passed data into the word document at the exact point where the cursor is at in the Word document. The special value <CRLF> will insert a Carriage Return/Linefeed into the data at the selected point in the text data being passed. When embedded in a CL program the text values can be substituted with CL variables:

FTPRUNPC CMD('WORDINSERTTEXT~Sincerely<CRLF>Richard Schoen<CRLF>President') OPTION(*WORDOLE)


Sample MS Word Template Document:

Media:testmemo.exe

Sample CL Program using MS Word

            PGM                                                       
                                                                       
/**********************************************/                       
/* ATTEMPT TO LAUNCH MS WORD */                                        
/**********************************************/                       
             FTPRUNPC   RMTSYS(*CURRENT) CMD('WORDLAUNCH') +           
                          OPTION(*WORDOLE)                             
             MONMSG     MSGID(CPF0000) EXEC(SNDPGMMSG MSGID(CPF9898) + 
                          MSGF(QCPFMSG) MSGDTA('MS Word could not +    
                          be started'))                                
                                                                       
/**********************************************/                       
/* ATTEMPT TO OPEN MS WORD TEMPLATE */                                 
/**********************************************/                       
             FTPRUNPC   CMD('WORDOPENTEMPLATE~C:\TESTMEMO.DOT') +      
                          OPTION(*WORDOLE)                             
                                                                       
             MONMSG     MSGID(CPF0000)                                 
                                                                       
/**********************************************/                       
/* ATTEMPT TO FILL IN TEMPLATE DETAILS        */                       
/* FOR THE SELECTED TEMPLATE BOOKMARKS.       */                       
/**********************************************/                       
             FTPRUNPC   RMTSYS(*CURRENT) +                             
                          CMD('WORDINSERTBOOKMARK~TO_FIELD~Valued +    
                          Customer~FROM_FIELD~RJS +                    
                          Software~CC_FIELD~Nobody +                   
                          Else~RE_FIELD~This is a FTP Remote +         
                          Command Server MS Word Test') +              
                          OPTION(*WORDOLE)                             
             MONMSG     MSGID(CPF0000)                                 
                                                                       
/**********************************************/                       
/* ATTEMPT TO JUMP TO SIGNATURE LINE          */                       
/**********************************************/                       
             FTPRUNPC   RMTSYS(*CURRENT) +                             
                          CMD('WORDINSERTBOOKMARK~SINCERELY_FIELD~ +   
                          ') OPTION(*WORDOLE)                          
             MONMSG     MSGID(CPF0000)                                 
                                                                       
/**********************************************/                       
/* INSERT SIGNATURE TEXT.                     */                       
/**********************************************/                       
             FTPRUNPC   RMTSYS(*CURRENT) +                             
                          CMD('WORDINSERTTEXT~Sincerely<CRLF>Richard + 
                          Schoen<CRLF>President') OPTION(*WORDOLE)     
             MONMSG     MSGID(CPF0000)                                 
                                                                       
             ENDPGM                                                    

Personal tools