ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

FTP using CPYTOIMPF

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

  • FTP using CPYTOIMPF

    I have one file with the following Layout, now I want to FTP this to server, but when I'm using CPYTOIMPF in my CL, due to some wrong options I had given in CPYTOIMPF, Txt file that is getting FTP is not getting with the compelete file Length.
    Length of the record is 868 bytes, but the FTPed file is truncated till the data is present in the file. Now i want for each record 868 bytes even if the data is not there completely(Basically I need the text file with complete file layout)

    CPYTOIMPF FROMFILE(PRAEDB/MDIEPFILEX) +
    TOSTMF('/home/MDIEPFILE.txt') +
    MBROPT(*REPLACE) RCDDLM(*CRLF) +
    DTAFMT(*FIXED) STRDLM(*NONE)

    Find the file layout below.
    PHP Code:
    01  MDIEP-LINE.                                              
        
    05  MDIEP-MSDE-ID               PIC X(10)   VALUE SPACES.
        
    05  MDIEP-SSN                   PIC X(09)   VALUE SPACES.
        
    05  MDIEP-STUDNO                PIC X(15)   VALUE SPACES.
        
    05  MDIEP-FNAME                 PIC X(25)   VALUE SPACES.
        
    05  MDIEP-MNAME                 PIC X       VALUE SPACES.
        
    05  MDIEP-LNAME                 PIC X(35)   VALUE SPACES.
        
    05  MDIEP-BIRTHDATE             PIC X(08)   VALUE SPACES.
        
    05  MDIEP-SEX                   PIC X       VALUE SPACES.
        
    05  MDIEP-GRADE                 PIC XX      VALUE SPACES.
        
    05  MDIEP-STREET                PIC X(50)   VALUE SPACES.
        
    05  MDIEP-ADDR2                 PIC X(50)   VALUE SPACES.
        
    05  MDIEP-CITY                  PIC X(20)   VALUE SPACES.
        
    05  MDIEP-STATE                 PIC XX      VALUE SPACES.
        
    05  MDIEP-ZIP-CD                PIC X(05)   VALUE SPACES.
        
    05  MDIEP-ZIP-4                 PIC X(04)   VALUE SPACES.
        
    05  MDIEP-PHONE                 PIC X(10)   VALUE SPACES.
        
    05  MDIEP-ETHNICITY             PIC X       VALUE SPACES.
        
    05  MDIEP-RES-PUB-AGY           PIC XX      VALUE SPACES.
        
    05  MDIEP-RES-SCHNO             PIC X(04)   VALUE SPACES.
        
    05  MDIEP-SVC-PUB-AGY           PIC XX      VALUE SPACES.
        
    05  MDIEP-SVC-SCHNO             PIC X(04)   VALUE SPACES.
        
    05  MDIEP-FNAME-F               PIC X(25)   VALUE SPACES.
        
    05  MDIEP-MNAME-F               PIC X       VALUE SPACES.
        
    05  MDIEP-LNAME-F               PIC X(35)   VALUE SPACES.
        
    05  MDIEP-RELATION-F            PIC XX      VALUE SPACES.
        
    05  MDIEP-STREET-F              PIC X(50)   VALUE SPACES.
        
    05  MDIEP-ADDR2-F               PIC X(50)   VALUE SPACES.
        
    05  MDIEP-CITY-F                PIC X(20)   VALUE SPACES.
        
    05  MDIEP-STATE-F               PIC XX      VALUE SPACES.
        
    05  MDIEP-ZIP-F                 PIC X(05)   VALUE SPACES.
        
    05  MDIEP-ZIP-4-F               PIC X(04)   VALUE SPACES.
        
    05  MDIEP-HPHONE-F              PIC X(10)   VALUE SPACES.
        
    05  MDIEP-WPHONE-F              PIC X(10)   VALUE SPACES.
        
    05  MDIEP-WPHONE-EXT-F          PIC X(05)   VALUE SPACES.
        
    05  MDIEP-CPHONE-F              PIC X(10)   VALUE SPACES.
        
    05  MDIEP-EMAIL-F               PIC X(75)   VALUE SPACES.
        
    05  MDIEP-FNAME-M               PIC X(25)   VALUE SPACES.
        
    05  MDIEP-MNAME-M               PIC X       VALUE SPACES.
        
    05  MDIEP-LNAME-M               PIC X(35)   VALUE SPACES.
        
    05  MDIEP-RELATION-M            PIC XX      VALUE SPACES.
        
    05  MDIEP-STREET-M              PIC X(50)   VALUE SPACES.
        
    05  MDIEP-ADDR2-M               PIC X(50)   VALUE SPACES.
        
    05  MDIEP-CITY-M                PIC X(20)   VALUE SPACES.
        
    05  MDIEP-STATE-M               PIC XX      VALUE SPACES.
        
    05  MDIEP-ZIP-M                 PIC X(05)   VALUE SPACES.
        
    05  MDIEP-ZIP-4-M               PIC X(04)   VALUE SPACES.
        
    05  MDIEP-HPHONE-M              PIC X(10)   VALUE SPACES.
        
    05  MDIEP-WPHONE-M              PIC X(10)   VALUE SPACES.
        
    05  MDIEP-WPHONE-EXT-M          PIC X(05)   VALUE SPACES.
        
    05  MDIEP-CPHONE-M              PIC X(10)   VALUE SPACES.
        
    05  MDIEP-EMAIL-M               PIC X(75)   VALUE SPACES

  • #2
    Re: FTP using CPYTOIMPF

    Im not sure the IFS works with COBOL.... anyone else?

    Okay Im kidding - We are missing large chunks of what is happening here.

    can we see what you are FTP'in as well as the dds to this file?

    can you post some images of the full data in the table (DBU)

    can you attach the file that is on the IFS?

    jamie
    All my answers were extracted from the "Big Dummy's Guide to the As400"
    and I take no responsibility for any of them.

    www.code400.com

    Comment


    • #3
      Re: FTP using CPYTOIMPF

      All high-level languages on the iSeries can work with IFS data and Cobol is no exception.

      The record layout that is posted is all character fields. It sounds like he's trying to FTP a physical file that has a single 868 byte field/record -and- he wants to retain the trailing spaces. The Cobol record layout is probably "internally described", which I believe is like the RPG I-specs...

      I agree Jamie, more information is needed.

      Terry

      Comment


      • #4
        Re: FTP using CPYTOIMPF

        no more info needed....it's not the CPYTOIMPF it's the FTP. check the file in the IFS for the data...you should see it as expected...then check the remote system after the FTP and you'll see that "white space" has been truncated.
        I'm not anti-social, I just don't like people -Tommy Holden

        Comment


        • #5
          Re: FTP using CPYTOIMPF

          Thanks for the response.

          Yes, exaactly white space is truncated after the data(no trailing spaces are present). All the data is coming but the trailing spaces are getting truncated.

          My FTPCMD file has following code:
          **********************************
          ftp.perfmatters $perfmatters$
          ASCII
          namefmt 1
          cd MDIEP
          PUT /home/MDIEPFILE.txt IEPSIS.TXT
          QUIT
          ****************** End of data ************************************************** ****
          Anil.

          Comment


          • #6
            Re: FTP using CPYTOIMPF

            Hi medam.anil:

            The trick here is to
            1. copy the file to be length 869.
            2. use sql or other to insert X'00' into the 869th position
            3. use the cpytoimpf as you had done [RCDDLM(*CRLF) DTAFMT(*FIXED) STRDLM(*NONE)]

            The cpytoimpf will truncate to the last non blank position of the record making it a variable length record. When you insert the X'00' the last position is not blank.

            I'm not sure what the ftp will do.

            Hope this helps
            GLS
            The problem with quotes on the internet is that it is hard to verify their authenticity.....Abraham Lincoln

            Comment


            • #7
              Re: FTP using CPYTOIMPF

              Find the two files attached One is by Using the RECEIVE file from HOST (From Actions of 5250) and the other one is by using the CL :
              I want similar to one I got from REEIVE FILE FROM HOST including the Trailing spaces with full 868 bytes(Since I want to automate I want to do this thru CL).
              PGM
              SNDMSG MSG('Job SAS061CL Download has Started') +
              TOMSGQ(QUSRSYS/DMSJOBLOG)
              CLRPFM FILE(DMSLIB/FTPSRC) MBR(MDIEPLOG)
              CPYTOIMPF FROMFILE(PRAEDB/MDIEPFILEX) +
              TOSTMF('/home/MDIEPFILE.txt') +
              MBROPT(*REPLACE) RCDDLM(*EOR) +
              DTAFMT(*FIXED) STRDLM(*NONE) NULLIND(*YES)


              OVRDBF FILE(INPUT) TOFILE(DMSLIB/FTPSRC) +
              MBR(MDIEPCMD)
              OVRDBF FILE(OUTPUT) TOFILE(DMSLIB/FTPSRC) +
              MBR(MDIEPLOG)
              STRTCPFTP RMTSYS('172.18.159.5')
              SNDMSG MSG('Job SAS061CL Download has Completed') +
              TOMSGQ(QUSRSYS/DMSJOBLOG)
              ENDIT: ENDPGM
              Attached Files

              Comment


              • #8
                Re: FTP using CPYTOIMPF

                are you sending this to a PC or to another iSeries?

                if it's iSeries to iSeries just create the same file on the target box and just FTP directly into it. another thing you can try is this:
                don't use CPYTOIMPF

                Code:
                ftp.perfmatters $perfmatters$
                ASCII
                namefmt 0
                cd MDIEP
                PUT PRAEDB/MDIEPFILEX IEPSIS.TXT
                QUIT
                I'm not anti-social, I just don't like people -Tommy Holden

                Comment


                • #9
                  Re: FTP using CPYTOIMPF

                  changed the CL:
                  Code:
                  PGM
                    SNDMSG MSG('Job SAS061CL Download has Started') +
                      TOMSGQ(QUSRSYS/DMSJOBLOG)
                    CLRPFM FILE(DMSLIB/FTPSRC) MBR(MDIEPLOG)
                  
                  
                    OVRDBF FILE(INPUT) TOFILE(DMSLIB/FTPSRC) +
                      MBR(MDIEPCMD)
                    OVRDBF FILE(OUTPUT) TOFILE(DMSLIB/FTPSRC) +
                     MBR(MDIEPLOG)
                    FTP '172.18.159.5'
                  
                    SNDMSG MSG('Job SAS061CL Download has Completed') +
                     TOMSGQ(QUSRSYS/DMSJOBLOG)
                  ENDIT: ENDPGM
                  I'm not anti-social, I just don't like people -Tommy Holden

                  Comment


                  • #10
                    Re: FTP using CPYTOIMPF

                    TOM HOLDEN,
                    I didn't see what exactly you modifed inCL, I see that you removed CPYTOIMPF.How does this help??
                    I want to FTP this to a Server in TXT format, not to iseries.

                    Anil.

                    Comment

                    Working...
                    X