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

concatenating strings

Former Member
0 Likes
792

hi all,

i have a internal table ITAB with field ITYPE.it has 3 records as follows-----

ITAB-ITYPE = A

ITAB-ITYPE = B

ITAB-ITYPE = C.

i have another internal table JTAB with field JTYPE.it has 1 record as follows-----

JTAB-JTYPE = D.

now, my requirement i want all records of ITAB into JTAB as follows.

JTAB-JTYPE = D,A,B,C.

i used following code, but its not working--

loop at itab.

concatenate itab-itype into jtab-jtype seperated by ','.

endloop.

plz help me .

itz very urgent.

thanks,

Shivaa.

8 REPLIES 8
Read only

JozsefSzikszai
Active Contributor
0 Likes
770

hi Shiva,

LOOP AT jtab.

LOOP AT itab.

CONCATENATE jtab-jtype itab-itype INTO jtab-jtype SEPARATED BY ','.

ENDLOOP.

MODIFY jtab.

ENDLOOP.

hope this helps

ec

Read only

Former Member
0 Likes
770

Try this:

concatenate jtab_jtype itab-itype into jtab-jtype seperated by ','.

Read only

Former Member
0 Likes
770

Hey dude !!!

Loop at Itab.

read jtab index 1/ with key Id.( as per requirement)

concatenate jtab-jtype itab-itype into jtab-itype separated by ','.

append Jtab.

endloop.

For more on read operations , place cursor on read and press F1.

As far as my knowledge is, Using loop inside a loop is not a good programing practice.

This would solve your problem.

CHEERS

Read only

Former Member
0 Likes
770

hi,

Loop at Itab.

read jtab index 1 key (what are the other requirement)

concatenate jtab-jtype itab-itype into jtab-jtype separated by ','.

append Jtab.

endloop.

i hope it will help

regards,

mae

Read only

rxsalomone
Explorer
0 Likes
770

Try this:

read jtab index 1. "just one record in jtab

loop at Itab.

concatenate jtab-jtype itab-itype into jtab-jtype separated by ','.

endloop.

modify jtab.

I hope it will help

best regards,

Read only

Former Member
0 Likes
770

Try this code

DATA: w_itype TYPE string.

LOOP AT itab.
  CONCATENATE w_itype
              itab-itype
    INTO w_itype SEPARATED BY ','.
ENDLOOP.


READ TABLE jtab INDEX 1 TRANSPORTING jtype.

IF sy-subrc EQ 0.
  CONCATENATE jtab-jtype
              w_itype
    INTO jtab-jtype.
ENDIF.

CLEAR w_itype.

Read only

Former Member
0 Likes
770

Hi,

I think you need to have following code:

data: l_str type string.

loop at jtab. "If more than one records.

concatenate l_str jtab-jtype into l_str.

endloop.

loop at itab.

concatenate l_str itab-itype into l_str.

endloop.

Regards,

Dharitree

Read only

Former Member
0 Likes
770

Hi shiva,

Try this :

loop at itab.

read table jtab[] index 1.

concatenate itab-itype into jtab-jtype seperated by ','.

modify table jtab[] from jtab index 1.

endloop.

hope this helps you.

reward points if this helps.