‎2007 Jan 15 7:35 AM
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.
‎2007 Jan 15 8:47 AM
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
‎2007 Jan 15 7:54 AM
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.
‎2007 Jan 15 8:47 AM
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
‎2007 Jan 16 5:40 AM
Hellow Uwe,
It is helped me to solve my problem. I have done little bit differently .Thanks a lot Uwe.
Regards,
Ameer.
‎2007 Aug 01 12:06 PM
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