610 pts.
 FTP/400
Hi Friends, How can I send a file by FTP/400 using that variables (&RCVNAME and &RCVLIB).  ?



1900 DCL VAR(&MSGDATA) TYPE(*CHAR) LEN(200) 09/03/10

2000 DCL VAR(&RCVNAME) TYPE(*CHAR) LEN(10) 10/03/10

2100 DCL VAR(&RCVLIB) TYPE(*CHAR) LEN(10) 10/03/10

2200 DCL VAR(&MRK) TYPE(*CHAR) LEN(4) 09/03/10

2300 DCL VAR(&MSG) TYPE(*CHAR) LEN(75) 09/03/10

2500 DCL VAR(&SENDER) TYPE(*CHAR) LEN(200) 09/03/10

3900 RCVMSG MSGQ(&MSGLIB/&MSGQ) MSGKEY(&MRK) WAIT(0) + 10/03/10

4000 RMV(*YES) MSGDTA(&MSGDATA) SENDER(&SENDER) 10/03/10

4100 09/03/10

4200 CHGVAR VAR(&RCVNAME) VALUE(%SST(&MSGDATA 21 10)) 10/03/10

4300 CHGVAR VAR(&RCVLIB) VALUE(%SST(&MSGDATA 31 10)) 10/03/10

4400 09/03/10

4500 IF COND(&MSGID = 'CPF7020') THEN(GOTO + 10/03/10

4600 CMDLBL(SAVEFILE)) 10/03/10

4700 10/03/10

4800 SAVEFILE: CRTSAVF FILE(&RCVLIB/&RCVNAME) 10/03/10

4900 10/03/10

5000 SAVOBJ OBJ(&RCVNAME) LIB(&RCVLIB) DEV(*SAVF) + 09/03/10

5100 OBJTYPE(*JRNRCV) SAVF(&RCVLIB/&RCVNAME) 09/03/10

5200 11/03/10

5300 /* ===== TRANSFERENCIA DE SAVE-FILES ===== */ 13/03/10

5400 OVRDBF FILE(INPUT) 13/03/10

5500 OVRDBF FILE(OUTPUT) 13/03/10

5600 FTP RMTSYS('XXX.XXX.XXX.XXX') 13/03/10

[strong]OBS: How can I send this savefile &RCVNAME/&RCVLIB by FTP to another Windows Server ?[/strong]

6800 10/03/10

6900 GOTO CMDLBL(END) 30/11/09

7000 END: ENDPGM 30/11/09

* * * * E N D O F S O U R C E * * * *





Software/Hardware used:
AS/400
ASKED: March 19, 2010  8:16 PM
UPDATED: March 22, 2010  9:51 PM

Answer Wiki:
<pre> Hi Tom... Like example below /*============================================================== */ DLTF FILE(QTEMP/FTPSCRIPT) MONMSG MSGID(CPF0000) CPYF FROMFILE(MYLIB/FTP_SRC1) + TOFILE(QTEMP/FTPSCRIPT) FROMMBR(*FIRST) + CRTFILE(*YES) MONMSG MSGID(CPF0000) /*============================================================== */ Display Physical File Member File . . . . . . : FTP_SRC1 Library . . . . : MYLIB Member . . . . . : FTP02 Record . . . . . : 1 Control . . . . . Column . . . . . : 1 Find . . . . . . . *...+....1....+....2....+....3....+....4....+....5....+....6... AS400 As400Backup cd Journal bin put '&RCVNAME' quit /*============================================================== */ CPYF FROMFILE(QTEMP/FTPSCRIPT) + TOFILE(MYLIB/QFTPSRC) + MBROPT(*ADD) FMTOPT(*CVTSRC) MONMSG MSGID(CPF0000) /*============================================================== */ OVRDBF FILE(INPUT) TOFILE(MYLIB/QFTPSRC) OVRDBF FILE(OUTPUT) TOFILE(MYLIB/QFTPSRC) FTP RMTSYS('XXX.XXX.XXX.XXX') ENDPGM </pre> Multiple possibilities... You could build the FTP script in a user space and copy that to a file member. Or you could build it in a /QDLS document using the HFS APIs and copy that to a file member. Or you could use a tool/command that executes a SQL statement that UPDATEs an existing file member to update the script with your variables (STRQMQRY seems best for you). Or you could do it with a REXX script (I'm assuming you don't want to, or can't, use RPG or other HLL). Or you could use STRQSH to update the script. However, you really shouldn't do it at all in this program. You should either do something like send the values to a data queue and let a data queue monitor program do the work or perhaps just SBMJOB to have another job do the work. You be shouldn't be doing actions like saves and FTP in a break-handling program. This program should receive the message, pass the values to some other job and return. It should do as little work as possible. Kick off some other job to do the work so this program can release the message queue as quickly as possible. Tom
Last Wiki Answer Submitted:  March 19, 2010  10:16 pm  by  TomLiotta   108,300 pts.
All Answer Wiki Contributors:  TomLiotta   108,300 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

Using example names, a possible QM source member might look like:

UPDATE MYLIB/FTP_SRC1
   SET SRCDTA = 'PUT '   CONCAT
                &RCVNAME
 WHERE SRCDTA LIKE 'PUT %'

A CL program could then run STRQMQRY and pass a value in for the RCVNAME replacement variable. Since the replacement variable needs to be a literal in the SQL statement (and therefore enclosed in quotes, the quotes may be added by the CLP to the value that is passed in. I prefer a different method, though. I prefer passing a simple quote mark in as a replacement value by itself, and inserting that wherever needed in the SQL:

UPDATE MYLIB/FTP_SRC1
   SET SRCDTA = 'PUT '   CONCAT
                &q&RCVNAME&q
 WHERE SRCDTA LIKE 'PUT %'

My STRQMQRY command can then simply have SETVAR((q ””) … ) as one of its parameters. QM will place the quote wherever &q appears in the SQL. (Note that replacement variable names are case-sensitive.

In your example, you show that &RCVNAME has quotes in the FTP script itself. That would take a couple practice runs to see how many times &q would have to be specified in the QM SQL source member, but it would still only have to be specified once on the STRQMQRY command.

Finally, again — this is not processing that should be done in the break-handler. This work should be handed off to a different job.

Tom

 108,300 pts.

 
Sorry about me.

I don´t know exactly where I´m wrong.

I have a savefile named (savefile1/lib1) and (savefile2/lib2) and etc....

Im trying put this savefiles named (&rcvname/&rcvlib) to this windows server ip xxx.xxx.xxx.xxx

QMQRY(MYLIB/FTP400) 
0001.00 UPDATE MYLIB/FTP_SRC1                  
0002.00 SET CAMPO1 = 'put' CONCAT
0003.00               &RCVNAME      
0004.00 WHERE CAMPO1 LIKE 'put %'               


8 > STRQMQRY QMQRY(MYLIB/FTP400)                       
    Entry for local relational database already exists. 
   Type a value for variable "RCVNAME" and press Enter. 
 ? corprc1219                                           
   Column SRCDTA not in specified tables.               
   RUN QUERY command failed with SQLCODE -206.          
   RUN QUERY command ended due to error.                
   STRQMQRY command failed.  

runqry *n mylib/ftp_src1   

Position to line  . . . . .                                                                  Shift 
Line   ....+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8....+....9  
       CAMPO1      CAMPO2  CAMPO3                CAMPO4  CAMPO5                CAMPO6  CAMPO7      
000001 AS400                                                                             
000002 cd                                                                                
000003 mdelete                                                                          
000004 rmdir                                                                            
000005 mkdir                                                                             
000006 cd                                                                                
000007 bin                                                                               
000008 put                 &RCVNAME                                                                
000009 quit
 610 pts.

 

The INPUT and OUTPUT files for batch FTP need to be either source physical files or program-described physical files with a single field. It looks like your INPUT file is an externally-described file with multiple fields, e.g., CAMPO1, CAMPO2, CAMPO3, etc.

That’s why my example UPDATE statement was updating a field named SRCDTA — it’s a source file. (I didn’t see a clear statement in IBM documentation, but it works with both source and program-described/single-field files, and all IBM examples use source files.)

Before going any farther, try it with INPUT and OUTPUT files that the FTP client can read. The FTP client is expecting input/output from and to a simple terminal, not a database file with multiple fields.

Tom

 108,300 pts.