CPYTOIMPF / CPYTOPCD question - IBM AS400

This is a discussion on CPYTOIMPF / CPYTOPCD question - IBM AS400 ; All, I have the following "problem"; On the AS I created a file with 1 field. Field length is 1024 Alpha This file is filled with some XML coding and copied to the IFS with the following command. CPYTOIMPF FROMFILE(WRKXMLP) ...

+ Reply to Thread
Results 1 to 9 of 9

Thread: CPYTOIMPF / CPYTOPCD question

  1. CPYTOIMPF / CPYTOPCD question

    All,

    I have the following "problem";

    On the AS I created a file with 1 field. Field length is 1024 Alpha
    This file is filled with some XML coding and copied to the IFS with the
    following command.

    CPYTOIMPF FROMFILE(WRKXMLP) TOSTMF(&TOSTMF)
    MBROPT(*REPLACE) STMFCODPAG(*PCASCII) +
    RCDDLM(*CRLF) STRDLM(*NONE) DECPNT(*COMMA)

    Problem now is the size of the file on the IFS. In some cases it has
    about 15000 records in it, which will result in a file bigger than
    15Mb.
    As far as I see, the CPYTOIMPF copies, for every record, the complete
    1024 bytes. However, in most cases, only 200 positions are filled with
    data.

    Because of this, I planned to first copy the AS file to the QDLS with
    the CPYTOPCD command

    CPYTOPCD FROMFILE(WRKXMLP) TOFLR(TRANSFER)
    FROMMBR(&MBRNAM) TODOC(&TODOC) TRNFMT(*TEXT)

    The parameter TRNFMT(*TEXT) will cause that only the "filled" positions
    in the file are copied.
    This will result in a much smaller file-size.

    After this I can copy the file from QDLS to the IFS with the CPY
    command


    Only problem now is, that the CPYTOPCD command adds a final record to
    the QDLS file with some hex-code in it. This will then also be copied
    to the IFS.
    While opening this file with Excel, it will cause an error because of
    this hex-code

    Anyone any idea's for copying the 1024 long file to the IFS, resulting
    in the smallest file size.

    Thanx again


  2. Re: CPYTOIMPF / CPYTOPCD question


    SanderP wrote:
    > All,
    >
    > I have the following "problem";
    >
    > On the AS I created a file with 1 field. Field length is 1024 Alpha
    > This file is filled with some XML coding and copied to the IFS with the
    > following command.
    >
    > CPYTOIMPF FROMFILE(WRKXMLP) TOSTMF(&TOSTMF)
    > MBROPT(*REPLACE) STMFCODPAG(*PCASCII) +
    > RCDDLM(*CRLF) STRDLM(*NONE) DECPNT(*COMMA)


    are you sure about this command? I thought CPYTOIMPF was for copying
    from a comma delimeted text file into a database file. Try CPYTOSTMF
    instead.

    >
    > Problem now is the size of the file on the IFS. In some cases it has
    > about 15000 records in it, which will result in a file bigger than
    > 15Mb.
    > As far as I see, the CPYTOIMPF copies, for every record, the complete
    > 1024 bytes. However, in most cases, only 200 positions are filled with
    > data.
    >
    > Because of this, I planned to first copy the AS file to the QDLS with
    > the CPYTOPCD command
    >
    > CPYTOPCD FROMFILE(WRKXMLP) TOFLR(TRANSFER)
    > FROMMBR(&MBRNAM) TODOC(&TODOC) TRNFMT(*TEXT)
    >
    > The parameter TRNFMT(*TEXT) will cause that only the "filled" positions
    > in the file are copied.
    > This will result in a much smaller file-size.
    >
    > After this I can copy the file from QDLS to the IFS with the CPY
    > command
    >
    >
    > Only problem now is, that the CPYTOPCD command adds a final record to
    > the QDLS file with some hex-code in it. This will then also be copied
    > to the IFS.
    > While opening this file with Excel, it will cause an error because of
    > this hex-code
    >
    > Anyone any idea's for copying the 1024 long file to the IFS, resulting
    > in the smallest file size.


    CPYTOPCD is from the old days. If it works you can use it. But the QDLS
    file system runs slow and I always seem to have authority problems with
    DLO files. I think CPYTOIMPF will be your best bet. Worst case you
    could write an RPG program that calls the C runtime functions that a
    LINUX C program would use to write to a file.

    -Steve


  3. Re: CPYTOIMPF / CPYTOPCD question

    Hi Steve,

    Thanks a lot for your answer!
    Never thought about the CPYTOSTMF command
    Only problem is that this command only works for sourcefiles or
    database files which are created without any fields.
    The file I use is defined in DDS with one field, but I will copy this
    data to a work file which is created with CRTPF FILE(WORKFILE)
    RCDLEN(1024)
    After this I can copy this workfile with the CPYTOSTMF command.
    Thanx again,

    Sander


  4. Re: CPYTOIMPF / CPYTOPCD question

    SanderP wrote:
    > All,
    >
    > I have the following "problem";
    >
    > On the AS I created a file with 1 field. Field length is 1024 Alpha
    > This file is filled with some XML coding and copied to the IFS with the
    > following command.
    >
    > CPYTOIMPF FROMFILE(WRKXMLP) TOSTMF(&TOSTMF)
    > MBROPT(*REPLACE) STMFCODPAG(*PCASCII) +
    > RCDDLM(*CRLF) STRDLM(*NONE) DECPNT(*COMMA)
    >
    > Problem now is the size of the file on the IFS. In some cases it has
    > about 15000 records in it, which will result in a file bigger than
    > 15Mb.
    > As far as I see, the CPYTOIMPF copies, for every record, the complete
    > 1024 bytes. However, in most cases, only 200 positions are filled with
    > data.

    Using RMVBLANK(*TRAILING) you should achieve your objective.

    --
    Dr.Ugo Gagliardelli,Modena,ItalyCertifiedUindoscrasherAñe joAlcoolInside
    Spaccamaroni andate a cagare/Spammers not welcome/Spammers vão à merda
    Spamers iros a la mierda/Spamers allez vous faire foutre/Spammers loop
    schijten/Spammers macht Euch vom Acker/Spamerzy wypierdalac'

  5. Re: CPYTOIMPF / CPYTOPCD question

    Hi Ugo,

    As far as I know this RMVBLANK(*TRAILING) parameter is only available
    in the CPYFRMIMPF command, and not in the CPYTOIMPF command, which I
    use

    Sander


  6. Re: CPYTOIMPF / CPYTOPCD question

    SanderP wrote:
    > Hi Ugo,
    >
    > As far as I know this RMVBLANK(*TRAILING) parameter is only available
    > in the CPYFRMIMPF command, and not in the CPYTOIMPF command, which I
    > use
    >
    > Sander
    >

    Hi Sander,
    Maybe I know further then you! :-) Just kidding, I know that up to V5R2
    there was no RMVBLANK, on V5R4 it's there for sure.

    This is italian but you can see parameter names from CPYTOIMPF command
    copy-screen.
    Copia nel file di import. (CPYTOIMPF)

    Immettere le scelte e premere Invio.

    Delimitatore stringa . . . . . . STRDLM *DBLQUOTE
    Carattere escape stringa . . . . STRESCCHR *STRDLM
    Rimozione spazi . . . . . . . . RMVBLANK > *TRAILING
    Delimitatore campo . . . . . . . FLDDLM ','
    Indicatore campo nullo . . . . . NULLIND *NO
    Virgola decimale . . . . . . . . DECPNT *PERIOD
    Formato della data . . . . . . . DATFMT *ISO
    Formato dell'ora . . . . . . . . TIMFMT *ISO

    If you are at a different realese then V5R4 you're right. So you should
    workaround and use CPYTOSTMF with *CRLF that removes trailing blanks.
    You are also right saying that this command works only on savf and plain
    files. What I do not understand is why are you using an externally
    described file with one field only, while you could use a physical file
    without DDS.

    --
    Dr.Ugo Gagliardelli,Modena,ItalyCertifiedUindoscrasherAñe joAlcoolInside
    Spaccamaroni andate a cagare/Spammers not welcome/Spammers vão à merda
    Spamers iros a la mierda/Spamers allez vous faire foutre/Spammers loop
    schijten/Spammers macht Euch vom Acker/Spamerzy wypierdalac'

  7. Re: CPYTOIMPF / CPYTOPCD question

    Hi Ugo,

    You're right
    We're still at V5R3 here, so we cant use the RMVBLANK parameter.
    I will keep using the workaround with the CPYTOSTMF command, untill
    we're at V5R4 also.

    Thanx for your help


  8. Re: CPYTOIMPF / CPYTOPCD question

    If you want the smallest possible file you could convert the file to a .zip
    format. Here is what you need.

    1) you need to have java installed on the machine

    2) you need to have QSHELL installed on the machine.

    Then, after you create the file using CPYTOIMPF, you can issue the following
    command to convert the file to a .zip file:

    QSH CMD('jar -cf ')

    then you can remove the original file with the UNLINK command.

    I don't think that you'll find a way to make the file any smaller than this.

    SanderP wrote:

    > All,
    >
    > I have the following "problem";
    >
    > On the AS I created a file with 1 field. Field length is 1024 Alpha
    > This file is filled with some XML coding and copied to the IFS with the
    > following command.
    >
    > CPYTOIMPF FROMFILE(WRKXMLP) TOSTMF(&TOSTMF)
    > MBROPT(*REPLACE) STMFCODPAG(*PCASCII) +
    > RCDDLM(*CRLF) STRDLM(*NONE) DECPNT(*COMMA)
    >
    > Problem now is the size of the file on the IFS. In some cases it has
    > about 15000 records in it, which will result in a file bigger than
    > 15Mb.
    > As far as I see, the CPYTOIMPF copies, for every record, the complete
    > 1024 bytes. However, in most cases, only 200 positions are filled with
    > data.
    >
    > Because of this, I planned to first copy the AS file to the QDLS with
    > the CPYTOPCD command
    >
    > CPYTOPCD FROMFILE(WRKXMLP) TOFLR(TRANSFER)
    > FROMMBR(&MBRNAM) TODOC(&TODOC) TRNFMT(*TEXT)
    >
    > The parameter TRNFMT(*TEXT) will cause that only the "filled" positions
    > in the file are copied.
    > This will result in a much smaller file-size.
    >
    > After this I can copy the file from QDLS to the IFS with the CPY
    > command
    >
    >
    > Only problem now is, that the CPYTOPCD command adds a final record to
    > the QDLS file with some hex-code in it. This will then also be copied
    > to the IFS.
    > While opening this file with Excel, it will cause an error because of
    > this hex-code
    >
    > Anyone any idea's for copying the 1024 long file to the IFS, resulting
    > in the smallest file size.
    >
    > Thanx again



  9. Re: CPYTOIMPF / CPYTOPCD question

    Thanx a lot John!!


+ Reply to Thread