Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to resolve this unicode error.

Former Member
0 Likes
2,719

Hi all,

The below code gives an unicde error.

Please give your inputs.

Code:

DATA: hexfield0 TYPE x VALUE 'FF'.

TYPES: BEGIN OF ty_belnr,

belnr TYPE bkpf-belnr,

END OF ty_belnr.

DATA it_tab TYPE TABLE OF ty_belnr.

DATA wa_tab TYPE ty_belnr.

SELECT belnr FROM bkpf UP TO 10 ROWS

INTO TABLE it_tab.

IF sy-subrc = 0.

LOOP AT it_tab into wa_tab.

If not wa_tab-Belnr z Hexfield0.

Write wa_tab-Belnr.

Endif.

ENDLOOP.

ENDIF.

Thanks.

Hi all,

The below code gives an unicde error.

Please give your inputs.

Code:

DATA: hexfield0 TYPE x VALUE 'FF'.

TYPES: BEGIN OF ty_belnr,

belnr TYPE bkpf-belnr,

END OF ty_belnr.

DATA it_tab TYPE TABLE OF ty_belnr.

DATA wa_tab TYPE ty_belnr.

SELECT belnr FROM bkpf UP TO 10 ROWS

INTO TABLE it_tab.

IF sy-subrc = 0.

LOOP AT it_tab into wa_tab.

If not wa_tab-Belnr z Hexfield0.

Write wa_tab-Belnr.

Endif.

ENDLOOP.

ENDIF.

Thanks.

15 REPLIES 15
Read only

Former Member
0 Likes
2,134

Hi,

For similar kind of error, here iam giving example code.

Error: DATA: BEGIN OF ht,

x(1) TYPE x VALUE '09',

END OF ht.

Solution:

1.Define Class after the Tables definition.

CLASS cl_abap_char_utilities DEFINITION LOAD.

2.Data Defination : Comment internal table HT and define a variabl

HT type C.

  • Insert + APRIA00 05/02/2007 Unicode project

  • DATA: BEGIN OF ht,

  • x(1) TYPE x VALUE '09'

  • END OF ht.

  • Insert - APRIA00 05/02/2007 Unicode project

DATA HT type C.

3. Before using HT assign Horizontal tab.

Ht = CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.

Do let me know if you have any queries.

Regards

Arani Bhaskar

Read only

0 Likes
2,134

Hi,

The if condition in my code is as follows.

Z is used as operator.

please let me know how to deal with this.

If not wa_tab-Belnr z Hexfield0.

Read only

former_member222860
Active Contributor
0 Likes
2,134

Pl. re-check ur code again

DATA: hexfield0 TYPE x VALUE 'FF'.

TYPES: BEGIN OF ty_belnr,
          belnr type bkpf-belnr,
       END OF ty_belnr.

DATA it_tab TYPE TABLE OF ty_belnr.
DATA wa_tab TYPE ty_belnr.

SELECT belnr FROM bkpf
             UP TO 10 ROWS
             INTO TABLE it_tab.

IF sy-subrc = 0.
  LOOP AT it_tab into wa_tab.
    If not wa_tab-Belnr = Hexfield0.
      Write wa_tab-Belnr.
    Endif.
  ENDLOOP.
ENDIF.

Read only

0 Likes
2,134

Hi,

I need to solve the Unicode error here.

Z if you replace by = , the functionality will change.

Z operator cannot be replaced here.

Read only

0 Likes
2,134

Hi purshotaman,

I am sure that , check once again that code,

functionality of "z" operator is ::

Zeros: True, if the bits that are 1 in operand2 are 0 in operand1. If operand2 contains only zeroes, the logical expression is always true.

Problem is not with Z, i guess it will be with type "x". try to convert it what i said earlier and check it out.

Regards

Arani Bhaskar

Read only

0 Likes
2,134

Hi,

You cannot compare the char field with the Hexa field in the Unicode version..so you need to convert the Hexa field Hexfield0 in to char field and compare. Use the FM STPU1_HEX_TO_CHAR to the char value of the hexasting and compare with Belnr .

Read only

0 Likes
2,134

DATA: hexfield0 TYPE x VALUE 'FF'.

DATA: hexfield1 TYPE x .

TYPES: BEGIN OF ty_belnr,

belnr TYPE bkpf-belnr,

END OF ty_belnr.

DATA it_tab TYPE TABLE OF ty_belnr.

DATA wa_tab TYPE ty_belnr.

SELECT belnr FROM bkpf UP TO 10 ROWS

INTO TABLE it_tab.

IF sy-subrc = 0.

LOOP AT it_tab into wa_tab.

hexfield1 = wa_tab-Belnr.

If not hexfield1 z Hexfield0.

Write wa_tab-Belnr.

Endif.

ENDLOOP.

ENDIF.

"Though u can avoid errors..you can recheck with the requirement

Cheers

Edited by: Mukundan Ramanathan on Mar 25, 2009 12:28 PM

Read only

Former Member
0 Likes
2,134

HI,

Check this Code..

TYPES: BEGIN OF ty_belnr,
belnr TYPE bkpf-belnr,
END OF ty_belnr.

DATA it_tab TYPE TABLE OF ty_belnr.
DATA wa_tab TYPE ty_belnr.

  DATA: l_Char(5) TYPE c .                   
 DATA: c_Hexl(5) TYPE c value '\X\FF'  .  

    CALL FUNCTION 'STPU1_HEX_TO_CHAR'
      EXPORTING
                hex_string        = c_hec
     IMPORTING
              CHAR_STRING       = l_char.


SELECT belnr FROM bkpf UP TO 10 ROWS
INTO TABLE it_tab.
IF sy-subrc = 0.
LOOP AT it_tab into wa_tab.
If not wa_tab-Belnr Z l_Char.
Write wa_tab-Belnr.
Endif.
ENDLOOP.
ENDIF.

Read only

0 Likes
2,134

Thanks.

But here i am checking with a hexadecimal value 'FF'.

and the operator is Z .

The functionality should remain the same.

The unicode error needs to be resolved.

Thanks. Kindly suggest.

Read only

0 Likes
2,134

Hi,

first convert your hexadecimal field to C by following my steps, then use your code it will works fine.

Regards

Arani Bhaskar

Read only

0 Likes
2,134

STPU1_HEX_TO_CHAR function module takes character as input.

Looking if there are any FM that would convert X to C.

Literally BKPF-BELNR "10 Char" to hexadecimal.

Or Hexdecimal value 'FF' to Char.

Tried using the Fm, its dumping. Trying other options.

Thanks.

Read only

Former Member
0 Likes
2,134

belnr data type is chara length 10

and hexfield0 TYPE x hexadecimal

since the data type is mismatching hence it is showing the error.

Read only

Former Member
0 Likes
2,134

DATA: hexfield0 TYPE x VALUE 'FF'.

TYPES: BEGIN OF ty_belnr,

belnr TYPE bkpf-belnr,

END OF ty_belnr.

class CL_ABAP_CONV_IN_CE definition load. "class for hex to char conversion

data lv_Hexfield0_uc type c. " field for storing hex value in char format

DATA it_tab TYPE TABLE OF ty_belnr.

DATA wa_tab TYPE ty_belnr.

SELECT belnr FROM bkpf UP TO 10 ROWS

INTO TABLE it_tab.

IF sy-subrc = 0.

lv_Hexfield0_uc = CL_ABAP_CONV_IN_CE=>UCCP('FF'). " conv HEX to C.

LOOP AT it_tab into wa_tab.

If not wa_tab-Belnr z lv_Hexfield0_uc. " use of lv_hexfield...

Write wa_tab-Belnr.

Endif.

ENDLOOP.

ENDIF.

Read only

0 Likes
2,134

Hi,

lv_Hexfield0_uc = CL_ABAP_CONV_IN_CE=>UCCP('FF'). " conv HEX to C.

is still giving the same error.

It says wa_tab-Belnr must be a byte-type field. ( type X or XSTRING).

I guess this is due to the Operator they used "Z" in the system.

Read only

0 Likes
2,134

then u need to convert the character field into X.

suppose ur char field is wa-axx and Hexa field is hex, then.......

field-symbols: <lv> type X.

assign: wa-axx to <lv> casting.

if <lv> Z hex.

//ur code.

endif.