ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

CPYTOIMPF command parameters for csv file

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

  • CPYTOIMPF command parameters for csv file

    Hello all, do you know if for copy a DB2 file into IFS directory in streamfile which will need to be csv file on other system, do I have to specify a specific CCSID for this? I have the name with .csv extension and *PCASCII specified

  • #2
    Specifying STMFCCSID(*PCASCII) is the same as specifying STMFCCSID(1252) which is one of the ASCII character sets, so it should work fine.

    Comment


    • #3
      it copy but with 500 CCSID.. I will try with a specific CCSID, as 1252

      Comment


      • #4
        If the stream file that you are copying to already exists, then it won't change the CCSID of the file. If that's the case, try deleting it and then run the CPYTOIMPF command.

        Comment


        • #5
          What is the CCSID of the DB file? If it is 65535, then you will need to also specify the FROMCCSID parameter and match it to the data in the file.

          Comment


          • #6
            How can I see it? With basic command wrkobj is somewhere a parameter for this?

            Comment


            • #7
              I saw the CCSID with CHGPF.. the single way I can figure out to find it.. and I saw that it is *HEX and I can't change it with CHGPF to specify another one because this is a program described file.. Explicitly specified CCSIDs or file restrictions present. - reason code 4

              Message ID . . . . . . : CPD322D Severity . . . . . . . : 20
              Message type . . . . . : Diagnostic
              Date sent . . . . . . : 06/27/18 Time sent . . . . . . : 07:50:07

              Message . . . . : Explicitly specified CCSIDs or file restrictions present.
              Cause . . . . . : The CCSID(s) for file FILE1 in library LIB1 can not
              be changed because of reason 4. The reason codes are:
              4 - The file is a program described file.

              Comment


              • #8
                If the file is a programmed described file, then try using the CPYTOSTMF command instead of CPYTOIMPF.

                Comment


                • #9
                  I would prefer to keep CPYTOIMPF because I have a custom program special desinged for this, it is inside a process, which is a generic process to be applied for many cases.. so, with CPYTOIMPF what will be the choices? I necessarily need to have in IFS a streamfile which can be .csv file on the remote server, which is unix, after the transfer.. no matter what is the CCSID of the DB2 file.. until now I did the copy with CPYTOIMPF with this parameters, using *PCASCII :

                  FROMCCSID *FILE
                  TOCCSID *FILE
                  STMFCCSID *STMF
                  STMFCODPAG > *PCASCII
                  .. but I can modify all of those parameters because I have a setup table were I keep all of those parameters for CPYTOIMPF, if I have a special case where I need some particular settings.

                  So what do you recommend? the interesting thing is that for many DB2 files copied with this command, with STMFCODPAG = *PCASCII all the things are good and I have the stream file in a good format, with code page 1252 and it is well interpreted on the remote server as .csv file.. probably the DB2 file has a good CCSID after the copy into IFS and this is the reason for what I do not have any issue.

                  What I want is to be independent of the CCSID of the DB2 file, even if I have a DB2 file with *HEX as CCSID I want to be able to copy into IFS with an appropriate CCSID and transfer it and being well interpreted as .csv..

                  Comment


                  • #10
                    The problem is with programmed described files since they are created with a CCSID value of 65535 (or *HEX) which is treated as binary data and not converted. If you can determine when you're dealing with a program described file, then add the FROMCCSID parameter to the CPYTOIMPF command as John.sev99 suggested. Also, the STMFCODPAG parameter is deprecated, use the STMFCCSID parameter instead.

                    Comment


                    • #11
                      And what should be the value for FROMSTMF in that case? If I need to specify for DB2 files with ccsid=*hex?

                      Comment


                      • #12
                        It's hex data - neither we nor the system has any idea of how that data should be interpreted. For example, if the first byte of data in the file is hex 40, if we were to interpret that as a character, in EBCDIC that would be a space but in ASCII that would be a @ character. What if it was some other text encoding scheme? Maybe the programmer didn't intend it to be a character? Maybe hex 40 represents a number, in which case it would be 64 if written as an integer number, or 4 if a packed decimal or something else maybe for some other encoding scheme. Or maybe it has some other meaning like a pixel in a picture or an amplitude in a sound file or something else? How can the system possibly know what the data represents? Only you can determine that based on your knowledge of what's written in the file.
                        Last edited by john.sev99; June 28, 2018, 05:34 PM.

                        Comment


                        • #13
                          in that files I have some text, only data to be sent to another system, with information about some products etc.. the issue is that I transferred under ssh/sfp this file from IFS, copied before with CPYTOIMPF command with *PCASCII at STMFCODPAG parameter.. before this change the file was sent directly from DB2 with FTP, and as I said, this DB2 file has CCSID = *HEX..
                          What I need to put to be well interpreted on the other system, it must be .csv, before, with FTP it was good interpreted

                          Comment


                          • #14
                            If this is just text data, then I would use the what the CCSID value is for your job, or if that's set to 65535, then use the value of your job's default CCSID. My system is set to 37, but your system may be different. To find out the value, use command DSPJOB and look at option 2.

                            Comment


                            • #15
                              Thanks, I'll try it

                              Comment

                              Working...
                              X