ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

CPYTOIMPF error

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

  • CPYTOIMPF error

    I need to add headings to CSV file but I'm getting an error. Please assist me, thanks.

    I'm trying to follow this code: http://www.code400.com/forum/showthr...CPYTOIMPF-Help

    My code and error:

    QSH CMD('echo ''"CUST REGION","CUSTN","CUST +
    NAME","INVOICE DATE","BALANCE DUE","SALES +
    PERSON"'' > /INACTIVATE/SM035W.CSV')

    QSH CMD('chmod u=rwx /INACTIVATE/SM035W.CSV')

    CPYTOIMPF FROMFILE(QTEMP/SM035W) TOSTMF(&OBJLNK) +
    MBROPT(*ADD) STMFCODPAG(*PCASCII) +

    =======================

    Message ID . . . . . . : CPF2845 Severity . . . . . . . : 40
    Message type . . . . . : Diagnostic
    Date sent . . . . . . : 05/11/10 Time sent . . . . . . : 14:45:55

    Message . . . . : The copy did not complete for reason code 1.
    Cause . . . . . : The Copy From Import File (CPYFRMIMPF) command, or Copy To
    Import File (CPYTOIMPF) command could not be completed for reason 1. The
    reason codes are:
    1 - The CCSID or code page value is not valid.
    2 - The field *N in the Field Definition File is not a field in the
    TOFILE.
    3 - The data for field *N of the TOFILE has a wrong decimal seperator.
    4 - The data for field *N of the TOFILE does not allow nulls, or the from
    file does not have enough fields for the TOFILE. The TOFILE does not support
    nulls.
    5 - The delimiters for the DTAFMT(*DLM) are not valid.

  • #2
    Re: CPYTOIMPF error

    Hi Regency:

    The copy did not complete for reason code 1.

    1 - The CCSID or code page value is not valid.
    What is the CCSID of the file you are adding to?
    wrklnk......find the file .... option 8 (display file attributes)

    Best of Luck
    GLS
    The problem with quotes on the internet is that it is hard to verify their authenticity.....Abraham Lincoln

    Comment


    • #3
      Re: CPYTOIMPF error

      Object . . . . . . : /INACTIVATE/SM035W.CSV

      Type . . . . . . . . . . . . . . . . . : STMF

      Owner . . . . . . . . . . . . . . . . : TSAMH
      System object is on . . . . . . . . . : Local
      Auxiliary storage pool . . . . . . . . : 1
      Object overflowed . . . . . . . . . : No

      Coded character set ID . . . . . . . . : 37
      Hidden file . . . . . . . . . . . . . : No
      PC system file . . . . . . . . . . . . : No
      Read only . . . . . . . . . . . . . . : No

      Need to archive (PC) . . . . . . . . . : Yes
      Need to archive (System) . . . . . . . : Yes

      Comment


      • #4
        Re: CPYTOIMPF error

        Hi Regency:

        Prompt on your cpytoimpf command. I'm at V5R4 and I don't have a STMFCODPAG option. I'll assume that the fromccsid should be 37 (ebcdic) or let it default to *file

        Best of Luck
        GLS
        The problem with quotes on the internet is that it is hard to verify their authenticity.....Abraham Lincoln

        Comment


        • #5
          Re: CPYTOIMPF error

          Hmm... Not positive on this one but try STMFCODPAG(*STDASCII) instead.
          Philippe

          Comment


          • #6
            Re: CPYTOIMPF error

            Another possibility is to create the CSV file with the Windows Code Page before.
            QSH CMD('touch -C 1252 /INACTIVATE/SM035W.CSV')

            Then use ">>" to add data :

            QSH CMD('echo ''"CUST REGION","CUSTN","CUST +
            NAME","INVOICE DATE","BALANCE DUE","SALES +
            PERSON"'' >> /INACTIVATE/SM035W.CSV')

            ... and your original CPYTOIMPF
            Patrick

            Comment


            • #7
              Re: CPYTOIMPF error

              I just use sql to create temp file with heading then do cpytoimpf MBROPT(replace)
              then I create the second table (the data) and use cpytoimpf MBROPT(add)

              I know its a bit late I can post a tiny example if interested.


              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


              • #8
                Re: CPYTOIMPF error

                Thank you all.

                I tried to set fromccsid to 37 (ebcdic), but still got the error.

                I will try all other suggestions tomorrow when I get back to work.

                Cheers

                Comment


                • #9
                  Re: CPYTOIMPF error

                  Again thank you all for your help.
                  Here is the code that worked out:

                  QSH CMD('touch -C 1252 /INACTIVATE/SM035W.CSV')

                  QSH CMD('echo ''"CUST REGION","CUSTN","CUST +
                  NAME","INVOICE DATE","BALANCE DUE","SALES +
                  PERSON"'' > /INACTIVATE/SM035W.CSV')

                  QSH CMD('chmod u=rwx /INACTIVATE/SM035W.CSV')

                  CPYTOIMPF FROMFILE(QTEMP/SM035W) +
                  TOSTMF('/INACTIVATE/SM035W.CSV') +
                  MBROPT(*ADD) STMFCODPAG(1252) RCDDLM(*CRLF)

                  Comment

                  Working...
                  X