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: 

Convert Internal table to string

Former Member
0 Kudos

Hi,

I have an internal table , i need to convert that to a string. How it can be done.

Sa_R

8 REPLIES 8

Former Member

data : v_string type string.

loop at itab.

concatenate itab-value v_string into v_string.

endloop.

write v_string.

0 Kudos

Mahesh,

I forget tell you that i am working in Unicode environment. so MOVE will not work

After making this string i need to pass CL_ABAP_GZIP to compress

Sa_R

0 Kudos

check with this FM

SOTR_SERV_TABLE_TO_STRING

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Something like this?



report zrich_0001 line-size 500.

data: it001 type table of t001 with header line.
data: string type string.

select * into table it001 from t001.


loop at it001.
 concatenate string it001 into string separated by ','.
endloop.
shift string left deleting leading ','.


write:/ string.

Regards

RIch Heilman

0 Kudos

Rich,

I tried with that , but system giving non compatible error

Sa_R

0 Kudos

Ok, how about moving one field at a time?



report zrich_0001 line-size 500.

data: it001 type table of t001 with header line.
data: string type string.
data: fldstr type string.
data: substr type string.
field-symbols: <fs>.

select * into table it001 from t001.


loop at it001.
  do.
    assign component sy-index of structure it001 to <fs>.
    if sy-subrc <> 0.
      exit.
    endif.
    fldstr = <fs>.
    concatenate substr fldstr into substr separated by space.
    shift substr left deleting leading space.
  enddo.
  concatenate string substr into string separated by ','.
endloop.
shift string left deleting leading ','.


write:/ string.

Regards,

RIch Heilman

0 Kudos

Simply You can use FM SOTR_SERV_TABLE_TO_STRING

Thanks

Seshu

0 Kudos

Seshu/Mahesh,

This fm only with type compatible structures , in unicode this will not work.

After using this fm it is giving dump in the following line


000420   * only one line of text   > directly into text-string
000430     if sy-tfill = 1.
000440       read table text_tab index 1.
     >       text = text_tab.
000460   * more than one line of text   > concatenate into text-string

Rich,

I need to use you logic to get this done. I try to avoid the loop . But there is no other way to avoid the loop, i have to go with loop.

Sa_R.