Unconfigured Ad Widget

Collapse

Announcement

Collapse
No announcement yet.

FTP -- GET text file

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • FTP -- GET text file

    There are several ways. One I use is get the file to the IFS with the GET command, then use the CPYFRMIMPF or the CPYFRMSTMF command - I think those copy a TXT file to a DB2 file.

  • #2
    FTP -- GET text file

    Ok, do you have an example of how to get it the IFS with the GET command? I am just starting to become familiar with the IFS somewhat.

    Comment


    • #3
      FTP -- GET text file

      Change the name format to 1. Use the LCD - Local Change Directory command. This chagnes the current local directory to a folder on the IFS. Then the get command will place the file in the current local directory. In the FTP script... namefmt 1 lcd /IFSFolder get filename.txt (filename.txt is now on the IFS in folder IFSFolder) Then back in your CL, use one of those CPYFRMxxxx commands

      Comment


      • #4
        FTP -- GET text file

        This should get me started at least. Thanks a lot!

        Comment


        • #5
          FTP -- GET text file

          I have never fully understood batch ftp. In my CL I have the code below. I don't really understand what the overridden files are for starters, but I assume somehow associated with FTP. My ftp commands are in the xxxSCRIPT text file. I need to make part of a filename in my GET command a variable now. I need to add a date to the INBOUND.TXT file name as in INBOUNDyyyymmdd.txt. So I assume I need to drop off the .TXT in the script and change it in the CL to concatenate the full name in, but how do I access the string in my CL?
          Code

          Comment


          • #6
            FTP -- GET text file

            A couple of things. When you do an FTP(xxx.xxx.xxx.xxx) command, there are two files that the program uses. Just like files used in an RPG program. The files are INPUT, and OUTPUT. If you don't do any overrides, then the FTP command will read it's input from a display/Keyboard, and it will put the messages that come from the FTP command back out to the screen. So the reason that you're doing the OVRDBF for INPUT is so that the commands (ie the Login, userid/password, GET, QUIT) are read source member xxxSCRIPT in file xxx016F in xxxLIB instead of from the screen/keyboard. Then any messages, or actually a log of the FTP session will be written to member xxxRETURN in file xxxSRC in Library xxxLIB. If all you have in the xxxSCRIPT member is the GET C:... statment, then I assume that the FTP server doesn't require signing on. If it does, then check our xxxRETURN member to see the log of your FTP session. What I do when I need a dynamic xxxSCRIPT, is I use another program that writes to the source member. So, if you have another program that figures out the date specific INBOUnD.TXT file name, then just have that program read the member and re-write the GET statement or re-write the entire script member. If you need more help on how to do that - let us know.

            Comment


            • #7
              FTP -- GET text file

              Ok, this explains it much better. Thanks. There was more to the FTP script than what I posted. I am reading a file in my CL to determine the PC dnsname to FTP to. I need to obtain the file for the current day, so I had planned on obtaining the date within my CL before the FTP. If it's easier to re-write the script from RPG, I could do that also, but it's the dynamic script I am really not sure how to do. I am not exactly sure how to read the script file member and write out to it. If it was a physical file, no problem. But this is a bit different than what I've done before.
              Code

              Comment


              • #8
                FTP -- GET text file

                A source file is no different than any other physical DB2 file on the iSeries. So your RPG program can have a file spec of QFTPSRC, or QRPGSRC, or what ever source file the FTP scripts are in. I've pasted the F specs in the code section. The source files have 3 fields in the record - SRCSEQ, SRCDAT and SRCDTA. Use Query (or DBU or just use a DSPPFM, and DSPFFD) and do a query on your source file QFTPSRC (or what ever your FTPScript is in), and member FTPScript - and I think it'll make sense to you. Before you do the OVRDBF to file INPUT (before the call your FTP command), do an override of the QFTPSRC file like the example I have in the CODE section, and then call your RPG program to read the QFTPSRC (with member FTPSCRIPT in it), and re-write the GET line. The reason you have an OVRDBF before your FTP-Script-ReWrite program, is that the source files are multi-member files. I don't know for sure - maybe there was a way to specify the member name on the F Spec, but I know that the oVRDBF works. I've re-typed the code, so it might not compile, but it's code. Hope that helps. Jeff
                Code

                Comment


                • #9
                  FTP -- GET text file

                  Thanks so much. All I needed was to understand that I could access the source file text member. I ran an sql query on it and it makes perfect sense now.

                  Comment


                  • #10
                    FTP -- GET text file

                    I have tried both of the commands below in my CL to try to get the data that I ftp'd to the IFS folder into a PF and I get errors on both commands. When doing the copy from stream file, it says the path name to RTP015W is not correct. RTP015W is an SQL table on the iSeries with 18 fields defined. When I tried the copy from import file, I am getting an error that simply says "Error Number 3021" and I have no idea what that is. I tried changing the delimiter to *CRLF and got the same error.
                    Code

                    Comment


                    • #11
                      FTP -- GET text file

                      You might try this on your CPYFRMSTMF... CPYFRMSTMF FROMSTMF('/TEMPASSISTUSAGEVRP') TOMBR('/qsys.lib/library.lib/RPT015W.file/RPT015W.mbr') MBROPT(*ADD) I think that the TOMBR keyword on the CpyFrmSTMF command expects a QSYS.LIB type of format for the file name. Also, is the file name correct? It's called TEMPASSISTUSAGEVRP and it's in the root directory of the IFS? If that's the case - you might also think about moving it at-lease to a emp folder in the IFS.

                      Comment


                      • #12
                        FTP -- GET text file

                        I tried this, adding in the library name, SQHLIB, where the file is actually located and got the message below. The file RTP015W was defined as an SQL table with 8 fields in it. And yes I created the file on the IFS in the root directory. I just looked further at the error and it is telling me that the file must be a source physical file with 3 fields, or a program described file. Ok, but how do I get the data then to my PF?
                        Code

                        Comment


                        • #13
                          FTP -- GET text file

                          Is the Stream file comma delimited? If not, I think I usually put my STMF into a Non-Externally described DB2 file ( ie just one field in it). with a record length that's large enough to hold my entire STMF record, then I write a "parsing" program to read that DB2 file and write to the file with all my fields in it. Try creating your DB2 file using just a CRTPF command (no SQL, and No DDS). Specify a record length that will be long enough to hold the entire STMF file record. When you do a DSPFD on the created file - it should have "Externally described file...: No" HTH Jeff

                          Comment


                          • #14
                            FTP -- GET text file

                            The file that I ftp'd off the pc was a .txt file I created a file using CRTPF and ran the command below.
                            Code

                            Comment


                            • #15
                              FTP -- GET text file

                              Can you go into the IFS and actually look at the file? Dave

                              Comment

                              Working...
                              X