RPGIV @ Work

A unique site for RPG and System i Lovers

Welcome!

Hi, this site will provide all what you need in System i and RPG developments.

My Name is Chamara Withanachchi, System i Expert and RPG Developer. And in the field for last 11 years.

I hope you will find lot of valuable information from this site

Changing the CCSID of an IFS File Print E-mail
User Rating: / 0
PoorBest 
Written by Chamara Withanachchi   

From time to time, you'll find a stream file in your IFS that's marked with the wrong CCSID. I recently had a problem where a file in my IFS was full of ASCII data but was marked as CCSID 37 (US EBCDIC). This was a problem because the IBM-supplied commands didn't convert the data, since they thought it was already in EBCDIC.


The CHGATR command can be used to change the CCSID of a stream file. Here's an example:


CHGATR OBJ('/path/to/myfile.txt') ATR(*CCSID) VALUE(819)

Another way to do the same thing is with the SETCCSID command in QShell. Here's an example of that command:


STRQSH CMD('setccsid 819 /path/to/myfile.txt')

If the data in the stream file also needs to be converted, you can use QShell's ICONV command to convert it. This does not set the CCSID of the resulting file properly, but we already know how to fix that!


The following command converts the data in MYFILE.TXT from CCSID 37 to CCSID 819 and writes the output to YOURFILE.TXT:


STRQSH CMD('iconv -f 37 -t 819 /path/to/myfile.txt > /path/to/yourfile.txt 
&& setccsid 819 /path/to/yourfile.txt')
Another way to convert the data in the file is with the CPY CL command. Here's an example of that: [code] CPY OBJ('/path/to/myfile.txt') TOOBJ('/path/to/yourfile.txt') + FROMCCSID(37) TOCCSID(819) DTAFMT(*TEXT) [/code]
User Comments

Please login or register to add comments

Next>