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

fill a table with table type

Former Member
0 Likes
948

Hi guys,

can please anybody tell me how can I insert a new record to a table which associated type referred to a table type. I have an internal table i_tab and I need to copy the content of the i_tab in to a result_tab which is defined in my function in the interface as a table with associated type referred to an table type.

Thanks

Kami

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
804

Hi,

LOOP AT i_tab

MOVE i_tab-fld1 TO result_tab-fld1.

MOVE i_tab-fld2 TO result_tab-fld2.

MOVE i_tab-fld3 TO result_tab-fld3.

APPEND result_tab.

ENDLOOP.

OR

LOOP AT i_tab

result_tab-fld1 = i_tab-fld1.

result_tab-fld2 = i_tab-fld2.

result_tab-fld3 = i_tab-fld3.

APPEND result_tab.

ENDLOOP.

Regards,

Harish

4 REPLIES 4
Read only

Former Member
0 Likes
804

hii

loop at itab

read table itab with key .... int result_tab.

append result_tab.

Read only

Former Member
0 Likes
805

Hi,

LOOP AT i_tab

MOVE i_tab-fld1 TO result_tab-fld1.

MOVE i_tab-fld2 TO result_tab-fld2.

MOVE i_tab-fld3 TO result_tab-fld3.

APPEND result_tab.

ENDLOOP.

OR

LOOP AT i_tab

result_tab-fld1 = i_tab-fld1.

result_tab-fld2 = i_tab-fld2.

result_tab-fld3 = i_tab-fld3.

APPEND result_tab.

ENDLOOP.

Regards,

Harish

Read only

0 Likes
804

Thanks to all of you.

Cheers!

Kami

Read only

Former Member
0 Likes
804

Hi,

1. define the result_tab TYPE associated type referred to an table type (refered in FM).

2. define ITAB1 TYPE TABLE OF <Line type of that table type> with header line.

3. Move the content from your internal table (i_tab) to ITAB1.

(Using loop and move the correponding fields)

4. Then RESULT_TAB[] = ITAB1[] .

Regards,

Prem