The Change Data by CCSID (CHGDTACXCL) command changes the CCSID of character data from one CCSID to another CCSID.
This function is also available with command CHGTOCCSID in library VC2XCL. Any use of this alternative command name should be library qualified in case the i operating system were to use this command name in a future release.
Restrictions:
- All generated data from the CCSID change must fit within the defined size of the VAR variable.
- BASVAR character data encoded with a shift state CCSID, for instance mixed DBCS data, must be in the initial state (generally SBCS).
Changed data variable (VAR)
Specifies the CL variable to receive the character data in the TOCCSID CCSID. When the BASVAR parameter is not specified the VAR variable is also used to identify the data to be changed.
This is a required parameter.
- character-value
- Specify the name of the CL variable to receive the changed character data.
To CCSID (TOCCSID)
Specifies the CCSID to convert the character data to. The CCSID can be EBCDIC-based, ASCII-based, or Unicode-based. The TOCCSID value is also used to properly encode blank characters when the FILLCHR parameter is set to *BLANK.
- *JOB
- The CCSID job attribute of the current job is used. If the CCSID of the current job is 65535 then default job CCSID is used.
- *ASCII
- The CCSID used is 819 - ISO Latin 1.
- *UCS2
- The CCSID used is 13488 - Unicode UCS2.
- *UTF8
- The CCSID used is 1208 - Unicode UTF8.
- *UTF16
- The CCSID used is 1200 - Unicode UTF16.
- 0-65533
- Specify a valid CCSID in the range of 1 to 65533.
From CCSID (FRMCCSID)
Specifies the CCSID to convert the character data from. The character data is identified with the BASVAR parameter. The CCSID can be EBCDIC-based, ASCII-based, or Unicode-based.
- *JOB
- The CCSID job attribute of the current job is used. If the CCSID of the current job is 65535 then default job CCSID is used.
- *ASCII
- The CCSID used is 819 - ISO Latin 1.
- *UCS2
- The CCSID used is 13488 - Unicode UCS2.
- *UTF8
- The CCSID used is 1208 - Unicode UTF8.
- *UTF16
- The CCSID used is 1200 - Unicode UTF16.
- 0-65533
- Specify a valid CCSID in the range of 1 to 65533.
Examples for CHGDTACXCL
Example 1: Changing EBCDIC Data to ASCII Data
Dcl Var(&Source) Type(*Char) Len(10) +
Value('ABCDE')
Dcl Var(&Target) Type(*Char) Len(10)
ChgDtaCXCL Var(&Target) ToCCSID(819) BasVar(&Source)
This example changes the EBCDIC value 'ABCDE' followed by five blanks to CCSID 819 (ASCII Latin 1 used in Western European languages). After the command runs the value of the &Target CL variable will be x'41424344452020202020'. This hex value corresponds to the ASCII value 'ABCDE' followed by five ASCII blanks.
Example 2: Using Best Fit Conversion Option
Dcl Var(&Source) Type(*Char) Len(10) +
Value(x'C1C2C3C4744040404040')
Dcl Var(&Target) Type(*Char) Len(10)
ChgDtaCXCL Var(&Target) ToCCSID(423) BasVar(&Source) +
Opt(*BestFit)
This example changes the EBCDIC value 'ABCDÈ' followed by five blanks to CCSID 423 (EBCDIC Greek). The fifth character of the EBCDIC value is the upper case latin letter E with grave which does not exist the Greek CCSID 423. After the command runs the value of the &Target CL variable will be x'C1C2C3C4DC' followed by five blanks. The fifth character of this EBCDIC value (x'DC') is the lower case latin letter e with grave which does exist in CCSID 423. The lower case e with grave is used due to OPT(*BESTFIT) being in effect.
Example 3: Using Subset Conversion Option
Dcl Var(&Source) Type(*Char) Len(10) +
Value(x'C1C2C3C4744040404040')
Dcl Var(&Target) Type(*Char) Len(10)
ChgDtaCXCL Var(&Target) ToCCSID(423) BasVar(&Source) +
Opt(*Subset)
This example changes the EBCDIC value 'ABCDÈ' followed by five blanks to CCSID 423 (EBCDIC Greek). The fifth character of the EBCDIC value is the upper case latin letter E with grave which does not exist the Greek CCSID 423. After the command runs the value of the &Target CL variable will be x'C1C2C3C43F' followed by five blanks. The fifth character of this EBCDIC value (x'3F') is the substitution character defined for CCSID 423. The substitution character is used due to OPT(*SUBSET) being in effect.
Example 4: Changing Null Terminated ASCII String to Blank Filled EBCDIC Value
Dcl Var(&Source) Type(*Char) Len(10) +
Value(x'41424300F1F2F3F4F5F6')
Dcl Var(&Target) Type(*Char) Len(10)
RtvDtaLXCL Var(&Source) Len(&Len) LenDlm(*Null) CCSID(819)
ChgDtaCXCL Var(&Target) BasVar(&Source) FrmCCSID(819) +
Len(&Len) FillChr(*Blank)
This example changes the null terminated ASCII value 'ABC' (followed by six logically undefined characters due to the null character found in the fourth byte of CL variable &Source) to the blank filled EBCDIC value 'ABC'. The Retrieve Data Length (RTVDTALXCL) command is used to determine the length of the null terminated string and the CHGDTACXCL command to then change the BASVAR data, through the RTVDTALXCL returned length, to the job CCSID with blank fill.