09-24-2008 5:45 PM
Dear memebers,
I have a internal table with 2 fields,
1 AAA
2 BBB
3 CCC
I want to concatenate column 2 values, So that my result will be AAABBBCCC.
how can I achieve this. Thanks for looking into.
Regards
madhu
09-24-2008 5:48 PM
Hi, try this.
TYPES: BEGIN OF itab,
car1 TYPE c,
car2(3) TYPE c,
END OF itab.
... appear itab
DATA: l_string TYPE string,
LOOP AT itab INTO w_itab.
CONCATENATE l_string w_itab INTO l_string.
ENDLOOP.
Your output will be AAABBBCCC.
Thanks and Regards.
David Carballido
09-24-2008 5:48 PM
Hi, try this.
TYPES: BEGIN OF itab,
car1 TYPE c,
car2(3) TYPE c,
END OF itab.
... appear itab
DATA: l_string TYPE string,
LOOP AT itab INTO w_itab.
CONCATENATE l_string w_itab INTO l_string.
ENDLOOP.
Your output will be AAABBBCCC.
Thanks and Regards.
David Carballido
09-24-2008 8:10 PM
Thanks David and others,
got answer !! closing thread. allotting points for all the contributors.
Thanks
Madhu
09-24-2008 5:49 PM
09-24-2008 5:50 PM
What is your internal table structure?Mention it plz so that we can give an exact answer
09-24-2008 5:52 PM
Hello,
Try this.
types: begin of ty_itab,
f1 type i,
f2 type string,
end of ty_itab.
Data: itab type standard table of ty_itab,
wa_tab type ty_itab,
ws_c_result type string.
wa_tab-f1 = 1.
wa_tab-f2 = 'AAA'.
Append wa_tab to itab.
clear wa_tab.
wa_tab-f1 = 2.
wa_tab-f2 = 'BBB'.
Append wa_tab to itab.
clear wa_tab.
wa_tab-f1 = 3.
wa_tab-f2 = 'CCC'.
Append wa_tab to itab.
clear wa_tab.
sort itab by f2 descending.
LOOP AT itab into wa_tab .
Concatenate wa_tab-f2 ws_c_result into ws_c_result.
ENDLOOP.
Write:/ 'Result ',
ws_c_result.
You'll get the desired result.
Thanks and Regards,
Venkat Phani Prasad Konduri
09-24-2008 5:59 PM
Hello Madhu totikonda,
Concatenating means joining which can be achieved by combining the relevant fields for the final output.
Use this understand this concept
ITAB1 = value.
ITAB2 = value.
ITAB3 = value.
CONCATENATE ITAB1 VALUE INTO COMB1.
CONCATENATE ITAB2 VALUE INTO COMB2.
CONCATENATE ITAB3 VALUE INTO COMB3.
CONCATENATE ITAB1 ITAB2 ITAB3 INTO ITAB1.
Cheers!!
09-24-2008 7:30 PM
Hi ,
here i am writing code. U can use this.
DATA: BEGIN OF itab OCCURS 0,
f1 TYPE i,
f2 TYPE string,
END OF itab.
DATA: result TYPE string.
CLEAR itab,result.
REFRESH itab.
itab-f1 = 1.
itab-f2 = 'AAA'.
APPEND itab.
CLEAR itab.
itab-f1 = 2.
itab-f2 = 'BBB'.
APPEND itab.
CLEAR itab.
itab-f1 = 3.
itab-f2 = 'CCC'.
APPEND itab.
CLEAR itab.
LOOP AT itab.
CONCATENATE itab-f2 result INTO result.
ENDLOOP.
WRITE: / result.
regards,
Surendra babu vemula