ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Extra Character at end of Downloaded file

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

  • Extra Character at end of Downloaded file

    No matter how I download a file from the IBM I to the IFS (CPYTOPCD, CPYTOSTMF, or iSeries Access for Windows), the resulting file has an extra line containing what appears to be a single character. In Notepad, the character show up as a right arrow. I've struggled with this issue for quite some time. The extra character frequently causes problems in situations where the file is sent to a third party for processing into their application. Has anyone else run into this?

  • #2
    Re: Extra Character at end of Downloaded file

    show us your cpytoimpf and what is the last record in your table look like.
    Hunting down the future ms. Ex DeadManWalks. *certain restrictions apply

    Comment


    • #3
      Re: Extra Character at end of Downloaded file

      Originally posted by rms_mtta10
      No matter how I download a file from the IBM I to the IFS...
      It's not clear what that means. The IFS is the Integrated File System for IBM i systems. That is, they are generally the same when spoken of as you have. It's like saying "download from the IBM i to the IBM i" or perhaps "from the IFS to the IFS". It can get a little more complicated when thinking about the /QNTC file system because it can extend the IFS to seem to include other systems.

      Can you explain the actual process?

      I'd guess that you have a physical file and you copy its data into a streamfile in some directory. (Physical files and streamfiles both reside in the IFS of IBM i.) The directory is shared out to a Windows network, and you then access it to open the streamfile with NotePad. (Or you might copy the PF data to some streamfile under the /QNTC file system.)

      Do you create the streamfile before you copy data into it? If you do, what are its attributes? And whether it exists or not, what is an exact command that you use to do the copy?
      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


      • #4
        Re: Extra Character at end of Downloaded file

        Sorry for not including more details - here is one example of an attempt to copy an IBM I physical file to a folder in QDLS:

        The physical file on the IBM i (RMSLIB/EDCODES) is externally defined with the following 2 fields:
        PREDC 3 Alpha Text(Education Code)
        PREDCD 25 Alpha Text(Education Description)

        The file contains the following 4 records:
        EDUCATION EDUCATION
        CODE DESCRIPTION
        10 10TH GRADE
        11 11TH GRADE
        12 12TH GRADE
        12E HIGH SCHOOL EQUIV

        I issued the following command to copy the file EDCODES to folder QDLS/BLWBA to a file called EDUC.TXT:

        CPYTOPCD FROMFILE(RMSLIB/EDCODES) TOFLR(BLWBA) TODOC(EDUC.TXT) REPLACE(*YES)

        File EDUC.TXT contains the following records (as displayed using Notepad:

        10 10TH GRADE
        11 11TH GRADE
        12 12TH GRADE
        12EHIGH SCHOOL EQUIV

        There is a 5th record with a single character that shows up in Notepad as a right arrow. (I would attach the actual file, but am new to this forum and have not yet figured out how to add attachments.)

        Comment


        • #5
          Re: Extra Character at end of Downloaded file

          Sorry for not including more details - here is one example of an attempt to copy an IBM I physical file to a folder in QDLS:

          The physical file on the IBM i (RMSLIB/EDCODES) is externally defined with the following 2 fields:
          PREDC 3 Alpha Text(Education Code)
          PREDCD 25 Alpha Text(Education Description)

          The file contains the following 4 records:
          EDUCATION EDUCATION
          CODE DESCRIPTION
          10 10TH GRADE
          11 11TH GRADE
          12 12TH GRADE
          12E HIGH SCHOOL EQUIV

          I issued the following command to copy the file EDCODES to folder QDLS/BLWBA to a file called EDUC.TXT:

          CPYTOPCD FROMFILE(RMSLIB/EDCODES) TOFLR(BLWBA) TODOC(EDUC.TXT) REPLACE(*YES)

          File EDUC.TXT contains the following records (as displayed using Notepad:

          10 10TH GRADE
          11 11TH GRADE
          12 12TH GRADE
          12EHIGH SCHOOL EQUIV

          There is a 5th record with a single character that shows up in Notepad as a right arrow. (I would attach the actual file, but am new to this forum and have not yet figured out how to add attachments.)

          Comment


          • #6
            Re: Extra Character at end of Downloaded file

            I have attached the file EDUC.TXT that was copied from the IBM i to QDLS/BLWBA using the following command:
            CPYTOPCD FROMFILE(RMSLIB/PRCODES) TOFLR(BLWBA) TODOC(EDUC.TXT)
            Attached Files

            Comment


            • #7
              Re: Extra Character at end of Downloaded file

              cpytopcd will always give you an end of file marker.

              You need to use cpytostmf.
              Because your file is externally defined cpytostmf will not work directly. You need to make a flat file and copy your external defined file to that flat file. Now you can cpytostmf.
              1. CRTPF FILE(QTEMP/JUNK) RCDLEN(300) <----you need to correct the record length and ensure your file does not contain packed chars
              2. CPYF FROMFILE(mylib/myfile) TOFILE(QTEMP/JUNK) MBROPT(*ADD) CRTFILE(*NO) FMTOPT(*NOCHK)
              3. CPYTOSTMF FROMMBR('\\qsys.lib\qtemp.lib\junk.file\junk.mbr') TOSTMF('/qdls/myflr/myfile.txt') STMFOPT(*REPLACE) STMFCCSID(*PCASCII)

              You may also want to look into cpytoimpf to generate a .csv file.


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

              Comment


              • #8
                Re: Extra Character at end of Downloaded file

                if you are at v6r1 (I think) or higher you can use cpytoimpf using data format *fixed

                CPYTOIMPF FROMFILE(mylib/myfile) TOSTMF('/qdls/myflr/myfile.txt') MBROPT(*REPLACE) STMFCCSID(*PCASCII) RCDDLM(*CRLF) DTAFMT(*FIXED) ADDCOLNAM(*NONE)

                If you use the ADDCOLNAM(*sys)...... the column names are comma separated.

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

                Comment


                • #9
                  Re: Extra Character at end of Downloaded file

                  Originally posted by GLS400 View Post
                  cpytopcd will always give you an end of file marker.

                  3. CPYTOSTMF FROMMBR('\\qsys.lib\qtemp.lib\junk.file\junk.mbr') TOSTMF('/qdls/myflr/myfile.txt') STMFOPT(*REPLACE) STMFCCSID(*PCASCII)
                  That doesn't look right?
                  FROMMBR('\\qsys.lib\qtemp.lib\junk.file\junk.mbr')

                  Shouldn't that be:
                  FROMMBR('/qsys.lib/qtemp.lib/junk.file/junk.mbr')

                  Backward slashes are very much a windows thing...

                  Comment


                  • #10
                    Re: Extra Character at end of Downloaded file

                    I see CPYTOIMPF DTAFMT(*FIXED) in library QSYSV5R1M0 on one of my older V5R3 systems, so it should be good just about everywhere nowadays.

                    The big issue will be the use of the /QDLS file system. Too bad IBM couldn't find a way to have every command that references it put out a *DIAG that says "Don't use /QDLS any more. It's old and practically obsolete." Something like the message SEU displays pointing out newer editors.
                    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


                    • #11
                      Re: Extra Character at end of Downloaded file

                      The character at the end of the file is ASCII x'1A' (Ctrl-Z). Ages ago this was added for compatbility with the CP/M operating system... It required this character to denote "end of useful data" in the file, so very old software from the earlier years of the MS-DOS era would put this character in there to denote the end of file just in case the file was ever sent to or used on a CP/M system.

                      QDLS was obsolete in 1995. Nobody should be using that today. Likewise, CPYTOPCD has been obsolete since around the same time.

                      CPYTOSTMF should work better. CPYTOIMPF would also work, but this is intended to reformat an externally defined file into a text file, so may not be appropriate here. You could also use QShell or write an HLL program to copy this file.

                      Comment


                      • #12
                        Re: Extra Character at end of Downloaded file

                        Or simply continue using CPYTOPCD until you can rewrite the application to use IFS - knowing you have to strip away the last character...

                        Comment


                        • #13
                          Re: Extra Character at end of Downloaded file

                          Thanks to all who replied. It looks like I will need to do some reading and experimenting to learn all the ins and outs of using the CPYTOSTMF and CPYTOIMPF commands. I think my main struggle will be making sense of the CCSID-related parms. The reason I had used CPYTOPCD for so long is that it was simple and it worked. It is only within the past year or so that the EOF character has been causing problems with applications that are using the file.

                          As far as QDLS being obsolete...if all I am doing is extracting data needed by another application and writing it out somewhere, I don't readily see what difference it makes where I write it to, as long as the user (or application) who needs it, can get to it. The only restriction I am aware of is with QDLS is the number of characters in the filename. Obviously, for other needs or purposes outside of a creating an interface file, other restrictions may come into play.

                          Again - thanks so much for all your responses.

                          Comment


                          • #14
                            Re: Extra Character at end of Downloaded file

                            It looks like I will need to do some reading and experimenting to learn all the ins and outs of using the CPYTOSTMF and CPYTOIMPF commands. My main struggle will be making sense of the CCSID-related parms. The reason I had used CPYTOPCD for so long is that it was simple and it worked. It is only within the past year or so that the EOF character has been causing problems with applications that are using the file.

                            As far as QDLS being obsolete...if all I am doing is extracting data needed by another application and writing it out somewhere, I don't see what difference it makes where I write it to, as long as the user (or application) who needs it, can get to it. The only restriction I am aware of is with QDLS is the number of characters in the filename. Obviously, for purposes beyond creating an interface file, other restrictions may come into play.

                            Thanks so much to all who responded.

                            Comment

                            Working...
                            X