How do I convert the fields from EBCDIC format to ASCII format -- using the CPYTOIMPF command?
When copying from a DB2/UDB 400 file (normal physical file) using the CPYTOIMPF, the TOCCSID keyword is used to determine what character set to use if copying to a DB2/UDB-400 file. If you're attempting to use this command to convert to a .CSV type of file, you should use the CPYTOIMPF to copy from a database file to a source-physical file member. Then copy using the CPYTOSTMF from your source-physical to the IFS file you are attempting to create. During the second copy function, you can specify the stream file code page of '00819' in order to change from CCSID 65535 (37 as a default) to the ASCII CCSID of 819.
As an alternative, you can put a file in an IFS directory, which already contains a file you are copying over with a CCSID of 819. In my original use of these commands I did the following:
/* Copy a temp file with the correct CCSID then copy over */ /* to set the CCSID to the correct one */ CPYTOSTMF FROMMBR('/qsys.lib/qgpl.lib/qtxtsrc.file/temp.mbr') TOSTMF(&TOSTMF) STMFOPT(*REPLACE) STMFCODPAG(00819) /* This creates a one character file with the correct CCSID of 819 */ CPYTOIMPF FROMFILE(&FROMLIB/&FROMFILE &MBR) TOSTMF(&TOSTMF) MBROPT(*REPLACE) RCDDLM(*CRLR) DTAFMT(*DLM) STRDLM('"') FLDDLM(',') /* This copies and replaces the file containing the correct CCSID */
MORE INFORMATION ON THIS TOPIC
The Best Web Links: tips, tutorials and more.
Ask your programming questions--or help out your peers by answering them--in our live discussion forums.
Ask the Experts yourself: Our application development gurus are waiting to answer your programming questions.