ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

What exactly is a Stream File? with regards to replacing CPYFRMPCD with CPYFRMSTMF?

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

  • What exactly is a Stream File? with regards to replacing CPYFRMPCD with CPYFRMSTMF?

    What exactly is a Stream File? I want to copy in a file from the IFS that is NOT in qdls so how do I replace the CPYFRMPCD functionality with CPYFRMSTMF?

  • #2
    A stream file is a file that (at least from the operating system's perspective) is a stream of bytes. In other words, one big block of bytes, and no additional structure -- aside from any structure determined by applications that use it.

    This is the "normal" type of file used on all Windows, Mac and Unix systems. It is also available on IBM i via the Integrated File System (IFS) interface, where it is the most common type of file in most file systems.

    It's been 20+ years since I used CPYFRMPCD, honestly I don't really remember what it did. I'm looking at the help, and it appears to be designed to copy stream files that are in text format to physical files. That's more or less what CPYFRMSTMF does as well. Can you explain the issue you're having?

    Comment


    • #3
      CPYFRMPCD seemed pretty straight forward in that I specified the path and document name and my database file. But my first several attempts with CPYFRMSTMF aren't working, I can't seem to get the path syntax correct and I'll have to dynamically build the To File name. I thought maybe I didn't understand what a Stream File was and that I was using the wrong command.
      Thank you for the explanation!

      Comment


      • #4
        CPYTOPCD is a very, very, very old QDLS command. IIRC, it took a PF and wrote it as a fixed-width text file into QDLS.

        I think these two are corresponding examples:
        Code:
        CPYTOPCD FROMFILE(QTEMP/MYFILE) TOFLR(QDLSFOLD)       
        CPYTOSTMF FROMMBR('/QSYS.LIB/QTEMP.LIB/MYFILE.FILE/MYFILE.MBR') TOSTMF('/IFS/PATH/HERE')

        Comment


        • #5
          Yes, I want to move away from QDLS and thus switch from the CPYFRMPCD to something else; CPYFRMSTMF has a limitation that the To File needs at least 3 fields; CPYFRMIMPF is proving to be problematic too, but I'm trying all sorts of parameter value variations...

          Comment


          • #6
            CPYFRMSTMF copies the data from a text file and places it in a physical file. It does not attempt to intepret the individual fields in the file, so it has a restriction: The file you're copying to must either not have any fields defined (such as when you use CRTPF with a record length and no DDS) or else it must be a source physical file. Source physical files have 3 fields in them, that is why you're getting a message about 3 fields.

            CPYFRMIMPF is a completely different animal. It attempts to interpret the fields in the stream file and convert them to the format in the physical file. For example, you might have a stream file with commas separating the fields like this:

            Code:
            1000,"Acme Business Systems", 19.43
            And you might copy it into a physical file defined like this:

            Code:
                 A          R CUSTREC            
                 A            CUSTNO         4S 0
                 A            CUSTNAME      30A  
                 A            BALANCE        7P 2
            The CPYFRMIMPF command will interpret each of the 3 fields in the comma separated stream file, and place them in the appropriate fields in the physical file. It is not meant to copy the whole record as a block like CPYFRMSTMF is.

            We could be more helpful if you gave us the specifics of what your from-file looks like (with an example), what your to-file looks like (with the DDS or SQL source for it) and the existing CPYTOPCD command you're using. Right now we only know that you don't understand, but we don't know what precisely you're trying to do.

            Comment


            • #7
              Scott, thanks for the explanations - it helps me so much in understanding the commands at a high level, more than when I read about them in the reference guides.
              I just got CPYFRMIMPF to work! But now that I understand CPYFRMSTMF, I'm going to recreate my PF and try it.

              Comment


              • #8
                FYI, here's a template we use to create fixed-width text files using CPYFRMIMPF:
                Code:
                CPYTOIMPF  FROMFILE(&LIB/&FILE) TOSTMF(&TOSTMF) +            
                             MBROPT(&STMFOPT) FROMCCSID(37) +                
                             STMFCCSID(*PCASCII) RCDDLM(*CRLF) DTAFMT(*FIXED)
                The default is DTAFMT(*DLM), which gives delimited output (e.g. CSV).

                Comment


                • #9
                  Thanks jtalyor, I was focused on CPYFRMIMPF not CPYTOIMPF and I did get it to work.

                  Comment


                  • jtaylor___
                    jtaylor___ commented
                    Editing a comment
                    My bad. I was going the other direction.
                Working...
                X