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 fields in loop.

0 Likes
2,670

Hello friends,

i wanted to concatenate fields on loop, here is my condition.

count1= 0.

count2 = 0.

loop at a into wa_a.

count1 = sy-tabix.

concatenate c d into e.

if count2 is lt count1.

     (here i want something like this)

     f = f and e.

endif.

endloop.

lets say loop executed two times.

first time           e = 'sap'    

second time      e = 'abap'.

finally f should be sap abap.

How to chase?? thanks in adv.

Regards.

2 REPLIES 2
Read only

henk_verdaasdonk4
Active Participant
0 Likes
891

Hi Praneeth,

Something like this?

DATA: LV_F TYPE STRING.

LOOP AT lt_a REFERENCE INTO DATA(LR_A).

LV_F = LV_F && LR_A->C && LR_A->D.

ENDLOOP.

I assume you wanted to do something with field in table A. Took those into the concatenate. Now output is without spaces. So you should add them add correct place if needed.

I'm not sure what you want to achieve with count1 and count2 so left that part out.

Cheers,
Henk

Read only

Former Member
0 Likes
891

Praneeth,

Inside the loop you can just write

concatenate f e into f separated by space. define f as string type.

Hope I answered you question .

Need much information on  the count1 and count2 conditions .

Thanks,

G