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: 

At end of

abdulazeez12
Active Contributor
0 Kudos

hii all

I have a itab with the following values:

col1 col2 col3

1 00278 msg1

1 00278 msg2

1 00278 msg3

1 00278 msg4

My requirement is to get all msg1 msg2 msg3 for col1 = 1 in one variable by concatenating..

can i use like this?

loop at itab.

at end of col1.

concatenate msg1 msg2 msg3 msg4 into msg.

endat.

endloop.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

You can write it as

DATA: lv_text(200) TYPE c.

sort itab by col1.

loop at itab.

at new col1.

CLEAR lv_text.

IF lv_text IS NOT INITIAL.

WRITE : lv_text.

ENDIF.

endat

concatenate lv_text itab-col3 INTO lv_text..

endloop.

Reward Points If helpfull.

5 REPLIES 5

Former Member
0 Kudos

Hi,

You can use like this,

Sort ITAB by COL1.

Loop at ITAB.

At New COL1.

WRITE:/ ITAB-COL1.

ENDAT.

write:/ ITAB-COL2,

ITAB-COL3.

ENDLOOP.

Please give the rewards points if it is usefull?...

0 Kudos

Thanks

but i dont want to write the output. i want to save it in a variable and then do further processing.

I want all the messags..msg1 msg2 msg3..into one variable for same col1 values..

how to do that?

Former Member
0 Kudos

You can write it as

DATA: lv_text(200) TYPE c.

sort itab by col1.

loop at itab.

at new col1.

CLEAR lv_text.

IF lv_text IS NOT INITIAL.

WRITE : lv_text.

ENDIF.

endat

concatenate lv_text itab-col3 INTO lv_text..

endloop.

Reward Points If helpfull.

Former Member
0 Kudos

Try this,

TABLES: SPFLI.

DATA: IT_SPFLI LIKE SPFLI OCCURS 0 WITH HEADER LINE.

SELECT * FROM SPFLI INTO TABLE IT_SPFLI.

SORT IT_SPFLI.

LOOP AT IT_SPFLI.

**************************************************************

*SHOW GRAND TOTAL TOP OF THE REPORT.

AT FIRST.

SUM.

WRITE:/ IT_SPFLI-DISTANCE COLOR 5.

ENDAT.

WRITE:/ IT_SPFLI-CARRID,

IT_SPFLI-DISTANCE.

*************************************************************

*************************************************************

*SHOW GRAND TOTAL END OF THE REPORT.

WRITE:/ IT_SPFLI-CARRID,

IT_SPFLI-DISTANCE.

AT LAST.

SUM.

WRITE:/ IT_SPFLI-DISTANCE COLOR 5.

ENDAT.

***************************************************************

*

***************************************************************

*GROUPS

AT NEW CARRID.

WRITE:/ IT_SPFLI-CARRID.

ENDAT.

WRITE:/ IT_SPFLI-DISTANCE.

***************************************************************

*

***************************************************************

*GROUPS AND SUBTOTAL

AT NEW CARRID.

WRITE:/ IT_SPFLI-CARRID.

ENDAT.

WRITE:/ IT_SPFLI-DISTANCE.

AT END OF CARRID.

SUM.

WRITE:/ IT_SPFLI-DISTANCE COLOR 5.

ENDAT.

Former Member
0 Kudos

Hi,

Hope this ll help

DATA: w_char(1000).

TYPES: BEGIN OF s_new,

col1(25),

col2(25),

col3(1000),

END OF s_new.

data: t_new TYPE STANDARD TABLE OF s_new with header line.

SORT t_itab BY col1.

LOOP AT t_itab.

AT NEW col1.

IF sy-tabix NE 1.

t_new-col3 = w_char.

APPEND t_new.

CLEAR t_new.

CLEAR w_char.

ENDIF.

t_new-col1 = t_itab-col1.

t_new-col2 = t_itab-col2.

ENDAT.

CONCATENATE w_char t_itab-col3 INTO w_char.

ENDLOOP.

IF w_char IS NOT INITIAL.

t_new-col3 = w_char.

APPEND t_new.

CLEAR t_new.

clear w_char.

endif.

Reward if helpful .

Regards,

Heera