How can I tell if a file is ASCII or EBCDIC in iSeries?

245 pts.
File Types
IBM iSeries
Hi, I have to create a file to send to another location outside of our company. they ask if the file type is ASCII or EBCDIC. How do I tell what the file is on the iseries? Also when I transfer the file thru FTP do I need to define it in FTP. Thanks!

Answer Wiki

Thanks. We'll let you know when a new response is added.

As you start off with “I have to create a file to send” I would say the encoding of the file is entirely up to you. You could use ASCII, EBCDIC, Unicode, etc. If you’re creating the file on an i then EBCDIC will generally be the easiest for you (EBCDIC is the default if you’re creating the file using a high level language such as RPG)..

One thing to keep in mind is that ASCII, EBCDIC, and Unicode are really rather high level indicators of how the file is encoded. If the “location outside of our company” is in the same country (or really, using the same national language) as your company then saying it’s ASCII or EBCDIC might be sufficient. If your company is in the United States and the other company in Japan, Russia, England, or a long list of other countries then they may need to know the CCSID of the data you will be sending them (which you can control) depending on what type of data you’re sending. With Unicode, even within the same country/national language, they may want to know if the data is UTF8, UCS2, UTF16, UTF32, etc (though they can typically figure this out with one quick look at the data received).

Discuss This Question: 3  Replies

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • TomLiotta
    In both cases, it kind of depends on what the person is thinking when the words "ASCII" and "EBCDIC" are used. Unless it's inside of a savefile or some other kind of object that is transferred as BINARY, it shouldn't matter which one it is. FTP and similar transfer protocols should translate the encodings automatically. It might be EBCDIC on your system but ASCII when it arrives at the remote system. The real "trick" is in ensuring that your systems are properly configured. Mostly that means that your QCCSID system value is set appropriately. A common issue is that sites leave the setting at the 65535 default that effectively causes transfers to happen in BINARY (no encoding translation) mode. Conversion between EBCDIC and ASCII should be automatic as needed. What transfer protocol or method are you going to use? What kind of system is at the remote site? What kind of file will you transfer? (Database? Streamfile?) Tom
    125,585 pointsBadges:
  • TomLiotta
    Bruce saw what might be the most important detail -- "I have to create a file...". they ask if the file type is ASCII or EBCDIC. How do I tell what the file is on the iseries? I would normally assume that you will be creating a streamfile (in the IFS), given the elements of your question. You can create ASCII streamfiles in a variety of ways. You might use Windows Explorer from your PC to create a .TXT file in a mapped drive that is shared from your iSeries. You can name it anything you wish; the initial .TXT extension can be replaced with a different extension. Windows will create an ASCII file by default. You might use CPYTOIMPF or CPYTOSTMF to create a streamfile. Use the STMFCODPAG(*PCASCII) parameter value to create a Windows Unicode streamfile or STMFCODPAG(*STDASCII) to create a standard ASCII text file. The *PCASCII option creates the streamfile as CCSID 1252 which is what Windows Explorer would probably create for you, and *STDASCII will assign CCSID 437 which might be easier for some Unix users. If you simply create a streamfile, with Windows Explorer or CPYTOIMPF/CPYTOSTMF, it's not important what you put into the file at that time. You can delete all of the initial data. What you are interested in at that moment is the attributes that get assigned to the streamfile. That will give you a base streamfile to review. Use WRKLNK to navigate to the streamfile and use option 8=Display attributes. You should see 'Coded character set ID' is 437 if you chose *STDASCII or 1252 if you chose *PCASCII (or if you used Windows Explorer). You can then use EDTF (or option 2=Edit) to input lines into the file. Whatever you enter in the file should be completely readable if you open the file in Notepad through Windows Explorer. After creating and testing a streamfile, you should have some idea about how to tell if a streamfile is ASCII or EBCDIC. A common first clue will be that Notepad can make sense of every character in the file. When data doesn't look right, you should look at the streamfile attributes to see what the system thinks should be in the file. You can create a streamfile as above, and then try one of the CPY* commands again with a different STMFCODPAG() value to see what happens when you try to copy using an encoding different from what the file says should be there. Any errors should help widen your experience. Those are just some generic comments. I would ask the recipient what encoding they prefer and provide it in their preferred encoding. Because they asked, they may be plenty familiar with both. That could mean that you could create it in the EBCDIC CCSID that is used by most jobs on your system. (In the USA, CCSID 37 is probably the most common for EBCDIC.) You can check your system in a couple ways. First DSPSYSVAL QCCSID will display the CCSID that was assigned for your system. If it shows up as 65535, then you can take a second step to see what might be best for you. Run DSPJOB to see attributes of an interactive job. From the DSPJOB menu, take option 2, 'Display job definition attributes', and scroll down. At the top of the third screen, you'd probably see 'Coded character set identifier' is also 65535. But just below that you should see the 'Default coded character set identifier' that was assigned to the job. The system won't let your jobs run as 65535, so it chooses a CCSID based on Language, Country and related elements. In the USA, the most likely default will be 37. If you create your streamfile with CCSID 37, you'll want to tell the recipient that the file is EBCDIC. I hope that doesn't bury something you need to know with too much commentary. Different system architectures in different countries with different languages and different alphabets can lead to data difficulties. Tom
    125,585 pointsBadges:
  • The Most-Watched IT Questions: November 23, 2010 - ITKE Community Blog
    [...] 7. Bvining and TomLiotta shared their iSeries expertise with a member wondering how to tell if a file is ASCII or EBCDIC in iSeries. [...]
    0 pointsBadges:

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.


Share this item with your network: