ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

FTP from Shared Drive to AS400

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

  • FTP from Shared Drive to AS400

    Hello,
    I'm trying set up a automate batch job to read the Fixed legth .TXT file from Shared drive and load into AS400. And then the program reads that file and do some process.

    When ever i'm running that job there is one decimal field in that file and once the file is read it's throwing all the junk data into the Numeric decimal field, because of that data is getting jumbled in the next fields.

    File layout is in Attached file layout.txt and my FTP job is in FTP job
    Trying to load TEST.txt from shared directory (as400-connector)into PRAEDB/pfpupconn using GET command in PUPCONCMD.

    Attached CL,File Layout, Input test file and Output Error file snapshot. Can some one help what is the problem in this, when I do that manually through 'Receive file from host' in AS400, all the fields are getting loaded properly with the same input file. I feel some issue with the Absence numeric decial field.

    Appreciate the response.

    Thanks,
    Anil.
    Attached Files

  • #2
    Re: FTP from Shared Drive to AS400

    well...you are putting blanks in a numeric field for one. also it looks like your definition is off and you actually want .0 to be the value in the numeric field. for this to work you have to remember that decimals on the system are implied not explicit in other words omit the decimal point. to get the resulting 000.0 you'll have to have 0000 in the corresponding buffer positions.
    I'm not anti-social, I just don't like people -Tommy Holden

    Comment


    • #3
      Re: FTP from Shared Drive to AS400

      Make all fields alpha then within the program make the decision to change it to numeric IF it is valid data.
      Bill
      "A good friend will bail you out of jail,
      A true friend would be sitting beside you saying,
      'Wow, that was fun.'"

      Comment


      • #4
        Re: FTP from Shared Drive to AS400

        Thanks Tom it did worked fine with your solution. I appreciate your quick response on this.

        I have one more question. For this FTP process, the department which is generating the I/p file and keeping in the shared drive wants to post the same with different file name each time they generate like TEST_09_07_08_10_00_00(File Name_DATE_TIME) as they will be generating this file every one hr from Morning to evening. If they use the same file name like TEST.TXT, due to some problem if my job in AS400 doesn't run, their process will override when they run in the next hr and we may loose the data. so to avoid data loss, they want me to FTP their file name into AS400 and uppon successful, I should move to some Processed files folder, so that nothing will be missed out. I just want to know if that is possible.
        Can you help in this regard.

        Anil.

        Comment


        • #5
          Re: FTP from Shared Drive to AS400

          Well, this program is very old, but it does something like what you need. In this case, the file name is tied to the date, but you could modify it to be hour, minutes, or just iterate a seq number. It consists of 3 parts, CL, RPG, and TXT file for the FTP command.
          The RPG pgm just reads thru the text file, and replaces the date where needed.
          Code:
          /*    FTP with a variable name    */
          PGM
          OVRDBF     QFTPSRC   TOFILE(MYLIB/QFTPSRC) MBR(IDGIN)
          /*    CHANGE THE FILE NAME TO INCLUDE TODAY'S DATE -         */
          /*    EX. 01063005.PRN BECOMES 01070105 ON JULY 1, 2005      */
          CALL       PGM(IDGSETDT)
          DLTOVR     QFTPSRC
          CLRPFM     FILE(MYLIB/QFTPSRC) MBR(IDGOUT)
          OVRDBF     FILE(INPUT) TOFILE(MYLIB/QFTPSRC) MBR(IDGIN)
          OVRDBF     FILE(OUTPUT) TOFILE(MYLIB/QFTPSRC) MBR(IDGOUT)
          FTP        RMTSYS('//WWW.XXXXXXXX.COM')
          DLTOVR     INPUT
          DLTOVR     OUTPUT
          ENDPGM
          Code:
          mylogin mypassword
          get 01090608.PRN anylib1/idgfit (replace
          get 03090608.PRN anylib1/idgnew (replace
          del 01090608.PRN
          del 03090608.PRN
          quit
          Code:
               FQFTPSRC   UPE  E             Disk
               F                                     Rename(QFTPSRC:FTPRF)
               D  Pos            S              3S 0
               C                   Eval      Pos = %scan('.PRN':SRCDTA)
               C                   If        Pos > 0
               C                   Eval      SRCDTA = %subst(SRCDTA:1:(Pos-7))
               C                               + %editc(UDate:'X')
               C                               + %subst(SRCDTA:Pos)
               C                   Update    FTPRF
               C                   EndIf

          Comment


          • #6
            Re: FTP from Shared Drive to AS400

            You can use the LS command from the FTP session to list the files in the remote folder.

            Have a logfile on the 400 side to list the processed files.

            Then only download the un-processed filenames
            process them
            add a record to the processed log file if the processing works

            You can scan the remote server every xx mins as you like.

            The LS command writes to a file called LSOUTPUT in your *CURRENT library, which cannot be QTEMP.

            You can even then delete all files from the remote server that have been processed ok.

            I use this as the FTP input file
            PHP Code:
            userid password03   
            lcd Local_Dir_Name      
            cd Remote_Dir_Name  
            ls 
            (disk          
            quit 
            Greg Craill: "Life's hard - Get a helmet !!"

            Comment

            Working...
            X