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

programming problem

Former Member
0 Likes
720

Hi Friends,

I have one problem in programming.

data: itab like table of kna1,

itab1 like table of kna1.

select * from kna1 into table itab where kunnr = s_kunnr.

now my data is in itab.

*now i wanted to do the loop for every record & transfer it to itab1.

    • i had already fetch the data in internal table itab_doc.

**just like

loop at itab into itab1 where kunnr = itab_doc-kunnr.

append itab to itab1.

endloop.

    • but here i m getting the error itab cannot be converted to the line type of itab1.

will u tell me how to resolve this???

8 REPLIES 8
Read only

Former Member
0 Likes
691

put like this

Message was edited by: Prabhu Peram

Read only

Former Member
0 Likes
691

Hello,

Please try like this

<b>data: itab like table of kna1 with header line,

itab1 like table of kna1 with header line.</b>

loop at itab into itab1 where kunnr = itab_doc-kunnr.

append itab to itab1.

endloop.

Reward if helps

Regards,

Krishna

Read only

Former Member
0 Likes
691

your problem is

loop at itab into itab1 where <b>kunnr = itab_doc-kunnr</b>.

append itab to itab1.

endloop.

u can replace

<b>kunnr = s_kunnr</b>

Read only

Former Member
0 Likes
691

hi,

Do like this.

data: itab like table of kna1,

itab1 like table of kna1.

<b>DAtA : wa_itab like kna1.</b>

select * from kna1 into table itab where kunnr = s_kunnr.

loop at itab into <b>wa_itab</b> where kunnr = itab_doc-kunnr.

append <b>wa_itab</b> to itab1.

endloop.

regards'

Ahasan

Read only

Former Member
0 Likes
691

Hi Salil,

data: itab type standard table of kna1,

itab1 type standard table of kna1,

wtab type kna1.

select * from kna1 into table itab where kunnr = s_kunnr.

loop at itab into wtab where kunnr = itab_doc-kunnr.

append wtab to itab1.

endloop.

Best regards,

Prashant

Read only

Former Member
0 Likes
691

better way is to use MOVE CORRESPONDING in this case

loop at itab into itab1 where kunnr = itab_doc-kunnr.
<b>MOVE CORRESPONDING ITAB TO ITAB1.
append itab1.</b>
endloop

Move CORRESPONDING will move all the fields which are same in both the tables.

Regards

srikanth

Read only

anversha_s
Active Contributor
0 Likes
691

hi salil.

this will work for u.

Tables : kna1.

data : itab like kna1 occurs 0 with header line,

itab1 like itab.

-ur select query-

if itab[] is not initial.

loop at itab where kunnr = itab_doc-kunnr.

append itab to itab1.

clear itab.

endloop.

endif.

rgds

anver

pls mark hlpful answers

Read only

Former Member
0 Likes
691

Hi,

use have to use header line

<b> data: itab like table of kna1 with header line,

itab1 like table of kna1 with header line.</b>Regards

amole