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

Add Internal Table Multiple Lines into Single Line

Former Member
0 Likes
3,677

Hi Gurus,

Before post this thread, i hav searched SDN but i could not find the exact solution.

I hav an internal table, i want to add the records of this internal table into single line (string variable), separated by tab operator.

can any one give me suggestions to solve this?

Thanks

Meher

Hi Gurus,

Before post this thread, i hav searched SDN but i could not find the exact solution.

I hav an internal table, i want to add the records of this internal table into single line (string variable), separated by tab operator.

can any one give me suggestions to solve this?

Thanks

Meher

3 REPLIES 3
Read only

Sm1tje
Active Contributor
0 Likes
1,468

use concatenate and cl_abap_char_utilities=>horizontal_tab

Roughly something like this:


do.
 assign component sy-index of structure <table_line> to <fs>
if sy-subrc is not initial.
exit.
endif.
concatenate lv_string <fs> into lv_string separated by cl_abap_char_utilities=>horizontal_tab
enddo.

Edited by: Micky Oestreich on Jul 3, 2009 5:42 PM

Read only

Former Member
0 Likes
1,468

Hi,

Program should be some thing like below:

-


REPORT  ZTEST36.
*-- test program to concatenate internal table to string.

DATA:STRING TYPE STRING.

TYPES:BEGIN OF TY_ITAB,
      WEEK(15),
      END OF TY_ITAB.

DATA:GT_ITAB TYPE STANDARD TABLE OF TY_ITAB WITH HEADER LINE.

CLEAR GT_ITAB.
GT_ITAB-WEEK = 'SUNDAY'.
APPEND GT_ITAB.

CLEAR GT_ITAB.
GT_ITAB-WEEK = 'MONDAY'.
APPEND GT_ITAB.

CLEAR GT_ITAB.
GT_ITAB-WEEK = 'TUESDAY'.
APPEND GT_ITAB.

CLEAR GT_ITAB.
GT_ITAB-WEEK = 'WEDNESDAY'.
APPEND GT_ITAB.

CLEAR GT_ITAB.
GT_ITAB-WEEK = 'THURSDAY'.
APPEND GT_ITAB.

CLEAR GT_ITAB.
GT_ITAB-WEEK = 'FRIDAY'.
APPEND GT_ITAB.

CLEAR GT_ITAB.
GT_ITAB-WEEK = 'SATURDAY'.
APPEND GT_ITAB.


CLEAR:GT_ITAB, STRING.
LOOP AT GT_ITAB.
  CONCATENATE STRING '/' GT_ITAB INTO STRING.
ENDLOOP.

WRITE: / STRING.
---------------------------------------------------------

Regards

Ramesh.

Moderator message - Ramesh - please use code tags

Edited by: Rob Burbank on Jul 3, 2009 12:26 PM

Read only

0 Likes
1,468

Thanks ramesh..

Probelm is solved.