Search on this Website

Friday, April 30, 2010

Error : WG_CRLF must be a character-like data object (data type C, N, D, T,or STRING) String

Error : WG_CRLF must be a character-like data object (data type C, N, D, T,or STRING) STRING).

Cause: Here WG_CRLF may be a variable or an internal table which contains variables which are of type X. Type X is used to represent hexadecimal values. Each Hexadeci-mal value can hold two characters (8 bits). These Hexadecimal values may also represent the codes for performing some actions like Horizontal Tab, Line Feed, etc. Till Version 4.6C (Non Unicode complaint environment), there was no problem if we try to assign a type C to type X and vice versa. But from Version ECC6.0, it’s not possible.

Solution: So we need to change all the X type variables to the C type Variables with their values unchanged. This can be tackled by declaring a variable as Type C, and then use the method UCCP('XXXX') of the Class CL_ABAP_CONV_IN_CE where XXXX represents the 8-bit hexadecimal value represented as 16 bits. Before this we need to load the definition of the Class CL_ABAP_CONV_IN_CE.

Example:


** Begin of Changes - 46C To ECC6 - IN9AGARWAL
CLASS: CL_ABAP_CONV_IN_CE DEFINITION LOAD.
** End of Changes - 46C To ECC6 - IN9AGARWAL

*\DATA: BEGIN OF wg_crlf,
*\ crlf(2) TYPE x VALUE '0D0A',
*\ END OF wg_crlf,

** Begin of Changes - 46C To ECC6 - IN9AGARWAL
DATA: BEGIN OF wg_crlf,
crlf(2) TYPE c,
END OF wg_crlf,
** End of Changes - 46C To ECC6 - IN9AGARWAL



** Begin of Changes - 46C To ECC6 - IN9AGARWAL
wg_crlf-crlf = CL_ABAP_CONV_IN_CE=>UCCP('0D0A').
** End of Changes - 46C To ECC6 - IN9AGARWAL

Note - 1: There are some methods of class CL_ABAP_CHAR_UTILITIES which are used to remove Errors related to Hexadecimal variables :

Following methods of class CL_ABAP_CHAR_UTILITIES are used for different val-ues of variables :

cl_abap_char_utilities=>horizontal_tab --- 09
cl_abap_char_utilities=>CR_LF --- 0D0A
cl_abap_char_utilities=>VERTICAL_TAB --- 0B
cl_abap_char_utilities=>NEWLINE --- 0A
cl_abap_char_utilities=>FORM_FEED --- 0C
cl_abap_char_utilities=>BACKSPACE --- 08


Examples :

* data : w_tab type x value '09'.

* DATA: HEX_LINEFEED TYPE X VALUE '0A'.
* DATA: LINEFEED TYPPE X VALUE ‘ODOA’.

** Begin of Changes - 46C To ECC6 - IN9AGARWAL
data : w_tab type C VALUE
CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.

DATA: HEX_LINEFEED TYPE C VALUE cl_abap_char_utilities=>NEWLINE

DATA: LINEFEED TYPPE C VALUE cl_abap_char_utilities=>CR_LF

** End of Changes - 46C To ECC6 - IN9AGARWAL


Note – 2: For e.g, the variable of type X has length more than one. Then an internal ta-ble must be created for the variable.

Example :

CLASS: CL_ABAP_CONV_IN_CE DEFINITION LOAD.
* DATA : LF(2) TYPE X VALUE 'F5CD'.
DATA : BEGIN OF LF,
A1 TYPE C,
A2 TYPE C,
END OF LF.
START-OF-SELECTION.
LF-A1 = CL_ABAP_CONV_IN_CE=>UCCP('00F5').
LF-A2 = CL_ABAP_CONV_IN_CE=>UCCP('00CD').

No comments: