Release the NEW Power of CL

Release the NEW Power of CL

Name:

Email:

Programming Services

Do you need a program written?

Bruce Vining Services can provide highly experienced IBM i developers to supplement your staff with short term contracts. We don't do general ledger but if you are looking for custom solutions involving system functions such as database, communications, security, encryption, print, and work management you will find your answers at Bruce Vining Services.

Change Data by CCSID PDF Print E-mail

Change Data by CCSID (CHGDTACXCL)

Where allowed to run:
  • Batch program (*BPGM)
  • Interactive program (*IPGM)
Threadsafe: Yes
Parameters
Examples
Error messages

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).
Top

Parameters

KeywordDescriptionChoicesNotes
VAR Changed data variable Character value Required, Positional 1
TOCCSID To CCSID 0-65533, *JOB, *ASCII, *UCS2, *UTF8, *UTF16 Optional, Positional 2
BASVAR Base data variable Character value Optional
FRMCCSID From CCSID 0-65533, *JOB, *ASCII, *UCS2, *UTF8, *UTF16 Optional
LEN Length of data to change Integer, *ALL Optional
FILLCHR Fill character *NONE, *BLANK, *NULL Optional
LENRTN Length of data returned Integer Optional
OPT Change option *IBMDFT, *BESTFIT, *SUBSET Optional
Top

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.
Top

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.
Top

Base data variable (BASVAR)

Specifies the initial character string to be changed. If this parameter is not specified then the VAR parameter is used to determine the initial character value.

character-value
Specify the initial character string to be changed.
Top

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.
Top

Length of data to change (LEN)

Specifies length of the character data identified by the BASVAR parameter which is to be changed to the TOCCSID CCSID. The length is specified in bytes. The length specified must include full characters that are to be changed. For instance a LEN of 5 would be an error if the FRMCCSID value is *UCS2 or *UTF16 as these CCSIDs require an even number of bytes per character.

*ALL
All bytes of the initial character string are to be changed to the TOCCSID CCSID. If the defined size of the VAR variable is less than the number of bytes generated by the CCSID conversion an error will be sent.
integer
Specify the number of bytes to convert.
Top

Fill character (FILLCHR)

Specifies if excess bytes in the VAR variable should be set to a specific value when the length of the generated character string is less than the defined length of the VAR variable.

*NONE
Any bytes of the VAR variable that were not changed due to the CCSID conversion of the BASVAR parameter are left as is.
*BLANK
Any bytes of the VAR variable that were not changed due to the CCSID conversion of the BASVAR parameter will be set to blanks. The blansk will be in the CCSID specified by the TOCCSID parameter.
*NULL
Any bytes of the VAR variable that were not changed due to the CCSID conversion of the BASVAR parameter will be set to null bytes.
Top

Length of data returned (LENRTN)

Specifies the CL variable to be updated with the length of bytes changed in the VAR parameter due to the CCSID conversion of the BASVAR parameter. This value does not include any bytes changed due the the FILLCHR parameter value.

integer
Specify the CL variable to receive the length of bytes changed in the VAR parameter due to the BASVAR value.
Top

Change option (OPT)

Specifies the CCSID conversion option to be used when a character is encountered in the BASVAR parameter that does not exist in the TOCCSID character set.

*IBMDFT
The IBM provided default conversion of character data is used. The default may be round-trip or *SUBSET. In a round-trip conversion characters found in the BASVAR parameter that do not exist in the TOCCSID are replaced by a character in the TOCCSID that does not exist in the FRMCCSID. If the replacement character is later converted from the TOCCSID to the FRMCCSID the original character is restored. The IBM Information Center provides additional information on the default conversions that the i operating system provided.
*BESTFIT
Characters in the BASVAR parameter that do not exist in the TOCCSID are replace by the most culturally acceptable alternative that does exist. The lower case latin letter e with grave for instance may be replace with the lower case latin letter e.
*SUBSET
Characters in the BASVAR parameter to eo not exist in the TOCCSID are replaced by a substitution character defined by the TOCCSID value. For EBCDIC CCSIDs the substitution character is often x'3F' which appears on most display stations as a solid block.
Top

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.

Top

Error messages for CHGDTACXCL

*ESCAPE Messages

XCL500B
CCSID value of &1 is not supported.
XCL500C
Encoding scheme &1 not supported.
XCL5011
The combination of CCSIDs and change option is not supported.
XCL5012
The output is larger than the size of the VAR variable.
XCL5013
An invalid character or shift state was found in the BASVAR data.
XCL9002
Function did not complete. See previously listed messages related to possible user errors.
XCL9003
Function did not complete. See previously listed messages for possible cause.
XCL9004
Function did not complete. See previously listed messages for possible cause.
XCL9005
Function did not complete. Contact your service provider.
Top
 
Joomla 1.5 Templates by Joomlashack