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

concatenate question?

vsubbakrishna
Participant
0 Likes
1,393

existing data:

i_input_name( with only one field) contains 4 records

name1

name2

name3

name4

desired output should be a single line separated by ',' into another <b>itab2-result_line</b>

ie <b>itab2-result_line</b> = <b>name1,name2,name3,name4</b>

thanks,

subba

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,360

CONCATENATE NAME1 NAME2 NAME3 NAME4 INTO ITAB2-RESULT SEPARATED BY ','.

Max

existing data:

i_input_name( with only one field) contains 4 records

name1

name2

name3

name4

desired output should be a single line separated by ',' into another <b>itab2-result_line</b>

ie <b>itab2-result_line</b> = <b>name1,name2,name3,name4</b>

thanks,

subba

10 REPLIES 10
Read only

Former Member
0 Likes
1,361

CONCATENATE NAME1 NAME2 NAME3 NAME4 INTO ITAB2-RESULT SEPARATED BY ','.

Max

Read only

Former Member
0 Likes
1,360

Hello,

data: lv_text type string.

LOOP AT ITAB.

CONATENATE LV_TEXT ITAB-FIELD1 into LV_TEXT separeted by ','.

ENDLOOP:

If useful reward.

Vasanth

Read only

Former Member
0 Likes
1,360

hi,

Try this...........

DATA : BEGIN OF itab OCCURS 0,

name TYPE string,

END OF itab.

DATA result TYPE string.

itab-name = '1'.

APPEND itab.

itab-name = '2'.

APPEND itab.

itab-name = '3'.

APPEND itab.

itab-name = '4'.

APPEND itab.

LOOP AT itab.

IF sy-tabix = 1.

CONCATENATE result itab-name INTO result.

ELSE.

CONCATENATE result itab-name INTO result SEPARATED BY ','.

ENDIF.

ENDLOOP.

WRITE result.

Regards

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,360

Loop at your internal table and check if the first record, if so, then simply move the value to RESULT, if not then concatenate the value with RESULT and seperate it with ','. See below.

Loop at i_input_name.

   if sy-tabix = 1.
      result = i_input_name-field.
  else.

 concatenate result i_input_name-field into result seperated by ','.
endif.

endloop.

write:/ result.

Regards,

Rich Heilman

Message was edited by:

Rich Heilman

Read only

Former Member
0 Likes
1,360

Please try this,


DATA: v_string TYPE string.
CONCATENATE LINES OF i_scarr INTO v_string SEPARATED BY ','.
WRITE:/ v_string.
* you can replace the v_string with your required internal table field

Regards

Kathirvel

Read only

Former Member
0 Likes
1,360

loop at i_input_name.

concatenate v_str i_input_name-<field> into v_str separated by ','.

endloop.

to remove ',' at the end.

v_strlen = strlen(v_str).

v_str = v_str+0(v_strlen).

Read only

Former Member
0 Likes
1,360
data : V_name type string.

loop at i_input_name.
 concatenate v_name i_input_name. separated by ','.
endloop.

v_len = strlen( v_name ). :  "to remove last comma
v_len = v_len - 1.
v_name = v_name+0(v_len).
Read only

vsubbakrishna
Participant
0 Likes
1,360

problem solved........pts assigned...

subba

Read only

vsubbakrishna
Participant
0 Likes
1,360

answered

Read only

Former Member
0 Likes
1,360

assign a variable name type string

concatenate name1 name2 name3 name4 into name.

bye