Application Development 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: 

How to move all fields data of structure or work area into one string ?

Former Member
0 Kudos

Hi All,

I am working on ECC 6.0.

I have a requirement to pass complete work area data into one field of type C length 322...

In SAP 4.7 we can simply Move wa_data to String.. But in ECC it gives error " Source and destination are not mutually convertible. In Unicode program must have same structure.

If any one is aware about this problem, please guide..

Thanks in advance..

Regards

Manglesh

5 REPLIES 5

Former Member
0 Kudos

Hi

u need to move field by field.

Max

0 Kudos

Thanks your suggestion.

I have some currency and quantity fields are also there. Is there any type casting possible for this to move into string.

Thanks

Manglesh

0 Kudos

Give the code which is causing the problem with the declarations.

Vijay.

0 Kudos

try:

data str type...

do.

assign component sy-index of structure itab to <f>.

if sy-subrc = 0.

concatenate str <f> into str.

else.

exit.

endif.

enddo.

hope that helps

Andreas

0 Kudos

Hi

Try something like this:

DATA: LT_STRUCT   TYPE REF TO CL_ABAP_STRUCTDESCR,
      W_COMPONENT TYPE abap_compdescr.

FIELD-SYMBOLS: <W_FIELD> TYPE ANY.

DATA: V_OFFSET TYPE I.

DATA: BEGIN OF ITAB,
        BUKRS TYPE BKPF-BUKRS,
        BELNR TYPE BKPF-BELNR,
        WRBTR TYPE BSEG-WRBTR,
        WAERS TYPE BKPF-WAERS,
        MENGE TYPE BSEG-MENGE,
        MEINS TYPE BSEG-MEINS,
      END OF ITAB.

DATA: C_STRING(250).

ITAB-BUKRS = '1000'.
ITAB-BELNR = '1234567890'.
ITAB-WRBTR = '100.20'.
ITAB-WAERS = 'EUR'.
ITAB-MENGE = '100'.
ITAB-MEINS = 'KG'.

LT_STRUCT ?= CL_ABAP_TYPEDESCR=>DESCRIBE_BY_DATA( ITAB ).

LOOP AT LT_STRUCT->COMPONENTS INTO W_COMPONENT.
  ASSIGN COMPONENT W_COMPONENT-NAME OF STRUCTURE ITAB TO <W_FIELD>.
  IF W_COMPONENT-type_kind = 'C'.
    DESCRIBE FIELD <W_FIELD> LENGTH W_COMPONENT-LENGTH IN CHARACTER MODE.
  ENDIF.
  MOVE <W_FIELD> TO C_STRING+V_OFFSET(W_COMPONENT-LENGTH).
  V_OFFSET = V_OFFSET + W_COMPONENT-LENGTH.

ENDLOOP.

WRITE C_STRING.

Max