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

Unicode Compliance

Former Member
0 Likes
594

Hi All,

I am working on conversion of the programs from non Unicode to Unicode.

I am getting the error at the statement of

TRANSLATE KNA1 TO UPPER CASE.

I know that if I write field by filed like TRANSLATE KNA1-KUNNR TO UPPER CASE. the error wont appear.Is there any simple method rather than doing field by field method. Please let me know.

Thanks in advance.

Regards,

Ameer.

1 ACCEPTED SOLUTION
Read only

uwe_schieferstein
Active Contributor
0 Likes
562

Hello Ameer

Here is possible solution for your problem. You cannot skip the field-by-field step because you will get an error when translating fields of type 'P'.

*&---------------------------------------------------------------------*
*& Report  ZUS_SDN_UC_TRANSLATE
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  zus_sdn_uc_translate.


TYPE-POOLS: abap.


DATA:
  go_struct      TYPE REF TO cl_abap_structdescr,
  gs_comp        TYPE abap_compdescr,
  gt_kna1        TYPE STANDARD TABLE OF kna1.



FIELD-SYMBOLS:
  <gd_fld>       TYPE ANY,
  <gs_kna1>      TYPE kna1.


START-OF-SELECTION.

  SELECT * FROM  kna1 INTO TABLE gt_kna1.



  go_struct ?= cl_abap_structdescr=>describe_by_name( 'KNA1' ).




  LOOP AT gt_kna1 ASSIGNING <gs_kna1>.

    LOOP AT go_struct->components INTO gs_comp
            WHERE ( type_kind NE 'P' ). " exclude non-Charlike
      ASSIGN COMPONENT gs_comp-name OF STRUCTURE <gs_kna1>
                                    TO <gd_fld>.

      TRANSLATE <gd_fld> TO UPPER CASE.
    ENDLOOP.


  ENDLOOP.


END-OF-SELECTION.

Regards

Uwe

4 REPLIES 4
Read only

Former Member
0 Likes
562

1) DECLARE A TABLE with char data type only as -

data: begin of itab occurs 0,

p_char(150) type c,

end of itab. "length of p_char = sum of field lengths of KNA1 (which u require to transalate)..

2) fetch database valuse into this p_char string.

3) then u can translate p_char to upper case.

4) then use offset to move the corresponding fields to ur itab. like -

itab-kunnr = p_char+0(10).

itab-field2 = p_char+10(5).

modify itab index sy-tabix.

Read only

uwe_schieferstein
Active Contributor
0 Likes
563

Hello Ameer

Here is possible solution for your problem. You cannot skip the field-by-field step because you will get an error when translating fields of type 'P'.

*&---------------------------------------------------------------------*
*& Report  ZUS_SDN_UC_TRANSLATE
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  zus_sdn_uc_translate.


TYPE-POOLS: abap.


DATA:
  go_struct      TYPE REF TO cl_abap_structdescr,
  gs_comp        TYPE abap_compdescr,
  gt_kna1        TYPE STANDARD TABLE OF kna1.



FIELD-SYMBOLS:
  <gd_fld>       TYPE ANY,
  <gs_kna1>      TYPE kna1.


START-OF-SELECTION.

  SELECT * FROM  kna1 INTO TABLE gt_kna1.



  go_struct ?= cl_abap_structdescr=>describe_by_name( 'KNA1' ).




  LOOP AT gt_kna1 ASSIGNING <gs_kna1>.

    LOOP AT go_struct->components INTO gs_comp
            WHERE ( type_kind NE 'P' ). " exclude non-Charlike
      ASSIGN COMPONENT gs_comp-name OF STRUCTURE <gs_kna1>
                                    TO <gd_fld>.

      TRANSLATE <gd_fld> TO UPPER CASE.
    ENDLOOP.


  ENDLOOP.


END-OF-SELECTION.

Regards

Uwe

Read only

0 Likes
562

Hellow Uwe,

It is helped me to solve my problem. I have done little bit differently .Thanks a lot Uwe.

Regards,

Ameer.

Read only

Former Member
0 Likes
562

hi all,

the solution which is given is good..

but we need to move the nono-character fileds also.

so how can they be excluded as shoen in the sample code.

lohith