Jrnrcv to a Savefile and FTP Server

540 pts.
Tags:
AS/400 Transfer
FTP Server
JRNRCVR
V5R3
Hi friends, I have a Iseries version V5R3 and I have a question about Jrnrcv. How can I save a JrnRCV to a Savefile (after generated this JrnRcv) and send this savefile to a FTP Windoes server ?
ASKED: July 29, 2010  4:37 PM
UPDATED: August 11, 2010  6:32 PM

Answer Wiki

Thanks. We'll let you know when a new response is added.

The SAVOBJ command will allow you to save you JRNRCV to a *SAVF.
You can then use FTP to PUT that file on an FTP Server

Discuss This Question: 17  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

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
  • RBDSILVA
    Thanks, how do I automate this in a CL/400 ? Att; Rbdsilva
    540 pointsBadges:
    report
  • CharlieBrowne
    You would create a CL program that would CRTSAVF SAVOBJ setup FTP Run FTP === To do the setup and run FTP would would have two source members. One for the FTP instructions and the other for the output log of the FTP porcess. Here is a link with examples for you. http://itknowledgeexchange.techtarget.com/itanswers/as400-ftp-batch-program/ If you search for AS400 BATCH FTP, you will find other examples.
    39,780 pointsBadges:
    report
  • TomLiotta
    For details on how CL programs interact with FTP, see the Running File Transfer Protocol in unattended mode using a batch job in the Information Center. If you FTP a savefile, it can useful to use .SAVF as the file extension on the remote system. Your AS/400 can help with some of the details when it recognizes that extension. Also, be sure to do the FTP transfer in BINARY mode to avoid character translation of the savefile data. Tom
    125,585 pointsBadges:
    report
  • RBDSILVA
    Ok friends, I have now this CL. /* ===== ===== */ RCVMSG MSGQ(&MSGLIB/&MSGQ) MSGKEY(&MRK) WAIT(0) + RMV(*YES) MSGDTA(&MSGDATA) SENDER(&SENDER) CHGVAR VAR(&RCVNAME) VALUE(%SST(&MSGDATA 21 10)) CHGVAR VAR(&RCVLIB) VALUE(%SST(&MSGDATA 31 10)) IF COND(&MSGID = 'CPF7020') THEN(GOTO + CMDLBL(SAVEFILE)) SAVEFILE: CRTSAVF FILE(&RCVLIB/&RCVNAME) SAVOBJ OBJ(&RCVNAME) LIB(&RCVLIB) DEV(*SAVF) + OBJTYPE(*JRNRCV) SAVF(&RCVLIB/&RCVNAME) How can I send this savefile FILE(&RCVLIB/&RCVNAME) to Windows FTP Server ? Thanks, RBDSILVA
    540 pointsBadges:
    report
  • TomLiotta
    How can I send this savefile FILE(&RCVLIB/&RCVNAME) to Windows FTP Server ? Your first step is to send (PUT) one of the savefiles manually and then receive (GET) it back again. You need to know which FTP subcommands must be included in a FTP script before you can create the script. You need to both send and receive so that you can verify that you get a valid savefile back. Sending it won't do you any good if it arrives in an incorrect format. If it's wrong when it arrives at the remote system, it won't be any good to anybody. When you know the correct series of FTP subcommands, type them into a simple source member. You can then run a simple interactive test. For example, assume that you typed your FTP subcommands into a source member named FTPIN in a source file named FTPSCRIPTS in library MYLIB, you could test from a command line:
    OVRDBF FILE(INPUT) TOFILE( MYLIB/FTPSCRIPTS ) MBR( FTPIN )
    FTP RMTSYS(windowsftpservername)
    DLTOVR FILE(INPUT)
    The FTP session should start and execute the subcommands from your script. You should see the session activity on your screen just as always except that it won't stop and ask you to type your commands. If the script isn't quite right, then update it and try again until it is. (When it works to send and receive without corruption, you can stop using the GET subcommand.) Once it works correctly, create another source member. Maybe give it a name like FTPOUT. Then run another test like:
    OVRDBF FILE(INPUT) TOFILE( MYLIB/FTPSCRIPTS ) MBR( FTPIN )
    OVRDBF FILE(OUTPUT) TOFILE( MYLIB/FTPSCRIPTS ) MBR( FTPOUT )
    FTP RMTSYS(windowsftpservername)
    DLTOVR FILE(INPUT)
    DLTOVR FILE(OUTPUT)
    This time, you shouldn't see anything on the screen. After the FTP command finishes and after you delete the two overrides, look at the FTPOUT source member. You should find that it contains what used to display on your screen. The INPUT override caused FTP to read its instructions from the FTPIN member instead of from your keyboard. The OUTPUT override told FTP to write its log messages to FTPOUT instead of to your screen. Those CL commands will essentially be copy/pasted into your CL program. There are only a couple of problems. You don't really want to have a script file that has a userid and password in it. And you need to change the name of your savefile in the script every time you use it. One possible solution is to have a template script that you copy into FTPIN and some QM queries that can UPDATE different rows in the template. You can modify the script on the fly by passing in replacement values with STRQMQRY commands. Or you might use any programming to update the FTPIN member. Whatever CL commands you use, those will be added to your CL program before the first OVRDBF. That's a basic discussion of steps you might go through to create your CL FTP programming. I don't know exactly what FTP subcommands you will need to use. I don't know what will be accepted by your FTP server. And I don't know what methods you might use to modify your script for each time you run it; there are many possible methods with different uses. Tom
    125,585 pointsBadges:
    report
  • RBDSILVA
    Thanks Tom When I use: IF COND(&MSGID = ‘CPF7020′) THEN(GOTO + CMDLBL(SAVEFILE)) SAVEFILE: CRTSAVF FILE(SAVFLIB/&RCVNAME) SAVOBJ OBJ(&RCVNAME) LIB(&RCVLIB) DEV(*SAVF) + Objtype (*JRNRCV) SAVF(SAVFLIB/&RCVNAME) I do not know the exact file name and library of this file generated, so as to indicate a file name that QMQRY not know this, since in FTP/400 not have the option GET (&SAVFNAME) LIB(SAVFLIB)
    540 pointsBadges:
    report
  • RBDSILVA
    I Have another example: Regarding how to transfer Libraries or Save Files using FTP, Ibrahim Shareef, from Saudi Arabia wrote: How can I FTP the contents of an entire library from one AS/400 to another AS/400?Response: Transferring AS/400 Objects or complete libraries with FTP can be done with the help of Save File (files of type *SAVF)A SAVF type file is a physical file with records 528 characters long. Here is how to transfer the contents of a SAVF from one AS/400 to an other: - Create a Save File (CRTSAVF) on the source machine - Save objects in the SAVF - Create a Save file (CRTSAVF) on the target machine - FTP to Remote AS/400 mode BINARY PUT FROMLIB/SAVEFILE TOLIB/SAVEFILE - For Automated Procedures (the SAVF does not have to be on the target AS/400: mode BINARY put /qsys.lib/catda7.lib/fromsavf.savf /qsys.lib/catda7.lib/tosavf.savf (I Know the lib name but not the savefile retrivied on CL)
    540 pointsBadges:
    report
  • TomLiotta
    I do not know the exact file name and library of this file generated, so as to indicate a file name that QMQRY not know this... You don't need to know the name. You only need the variables for the name and library -- &RCVLIB and &RCVNAME. Those variables are passed into the QM query through the STRQMQRY SETVAR() parameter. You would have a query that does an UPDATE of the record in the script that does the PUT. The UPDATE would change the record to include the savefile name from the variable. You have a line in your script that looks like maybe this:
    PUT xxx
    You have the variables in your CL program. You use the variables to create a string that will look like maybe this:
    PUT /qys.lib/MYLIB.lib/MYSAVEFILE.file somedirsomefile.SAVF
    You do that by a CL statement like maybe this:
    CHGVAR  &put  ('/qsys.lib/' *cat &RCVLIB *tcat '.lib/' *cat &RCVNAME *tcat '.file '  +
                   *cat &TOFILE )
    The value in &TOFILE will be whatever file you want to put your savefile in on the FTP server. You have to supply that name somewhere. I don't know what name you'll use. Now that you have the FTP PUT statement in a variable in your CL program:
    STRQMQRY QMQRY(MYQMQRY)
             SETVAR((PUT &PUT))
    And your QM query will be:
    UPDATE MYLIB/FTPSCRIPTS            
       SET SRCDTA = &PUT   
     WHERE SRCDTA LIKE'PUT xxx'
    Note that the MYLIB/FTPSCRIPTS file will also need to be overridden to the FTPIN member for this as well as for the FTP command later in your program. But the UPDATE will locate the PUT and replace it with whatever you build in your CL program. The WHERE clause needs to search for whatever special value you have in your script. Make sense? Tom
    125,585 pointsBadges:
    report
  • TomLiotta
    Correction: Because the QM query will be working with the SRCDTA column, the &PUT value will need to enclosed in quotes. One of the easiest way of doing that is like:
    SET SRCDTA = &Q&PUT&Q
    The STRQMQRY command in your CL program can then be like:
    STRQMQRY QMQRY(MYQMQRY)
             SETVAR((PUT &PUT) (Q ''''))
    The &Q replacement variable is passed in with a single-quote as its value. The QM query then inserts a single-quote before and after the &PUT value in the UPDATE statement. Tom
    125,585 pointsBadges:
    report
  • TomLiotta
    Correction to the correction: This editor didn't like me putting four single-quote marks in a row after the Q replacement variable. It resulted in two double-quote marks in my example. The SETVAR() parm should have Q being assigned with four single-quotes. Tom
    125,585 pointsBadges:
    report
  • RBDSILVA
    OK, Tthanks again.
    
    where I'm wrong ?
    
     Program . . . . . . . . . . . . . . . . . . . :   JRN_GET
       Library . . . . . . . . . . . . . . . . . . :     MYLIB
     Source file . . . . . . . . . . . . . . . . . :   QCLSRC
       Library . . . . . . . . . . . . . . . . . . :     MYLIB
     SEQNBR  *...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... 8 ...+... 9 ...+.  
        100-              PGM        PARM(&MSGQ &MSGLIB &MRK)
        200-  /* PARAMETERS TO BE USED ON FTP */
        300-              DCL        VAR(&DAYOFWEEK) TYPE(*CHAR) LEN(04)
        400-              DCL        VAR(&DAY) TYPE(*CHAR) LEN(2) 
        500-              DCL        VAR(&HOR) TYPE(*CHAR) LEN(2)
        600-              DCL        VAR(&MIN) TYPE(*CHAR) LEN(2)
        700-              DCL        VAR(&SEG) TYPE(*CHAR) LEN(2)
        800-              DCL        VAR(&APOST)     TYPE(*CHAR) LEN(01) VALUE('''')
        900-              DCL        VAR(&DIASEMANA) TYPE(*CHAR) LEN(10)
       1000-              DCL        VAR(&REMOVER)   TYPE(*CHAR) LEN(10)
       1100-              DCL        VAR(&REMOVER1)  TYPE(*CHAR) LEN(11)
       1200-              DCL        VAR(&IN)  TYPE(*CHAR) LEN(10)
       1300-              DCL        VAR(&OU)  TYPE(*CHAR) LEN(10)
       1400-              DCL        VAR(&tofile) TYPE(*CHAR) LEN(10)
       1500-              dcl        var(&put) type(*char) len(200)
       1600-
       1700-  /* PARAMETERS TO BE USED ON SAVEFILE */
       1800-              DCL        VAR(&MSGLIB) TYPE(*CHAR) LEN(10)
       1900-              DCL        VAR(&MSGq) TYPE(*CHAR) LEN(10)
       2000-              DCL        VAR(&MSGID) TYPE(*CHAR) LEN(7)
       2100-              DCL        VAR(&MSGDATA) TYPE(*CHAR) LEN(200)
       2200-                          DCL        VAR(&RCVNAME) TYPE(*CHAR) LEN(10)
       2300-                          DCL        VAR(&RCVLIB) TYPE(*CHAR) LEN(10)
       2400-              DCL        VAR(&MRK) TYPE(*CHAR) LEN(4)
       2500-              DCL        VAR(&MSG) TYPE(*CHAR) LEN(75)
       2600-              DCL        VAR(&MSGX) TYPE(*CHAR) LEN(5000)
       2700-              DCL        VAR(&SENDER) TYPE(*CHAR) LEN(200)
       2800-
       2900-  /*  ===== RETRIVING SYSTEM VALUES =====  */
       3000-                  RTVSYSVAL  SYSVAL(QDAYOFWEEK) RTNVAR(&DAYOFWEEK)
       3100-                  RTVSYSVAL  SYSVAL(QDAY)       RTNVAR(&DAY)
       3200-                  RTVSYSVAL  SYSVAL(QHOUR)      RTNVAR(&HOR)
       3300-                  RTVSYSVAL  SYSVAL(QMINUTE)    RTNVAR(&MIN)
       3400-                  RTVSYSVAL  SYSVAL(QSECOND)    RTNVAR(&SEG)
       3500-
       3600-  /*  ===== CHANGING VARIABLES TO BE USED ON FTP     =====  */
       3700-              CHGVAR     VAR(&IN) VALUE('IN' *CAT &DAY *CAT &HOR *CAT +
       3800                            &MIN *CAT &SEG) 
       3900-              CHGVAR     VAR(&OU) VALUE('OU' *CAT &DAY *CAT &HOR *CAT + 
       4000                            &MIN *CAT &SEG)
       4100-
       4200-   CHGVAR  &put ('/qsys.lib/' *cat &RCVLIB *tcat '.lib/' *cat &RCVNAME *tcat +
       4300    '.file '  *cat &TOFILE)
       4400-
       4500-   /*  =====  REMOVE FILES ON LIB QTEMP  =====  */
       4600-              DLTF       FILE(QTEMP/FTPSCRIPT)
       4700-              MONMSG     MSGID(CPF0000)
       4800-              CPYF       FROMFILE(MYLIB/FTP_SRC1) +
       4900                            TOFILE(QTEMP/FTPSCRIPT) CRTFILE(*YES)
       5000-              MONMSG     MSGID(CPF0000)
       5100-
       5200-              STRQMQRY   QMQRY(MYQMQRY) SETVAR((PUT) (&PUT) (Q '""'))
       5300-
       5400-     /*  =====                                                   =====  */
       5500-              RCVMSG     MSGQ(&MSGLIB/&MSGQ) MSGKEY(&MRK) WAIT(0) +
       5600                            RMV(*YES) MSGDTA(&MSGDATA) SENDER(&SENDER)
       5700-
       5800-              CHGVAR     VAR(&RCVNAME) VALUE(%SST(&MSGDATA 21 10))
       5900-              CHGVAR     VAR(&RCVLIB) VALUE(%SST(&MSGDATA 31 10))
       6000-
       6100-              IF         COND(&MSGID = 'CPF7020') THEN(GOTO +
       6200                            CMDLBL(SAVEFILE))
       6300-
       6400-   SAVEFILE:  CRTSAVF    FILE(&RCVLIB/&RCVNAME)
       6500-
       6600-              SAVOBJ     OBJ(&RCVNAME) LIB(&RCVLIB) DEV(*SAVF) +
       6700                            OBJTYPE(*JRNRCV) SAVF(&RCVLIB/&RCVNAME)
       6800-
       6900-  /*  ===== COPY SCRIPT TO BE USED ON FTP   =====  */
       7000-              CPYF       FROMFILE(QTEMP/FTPSCRIPT) +
       7100                            TOFILE(MYLIB/ftp_src1) TOMBR(&IN) +
       7200                            MBROPT(*ADD) FMTOPT(*CVTSRC)
       7300-             MONMSG     MSGID(CPF0000)
       7400-
       7500-  /*  ===== TRANSFER SAVE FILES    =====  */
       7600-              OVRDBF     FILE(INPUT) TOFILE(MYLIB/FTP_SRC1) MBR(&IN)
       7700-              OVRDBF     FILE(OUTPUT) TOFILE(MYLIB/FTP_SRC1) MBR(&OU)
       7800-              FTP        RMTSYS('XXX.XX.1.28')
       7900-
       8000-              GOTO       CMDLBL(END)
       8100-  END:        ENDPGM
    
    
    ==========> JOB LOG
    
    
       File CORPRC1333 created in library CORPDTA.                      
       1 objects saved from library CORPDTA.                            
       FMTOPT(*CVTSRC) not allowed for specified files.                 
       Copy command ended because of error.                             
       File FTP_SRC1 in library MYLIB with member IN02235230 not found. 
       Object FTPSCRIPT in QTEMP type *FILE deleted.                    
       Physical file FTPSCRIPT created in library QTEMP.                
       Member FTP_SRC1 added to file FTPSCRIPT in QTEMP.                	
       8 records copied from member INPUT.                              
       /qsys.lib/.lib/.file is not a valid Query Management variable.   
       Error found on STRQMQRY command.                                 
       Function check. CPF0001 unmonitored by JRN_GET at statement 5200,
         instruction X'0070'.                                           
       CPF0001 received by JRN_GET at 5200. (C D I R)   
    540 pointsBadges:
    report
  • RBDSILVA
    Opsss,
    where I'm wrong ?
    
    ==========> COMMAND
    
      SOURCE FILE . . . . . . .  MYLIB/QCLSRC
      MEMBER  . . . . . . . . .  JRN_MAIL
      SEQNBR*...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... 8 ...+... 9 ...+... 0
        100              PGM
        200              CHGMSGQ    MSGQ(QSYS/CHK_JRN) DLVRY(*BREAK) +
        300              PGM(MYLIB/JRN_GET *ALWRPY)
        400  LOOP:       DLYJOB     DLY(60)
        500              GOTO       CMDLBL(LOOP)
        600              ENDPGM      
    
    ==========> QMQRY
      
    
      SOURCE FILE . . . . . . .  MYLIB/QCLSRC
      MEMBER  . . . . . . . . .  MYQMQRY
      SEQNBR*...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... 8 ...+... 9 ...+... 0
        100 UPDATE MYLIB/FTP_SRC1
        200 SET SRCDTA = '& Q & Q & PUT'
        300 WHERE SRCDTA = 'PUT XXX'
                                      
    
    ==========> CL
    
    
     Program . . . . . . . . . . . . . . . . . . . :   JRN_GET
       Library . . . . . . . . . . . . . . . . . . :     MYLIB
     Source file . . . . . . . . . . . . . . . . . :   QCLSRC
       Library . . . . . . . . . . . . . . . . . . :     MYLIB
     SEQNBR  *...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... 8 ...+... 9 ...+.  
        100-              PGM        PARM(&MSGQ &MSGLIB &MRK)
        200-  /* PARAMETERS TO BE USED ON FTP */
        300-              DCL        VAR(&DAYOFWEEK) TYPE(*CHAR) LEN(04)
        400-              DCL        VAR(&DAY) TYPE(*CHAR) LEN(2) 
        500-              DCL        VAR(&HOR) TYPE(*CHAR) LEN(2)
        600-              DCL        VAR(&MIN) TYPE(*CHAR) LEN(2)
        700-              DCL        VAR(&SEG) TYPE(*CHAR) LEN(2)
        800-              DCL        VAR(&APOST)     TYPE(*CHAR) LEN(01) VALUE('''')
        900-              DCL        VAR(&DIASEMANA) TYPE(*CHAR) LEN(10)
       1000-              DCL        VAR(&REMOVER)   TYPE(*CHAR) LEN(10)
       1100-              DCL        VAR(&REMOVER1)  TYPE(*CHAR) LEN(11)
       1200-              DCL        VAR(&IN)  TYPE(*CHAR) LEN(10)
       1300-              DCL        VAR(&OU)  TYPE(*CHAR) LEN(10)
       1400-              DCL        VAR(&tofile) TYPE(*CHAR) LEN(10)
       1500-              dcl        var(&put) type(*char) len(200)
       1600-
       1700-  /* PARAMETERS TO BE USED ON SAVEFILE */
       1800-              DCL        VAR(&MSGLIB) TYPE(*CHAR) LEN(10)
       1900-              DCL        VAR(&MSGq) TYPE(*CHAR) LEN(10)
       2000-              DCL        VAR(&MSGID) TYPE(*CHAR) LEN(7)
       2100-              DCL        VAR(&MSGDATA) TYPE(*CHAR) LEN(200)
       2200-                          DCL        VAR(&RCVNAME) TYPE(*CHAR) LEN(10)
       2300-                          DCL        VAR(&RCVLIB) TYPE(*CHAR) LEN(10)
       2400-              DCL        VAR(&MRK) TYPE(*CHAR) LEN(4)
       2500-              DCL        VAR(&MSG) TYPE(*CHAR) LEN(75)
       2600-              DCL        VAR(&MSGX) TYPE(*CHAR) LEN(5000)
       2700-              DCL        VAR(&SENDER) TYPE(*CHAR) LEN(200)
       2800-
       2900-  /*  ===== RETRIVING SYSTEM VALUES =====  */
       3000-                  RTVSYSVAL  SYSVAL(QDAYOFWEEK) RTNVAR(&DAYOFWEEK)
       3100-                  RTVSYSVAL  SYSVAL(QDAY)       RTNVAR(&DAY)
       3200-                  RTVSYSVAL  SYSVAL(QHOUR)      RTNVAR(&HOR)
       3300-                  RTVSYSVAL  SYSVAL(QMINUTE)    RTNVAR(&MIN)
       3400-                  RTVSYSVAL  SYSVAL(QSECOND)    RTNVAR(&SEG)
       3500-
       3600-  /*  ===== CHANGING VARIABLES TO BE USED ON FTP     =====  */
       3700-              CHGVAR     VAR(&IN) VALUE('IN' *CAT &DAY *CAT &HOR *CAT +
       3800                            &MIN *CAT &SEG) 
       3900-              CHGVAR     VAR(&OU) VALUE('OU' *CAT &DAY *CAT &HOR *CAT + 
       4000                            &MIN *CAT &SEG)
       4100-
       4200-   CHGVAR  &put ('/qsys.lib/' *cat &RCVLIB *tcat '.lib/' *cat &RCVNAME *tcat +
       4300    '.file '  *cat &TOFILE)
       4400-
       4500-   /*  =====  REMOVE FILES ON LIB QTEMP  =====  */
       4600-              DLTF       FILE(QTEMP/FTPSCRIPT)
       4700-              MONMSG     MSGID(CPF0000)
       4800-              CPYF       FROMFILE(MYLIB/FTP_SRC1) +
       4900                            TOFILE(QTEMP/FTPSCRIPT) CRTFILE(*YES)
       5000-              MONMSG     MSGID(CPF0000)
       5100-
       5200-              STRQMQRY   QMQRY(MYQMQRY) SETVAR((PUT) (&PUT) (Q '""'))
       5300-
       5400-     /*  =====                                                   =====  */
       5500-              RCVMSG     MSGQ(&MSGLIB/&MSGQ) MSGKEY(&MRK) WAIT(0) +
       5600                            RMV(*YES) MSGDTA(&MSGDATA) SENDER(&SENDER)
       5700-
       5800-              CHGVAR     VAR(&RCVNAME) VALUE(%SST(&MSGDATA 21 10))
       5900-              CHGVAR     VAR(&RCVLIB) VALUE(%SST(&MSGDATA 31 10))
       6000-
       6100-              IF         COND(&MSGID = 'CPF7020') THEN(GOTO +
       6200                            CMDLBL(SAVEFILE))
       6300-
       6400-   SAVEFILE:  CRTSAVF    FILE(&RCVLIB/&RCVNAME)
       6500-
       6600-              SAVOBJ     OBJ(&RCVNAME) LIB(&RCVLIB) DEV(*SAVF) +
       6700                            OBJTYPE(*JRNRCV) SAVF(&RCVLIB/&RCVNAME)
       6800-
       6900-  /*  ===== COPY SCRIPT TO BE USED ON FTP   =====  */
       7000-              CPYF       FROMFILE(QTEMP/FTPSCRIPT) +
       7100                            TOFILE(MYLIB/ftp_src1) TOMBR(&IN) +
       7200                            MBROPT(*ADD) FMTOPT(*CVTSRC)
       7300-             MONMSG     MSGID(CPF0000)
       7400-
       7500-  /*  ===== TRANSFER SAVE FILES    =====  */
       7600-              OVRDBF     FILE(INPUT) TOFILE(MYLIB/FTP_SRC1) MBR(&IN)
       7700-              OVRDBF     FILE(OUTPUT) TOFILE(MYLIB/FTP_SRC1) MBR(&OU)
       7800-              FTP        RMTSYS('XXX.XX.1.28')
       7900-
       8000-              GOTO       CMDLBL(END)
       8100-  END:        ENDPGM
    
    
    ==========> JOB LOG
    
    
       File CORPRC1333 created in library CORPDTA.                      
       1 objects saved from library CORPDTA.                            
       FMTOPT(*CVTSRC) not allowed for specified files.                 
       Copy command ended because of error.                             
       File FTP_SRC1 in library MYLIB with member IN02235230 not found. 
       Object FTPSCRIPT in QTEMP type *FILE deleted.                    
       Physical file FTPSCRIPT created in library QTEMP.                
       Member FTP_SRC1 added to file FTPSCRIPT in QTEMP.                	
       8 records copied from member INPUT.                              
       /qsys.lib/.lib/.file is not a valid Query Management variable.   
       Error found on STRQMQRY command.                                 
       Function check. CPF0001 unmonitored by JRN_GET at statement 5200,
         instruction X'0070'.                                           
       CPF0001 received by JRN_GET at 5200. (C D I R)                   
    
    540 pointsBadges:
    report
  • TomLiotta
    First, you have a message queue named QSYS/CHK_JRN referenced at line 200 of JRN_MAIL. There's nothing actually wrong with that, but you shouldn't be creating things in library QSYS. If that's a device message queue or the system created it itself, then it's reasonable for it to be in QSYS. Otherwise, create your message queues in your own libraries or in QUSRSYS or QGPL. Next, you might get rid of variables &HOR, &MIN and &SEG. Just use one variable -- &TIME *CHAR LEN(6). Use RTVSYSVAL QTIME to get a time variable. Replace three variables with one to help make your program smaller. You have a variable named &APOST that appears intended to hold an apostrophe. I can't tell if it has two double-quotes or if this editor converted your four single-quotes to two double-quotes. It looks like different characters than the ones that were inserted into my message above. Make sure that you have four single-quotes in your program. But you don't actually use &APOST in your program, so you might as well delete it. You have created a variable named &tofile, but you haven't put a value in to it. That would be used for the name of the file on the remote FTP server. You might not need to put any value in it since you probably don't want to change the name of the savefile. You also have defined as LEN(10). That's probably way too short, but it won't matter if you're going to leave it blank anyway. In your QM query, you are updating MYLIB/FTP_SRC1. But in your CL, you copy it to QTEMP/FTPSCRIPT. Then you copy QTEMP/FTPSCRIPT back over the top of MYLIB/FTP_SRC1 which erases the update. You should change your QM query to update QTEMP/FTPSCRIPT, delete the CPYF at line 7000 and change your OVRDBF commands to reference QTEMP/FTPSCRIPT. The only reason to have MYLIB/FTP_SRC1 would be to keep a model of the script. You never want to change it and you never want to use it except to start the work in QTEMP. In your STRQMQRY command at line 5200, you have (Q ‘”"‘). You need to change those two double-quotes to single-quotes. You run RCVMSG at line 5500, but you don't test to see what message was received. If you don't test the message identifier, you won't even know if an actual message was received. If the message identifier is all blank, then you should probably run RETURN. And at the end of the program, you simply end. You don't loop back to see if any other messages are there. If you aren't going to loop, then you should make sure that the message queue is empty before you run CHGMSGQ in JRN_MAIL. In your QM query, you have:
    SET SRCDTA = ‘& Q & Q & PUT’
    ...where my example has:
    SET SRCDTA = &Q&PUT&Q
    You need to remove the single-quote marks, remove any spaces from the replacement variable names and put the replacement variables in the correct order. Since you have the replacement variables inside quotes, QM doesn't recognize them. The purpose of the &Q replacement variable is to supply the quotes automatically. You have variable &put declared as len(200). Unfortunately, QM replacement variables can only have a maximum length of 55 characters. And you shouldn't have your replacement variable longer than the length of the SRCDTA field that you are updating. If you ever need more than 55 characters, you'll need to have multiple replacement variables like &PUT1 and &PUT2. You could use the %SST() function to break the larger variable into parts. At line 4200, you have a CHGVAR that uses variables &RCVLIB and &RCVNAME. But you don't put values into those variables until line 5800. You need to move the CHGVAR down to line 6000 at least. At line 5200, you have the STRQMQRY. But you can't run that command until after the CHGVAR, so you have to move it down to after 6000. At line 6100, you test variable &MSGID. But you never put a value in to it. You need to retrieve the &MSGID with your RCVMSG command. Other than those things, it's not too bad. There might be a number of other problems that I didn't see. I did see some others, but they might just be the way the editor works. The CL compiler will tell you about syntax errors, so I can ignore them. It looks like you are going to have an IP address in your FTP command. First, you shouldn't use an IP address; you should use a host name. If the IP address isn't in your DNS, then put an entry in your system's hosts table. That way you won't have to change your program and recompile if the address changes; just change the hosts table entry. Further, if you must use an IP address, it should not be put in the RMTSYS() parameter. There is a special value -- *INTNETADR -- that you should use when you only have an address. IP addresses belong in the INTNETADR() parameter. Addresses almost always work in place of a host name, but sooner or later you'll hit a condition where it won't work as expected. And you will save perhaps days of troubleshooting trying to figure out what's wrong, if you ever manage to track it down at all. (It can be extremely tricky.) All similar commands work the same way -- don't put addresses where you should be putting names. It's hard to tell what will happen after you make a bunch of changes. See how far you get and let us know where you end up. Tom
    125,585 pointsBadges:
    report
  • RBDSILVA
    Hi Tom, now I have another example about my problem.
    Below You can see the Joblog, CL/400, QmQryfile, Inputfile and OutputFile from OVERDBF.
    
    ----------> CL/400	MYLIB/JRN_GET
                 PGM        PARM(&JRNFILE &JRNLIB &SAVEFILE &SAVELIB)
     /* PARAMETERS TO BE USED ON FTP */
                 DCL        VAR(&DAY) TYPE(*CHAR) LEN(2)
                 DCL        VAR(&TIME) TYPE(*CHAR) LEN(6)
                 DCL        VAR(&IN)  TYPE(*CHAR) LEN(10)
                 DCL        VAR(&OU)  TYPE(*CHAR) LEN(10)
                 DCL        VAR(&PUT) TYPE(*CHAR) len(30)
                 DCL        VAR(&JRNFILE) TYPE(*CHAR) LEN(10)
                 DCL        VAR(&JRNLIB) TYPE(*CHAR) len(10)
                 DCL        VAR(&SAVEFILE) TYPE(*CHAR) LEN(10)
                 DCL        VAR(&SAVELIB) TYPE(*CHAR) len(10)
    
     /*  ===== RETRIVING SYSTEM VALUES =====  */
                     RTVSYSVAL  SYSVAL(QDAY)       RTNVAR(&DAY)		->06
                     RTVSYSVAL  SYSVAL(QTIME)      RTNVAR(&TIME)	->231542
    
     /*  ===== CHANGING VARIABLES TO BE USED ON FTP     =====  */
                 CHGVAR     VAR(&IN) VALUE('IN' *CAT &DAY *CAT &TIME)	->IN06231542
                 CHGVAR     VAR(&OU) VALUE('OU' *CAT &DAY *CAT &TIME)	->OU06231542
    
     /*  =====  REMOVE FILES ON LIB QTEMP  =====  */
                 CLRPFM     FILE(QTEMP/FTPSCRIPT)
                 CPYF       FROMFILE(MYLIB/FTP_SRC1) +
                              TOFILE(QTEMP/FTPSCRIPT) FROMMBR(*FIRST) +
                              MBROPT(*ADD) CRTFILE(*YES)
                 MONMSG     MSGID(CPF0000)
    
     SAVEFILE:   CLRSAVF    FILE(&SAVELIB/&SAVEFILE)
                 MONMSG     MSGID(CPF5813 CPF7302)
    
                 SAVOBJ     OBJ(&JRNFILE) LIB(&JRNLIB) DEV(*SAVF) +		->'CORPDTA/CORPRC1361.SAVF       ' 
                              OBJTYPE(*JRNRCV) SAVF(&SAVELIB/&SAVEFILE)   
    
                 CHGVAR     VAR(&PUT) VALUE(&SAVELIB *TCAT '/' *CAT +		->'CORPDTA/CORPRC1361.SAVF       ' 
                              &SAVEFILE *TCAT '.SAVF')
    
     /*  ===== TRANSFER SAVE FILES    =====  */
                 STRQMQRY   QMQRY(MYQMQRY) SETVAR((CAMPO3 &PUT))		->'CORPDTA/CORPRC1361.SAVF       ' 
    
                 CPYF       FROMFILE(QTEMP/FTPSCRIPT) +
                              TOFILE(MYLIB/QFTPJOBLOG) TOMBR(&IN) +
                              MBROPT(*ADD) FMTOPT(*CVTSRC)
                 MONMSG     MSGID(CPF0000)
    
                 OVRDBF     FILE(INPUT) TOFILE(MYLIB/QFTPJOBLOG) MBR(&IN)	->IN06231542
                 OVRDBF     FILE(OUTPUT) TOFILE(MYLIB/QFTPJOBLOG) MBR(&OU)	->OU06231542
                 FTP        RMTSYS('MYSERVER')
    
                 GOTO       CMDLBL(END)
     END:        ENDPGM
    
    
    ----------> QMQRY	MYLIB/MYQMQRY
    UPDATE QTEMP/FTPSCRIPT
    SET CAMPO3 =  '&PUT'
    WHERE CAMPO1 = 'PUT'
    
    ----------> MYLIB/QFTPJOBLOG (IN06231542)
    AS400      As400Backup
    cd         FILES
    bin
    PUT        &PUT
    
    
    ----------> MYLIB/QFTPJOBLOG (OU06231542)
    Output redirected to a file.
    Input read from specified override file.
    Connecting to host MYSERVER at address XXX.XX.1.28 using port 21.
    220 Microsoft FTP Service
    Enter login ID (rbdsilva):
    331 Password required for AS400.
    230 User AS400 logged in.
    Windows_NT
    Enter an FTP subcommand.
    > cd         FILES
    250 CWD command successful.
    Enter an FTP subcommand.
    > bin
    200 Type set to I.
    Enter an FTP subcommand.
    > PUT        &PUT		
    Character (&) is not allowed in object name.
    Enter an FTP subcommand.
    > QUIT
    221
    
    
    ----------> EL CONTENTS FROM FILE MYLIB/FTP_SRC1                                                          Display Report                                                           
     Line   ....+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8....+....9                                 
            CAMPO1      CAMPO2  CAMPO3                CAMPO4  CAMPO5                CAMPO6  CAMPO7                                     
     000001 AS400               As400Backup                                                                                            
     000002 cd                  FILES                                                                                                  
     000003 bin                                                                                                                        
     000004 PUT			    
    
    ----------> DEBUG THE CL JRN_GET
    + > STRISDB PGM(MYLIB/JRN_GET) UPDPROD(*YES) PARM(CORPRC1361 CORPDTA CORPRC136 
        1 CORPDTA)                                                                 
        File @@MAPSEQ in QTEMP shares access path.                                 
        Query options retrieved file QAQQINI in library QUSRSYS.                   
    + > CALL PGM(MYLIB/JRN_GET) PARM( 'CORPRC1361' 'CORPDTA' 'CORPRC1361' 'CORPDTA 
        ')                                                                         
    + > /* ISDB stopped at statement /0001 in program JRN_GET */                   
    + > /* ISDB stopped at statement 1400 in program JRN_GET */                    
    + > /* ISDB stopped at statement 1500 in program JRN_GET */ 
    + > /* ISDB stopped at statement 1800 in program JRN_GET */   
    + > /* ISDB stopped at statement 1900 in program JRN_GET */   
    + > /* ISDB stopped at statement 2200 in program JRN_GET */   
        Member FTP_SRC1 file FTPSCRIPT in QTEMP cleared.          
    + > /* ISDB stopped at statement 2300 in program JRN_GET */   
        Query options retrieved file QAQQINI in library QUSRSYS.  
        4 records copied from member FTP02.                       
    + > /* ISDB stopped at statement 2800 in program JRN_GET */   
        Save file CORPRC1361 in library CORPDTA cleared.          
    + > /* ISDB stopped at statement 3400 in program JRN_GET */   
    + > /* ISDB stopped at statement 4000 in program JRN_GET */   
        Entry for local relational database already exists.       
        CONNECT to relational database *N completed.              
        Current connection is to relational database *N.          
        SET CONNECTION to relational database *N completed.      
        Query options retrieved file QAQQINI in library QUSRSYS. 
        The query access plan has been rebuilt.                  
        Query options retrieved file QAQQINI in library QUSRSYS. 
        **** Starting optimizer debug message for query .        
        Query options retrieved file QAQQINI in library QUSRSYS. 
        Arrival sequence access was used for file FTPSCRIPT.     
        Access path suggestion for file FTPSCRIPT.               
        The query access plan has been rebuilt.                  
        Query options used to build the query access plan.       
        **** Ending debug message for query .                    
        ODP created.                                             
        Data conversion required on INSERT or UPDATE.            
        ODP deleted.                                             
        1 rows updated in FTPSCRIPT in QTEMP.                       
        Connection to relational database *N ended.                 
        SQL cursors closed.                                         
    + > /* ISDB stopped at statement 4200 in program JRN_GET */     
        Member IN06231542 added to file QFTPJOBLOG in MYLIB.        
        Query options retrieved file QAQQINI in library QUSRSYS.    
        4 records copied from member FTP_SRC1.                      
    + > /* ISDB stopped at statement 4700 in program JRN_GET */     
    + > /* ISDB stopped at statement 4800 in program JRN_GET */     
    + > /* ISDB stopped at statement 4900 in program JRN_GET */     
        Member OU06231542 added to file QFTPJOBLOG in MYLIB.        
    + > /* ISDB stopped at statement 5100 in program JRN_GET */     
    + > /* ISDB stopped at statement 5200 in program JRN_GET */     
        ISDB has ended. Program no longer in debug mode.            
    
    
    Thanks again,
    Roberto
    540 pointsBadges:
    report
  • TomLiotta
    This line in your QM query cannot work:
    SET CAMPO3 =  ‘&PUT’
    You can not have your replacement variable inside quote marks. QM will ignore values inside quotes. Because you can't have quotes there, the line must look like this:
    SET CAMPO3 =  &Q&PUT&Q
    That means that you need another replacement variable named &Q. The value in &Q should be a single-quote mark. Perhaps this will help:
    STRQMQRY   QMQRY(MYQMQRY) SETVAR((PUT) (&PUT) (Q x'7D'))
    In that statement, I used the hexadecimal representation of a standard single-quote character. I set the value of the &Q replacement variable to be x'7D'. Now when STRQMQRY runs, &Q will be replaced by x'7D'. But x'7D' is just a single-quote mark. So one single quote will be inserted before the &PUT value, and another will be inserted after the &PUT value. There will probably be other things to change, but we need to get that part working first because everything else depends on it. Change the QM query and also change your STRQMQRY command. Then we'll see what is working. Tom
    125,585 pointsBadges:
    report
  • RBDSILVA
    Hi Tom, You are the guy, the best friend....
    
    Thanks for Your help, too CharlieBrowne.
    
    see below
    
    --> QMQRY
    
    0001.00 UPDATE QTEMP/FTPSCRIPT                                                               
    0002.00 SET CAMPO3 =  &Q&PUT&Q                                                                                               
    0003.00 WHERE CAMPO1 = 'PUT'            
    
    --> CL 
    
    CHGVAR     VAR(&PUT) VALUE(&SAVELIB *TCAT '/' *CAT  +
                         &SAVEFILE *TCAT '.SAVF')                 
            
    STRQMQRY   QMQRY(MYQMQRY) SETVAR((PUT &PUT) (Q X'7D')) 
    
    -->JobLog from  OVRDBF     FILE(OUTPUT) TOFILE(MYLIB/QFTPJOBLOG) MBR(&OU) 
    Output redirected to a file.                                             
    Input read from specified override file.                                 
    Connecting to host MYSERVER at address XXX.XX.1.28 using port 21.    
    220 Microsoft FTP Service                                                
    Enter login ID (rbdsilva):                                               
    331 Password required for AS400.                                         
    230 User AS400 logged in.                                                
    Windows_NT                                                               
    Enter an FTP subcommand.                                                 
    > cd          topas                                                      
    250 CWD command successful.                                              
    Enter an FTP subcommand.                                                 
    > bin                                                                    
    200 Type set to I.                                                       
    Enter an FTP subcommand.                                                 
    > PUT         CORPDTA/CORPRC1361.SAVF                                    
    227 Entering Passive Mode (172,18,1,28,15,192).                          
    125 Data connection already open; Transfer starting.                     
    226 Transfer complete.                                                 
    484932096 bytes transferred in 24.556 seconds. Transfer rate 19748.279 KB/sec.
    Enter an FTP subcommand.                                                      
    > QUIT                                                                        
    221                                                                           
                  
    
    Thanks for all MAN, You are the Best (again).
    
    540 pointsBadges:
    report
  • TomLiotta
    Rbdsilva: So far, so good. Now, you should work on the userid and password. Those shouldn't be in your model script, MYLIB/FTP_SRC1. You should keep those somewhere else, perhaps in a couple of secured data areas or in a single *CHAR 20 data area. ( They can be in a database record or a user index entry or anywhere that you can update them with a program and keep them secure. Store in whatever way that you find easiest to store and retrieve, and that you can keep safe.) Your MYLIB/FTP_SRC1 file would have one line that says "<userid password>". You would then change your CL program to retrieve the userid and password from your secure location. You would also change your CL to run another QM query. The new QM query would UPDATE your QTEMP/FTPSCRIPT to replace the userid/password line with a new line containing your real userid and password. You would have the same kind of QM query as the one that updates the PUT line -- it would have a different WHERE clause and you would pass in a different value on the STRQMQRY command. If you do that, you will have a script in MYLIB/FTP_SRC1 that can be used in multiple ways. Anybody can look at it and copy it. If someone else uses it, they can supply a different userid and password (or use the same one that you use, if they have the authority.) You will also have two QM queries that you can use multiple places. One will apply any userid and password that can supply. The other will set any file to PUT that you supply. You would have a flexible script. You could modify the userid or the password by changing the data area (or database record or whatever). You could have strong security over the pieces that should be protected. And it's essentially all done in basic CL. Note that it doesn't have to be done. But it can have some very good future uses, especially if you need to do more tasks like this in the future. Tom
    125,585 pointsBadges:
    report

Forgot Password

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

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

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

Thanks! We'll email you when relevant content is added and updated.

Following