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

Conversion between single field and structure in unicode

Former Member
0 Likes
1,195

I need to do conversation between data, stored in large char variable, and structure, that consists not only from char fields. In non-Unicode system "MOVE charstring TO structure" worked fine, but now this way isn't possible.

How can change the code to make it compatible with unicode?

4 REPLIES 4
Read only

Former Member
0 Likes
779

Hi Aleksandr

I know it is pain taking but the way to go is explicitly moving to each field separately.

Eg:

    move: charstring+0(18) to struc-matnr,
              charstring+18(4) to struc-werks
    ------

Kind Regards

Eswar

Read only

uwe_schieferstein
Active Contributor
0 Likes
779

Hello Aleksandr

A more dynamic approach is demonstrated in the following sample coding:

DATA: 
  ls_struc      TYPE <your table/structure>,
  lt_dfies       TYPE ddfields,
  ls_dfies      TYPE dfies.

FIELD-SYMBOLS:
  <ld_fld>     TYPE any.

  CALL FUNCTION 'DDIF_FIELDINFO_GET'
    EXPORTING
      tabname              = <name of table/structure>
    TABLES
      DFIES_TAB            = lt_dfies
    EXCEPTIONS
      NOT_FOUND            = 1
      INTERNAL_ERROR       = 2
      OTHERS               = 3.
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
  

  LOOP AT lt_dfies INTO ls_dfies.
    ASSIGN COMPONENT (ls_dfies-fieldname) OF STRUCTURE ls_struc TO <ld_fld>.

   <ld_fld> = ld_string+ls_dfies-offset(ls_dfies-intlen).
  ENDLOOP.

This works fine for all character-based fields. However, I have not found yet an elegant solution if the field has <b>INTTYPE = 'P'</b> (e.g. QUAN or DEC fields) because there can be a difference in length between INTLEN and OUTPUTLEN.

Regards

Uwe

Read only

Former Member
0 Likes
779

But the problem is to do conversation exactly to the structure,that consists not only from char fields.

Read only

0 Likes
779

Hi Aleksandr

Please try as below:

1. Use FM: GET_COMPONENT_LIST to extract the structure definition. This FM will give us the details of the fields and their lengths.

2. Using the above info, we know where exactly we need to split the string to each individual field of the structure.

So by the above method, we can dynamically pass the data of the string to respective fields of the structure without going through more pain.

Hope this helps.

Kind Regards

Eswar