ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Using CPYTOIMPF

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

  • Using CPYTOIMPF

    Is there any way to use this without having a record delimiter?

    I'm trying to copy data from physical file created by TrustedLink EDI. The file is a copy of the Comm Session data. The file has a one field and a record length of 135. CPYTOIMPF converts this nicely to a text file, but insists on inserting CR, LF or CRLF at the end of each record. I need those removed.

    Any ideas?

  • #2
    Have you tried DTAFMT(*FIXED) ?

    Comment


    • #3
      If you dont' specify one, the default is *EOR. This is the error:

      CPF2845 The copy did not complete for reason code 11

      11 - The RCDDLM parameter for a stream file can only be *CR, *CRLF, *LF,
      or *LFCR and for a data base file the RCDDLM parameter can be *EOR or a
      valid value.

      Comment


      • #4
        Why use CPYTOIMPF? It doesn't seem like you want what that command does. Perhaps CPYTOSTMF would be better, assuming I understand your situation.
        Tom

        There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors.

        Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth?

        Comment


        • #5
          Originally posted by tomliotta View Post
          Why use CPYTOIMPF? It doesn't seem like you want what that command does. Perhaps CPYTOSTMF would be better, assuming I understand your situation.
          I could not get that to work... I don't understand the syntax for the FROMMBR - but you still need to specify a end of record or *FIXED. Based on the help text, *FIXED doesn't remove the "blanks" at the end of each record. I would like to try that.

          Comment


          • #6
            Originally posted by tomliotta View Post
            Why use CPYTOIMPF? It doesn't seem like you want what that command does. Perhaps CPYTOSTMF would be better, assuming I understand your situation.
            Thanks Tom

            For anyone else that may need this:

            CPYTOSTMF FROMMBR('/qsys.lib/mylib.lib/myfile.file/member.mbr') TOSTMF('/folder/textfile.txt') DBFCCSID(37) STMFCCSID(*PCASCII) ENDLINFMT(*FIXED)

            This does work... but it does not trim spaces from the end of each record - so your stream file has spaces where they don't belong
            Last edited by gwilburn; February 1, 2017, 10:27 AM. Reason: spoke too soon

            Comment


            • #7
              That seems to be indicated in the help text for the ENDLINFMT parameter:

              "If one of the end-of-line character options is selected
              (ENDLINFMT(*FIXED) is not specified) the database file
              records are transformed to variable-length stream file
              text lines as they are copied. Each database file record
              is trimmed of any trailing blanks. Then, the data is
              converted to the destination data format (if specified)
              and the end-of-line character is appended to the end of
              the text line. The text line is copied to the stream
              file."

              Cheers,

              Emmanuel

              Comment

              Working...
              X