Tip

Dynamically change batch FTP script

At my clients place, we FTP an e-mail file to a third-party vendor daily; this happens as a batch process. The vendor wants the file to be suffixed with the current date, so they can standardize the input. But, batch FTP needs the script in a PF member. To change the file name in the FTP input script (PF/Member), we used a FREEWARE-SQLSTM to update the statement in the script with the current date.

This below method can be used for changing the script dynamically -- if you are already using the batch FTP process.

CUSTLIB/INPUT - FTP INPUT file (File with SCRIPT)
CUSTLIB/EMAILPF -- E-mail file, that needs to be sent via FTP to the Client
Flmmddyy.txt - Filename on the Client side
SQLSTM - SQL command that runs in the CL. (There are several utilities which offer a way to execute SQL via a standard command interface)


 
0146.00 /* SET THE OUT FILE ON CLIENT SIDE AS "FLmmddyy.txt" */             
0147.00            RTVJOBA    DATE(&DATE)

0148.00            CHGVAR   &VAR1 (&DATE *CAT '.TXT')

0149.00            CHGVAR     VAR(&STMT) VALUE('UPDATE CUSTLIB/INPUT + 
0150.00                         SET FTPINPUT = ''PUT CUSTLIB/EMAILPF +

0151.00                           FL' *CAT &VAR1 *TCAT ''' +           
0152.00                        WHERE SUBSTR(FTPINPUT,1,3) = ''PUT''  ')     
0153.00

0154.00              SQLSTM     CMD(&STMT)

0155.00

 


FTP INPUT File (Script for FTP)

Display Physical File Member  CUSTLIB/INPUT
FTPINPUT is the only field with 80 chars.
                        
 File . . . . . . :   INPUT              Library  . . . . :   SONOMA

 Member . . . . . :   INPUT              Record . . . . . :   1

 Control  . . . . .                       Column . . . . . :   1

 Find . . . . . . .

*...+....1....+....2....+....3....+....4....+....5....+....6....+....7.
userid password

SENDPASV 0

PUT INPUT/CUSTLIB Flmmddyy.TXT                                       
QUIT

                           ****** END OF DATA ******

 

Note: Search the Search400.com tips section on how to FTP from iSeries. Interactively, batch, etc.

==================================
MORE INFORMATION ON THIS TOPIC
==================================

The Best Web Links: tips, tutorials and more.

Ask your programming questions--or help out your peers by answering them--in our live discussion forums.

Ask the Experts yourself: Our application development gurus are waiting to answer your programming questions.

This was first published in March 2004

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.