10-19-2007 1:47 PM
Dear all,
I wrote a following program, but got an error.
REPORT Z_SIMPLE_ITAB.
data : begin of line,
num type i,
sqr type i,
end of line.
data itab type standard table of line with key table_line.
do 5 times.
line-num = sy-index.
line-sqr = sy-index ** 2.
append line to itab.
enddo.
loop at itab into line.
write : / line-num,line-sqr.
endloop.
Error Message
A line of "ITAB" and "LINE" are not mutually convertible. In a Unicode
program "ITAB" must have the same structure layout as "LINE"
independent of the length of a Unicode character. Unicode character.
Thanks you
10-19-2007 1:51 PM
HI,
Change this
data itab type standard table of line with key table_line.
to
data itab type table of line.
Regards,
Atish
10-19-2007 1:51 PM
HI,
Change this
data itab type standard table of line with key table_line.
to
data itab type table of line.
Regards,
Atish
10-19-2007 1:52 PM
try declaration like this:
types: begin of tp_line,
num type i,
sqr type i,
end of tp_line.
data : itab type standard table of tp_line ,
line type tp_line.
clear line.
refresh itab.
do 5 times.
line-num = sy-index.
line-sqr = sy-index ** 2.
append line to itab.
enddo.
loop at itab into line.
write : / line-num,line-sqr.
endloop.
10-19-2007 1:53 PM
Hi John,
do like this
REPORT Z_SIMPLE_ITAB.
types : begin of ty_line,
num type i,
sqr type i,
end of ty_line.
data: itab type standard table of ty_line.
line type ty_line.
do 5 times.
line-num = sy-index.
line-sqr = sy-index ** 2.
append line to itab.
enddo.
loop at itab into line.
write : / line-num,line-sqr.
endloop.
<b>Reward for helpful answers</b>
Satish
10-19-2007 1:53 PM
Hi..
Change this way...
REPORT Z_SIMPLE_ITAB.
data : begin of line,
num type i,
sqr type i,
end of line.
<b>data itab LIKE standard table of line .</b>
do 5 times.
line-num = sy-index.
line-sqr = sy-index ** 2.
append line to itab.
enddo.
loop at itab into line.
write : / line-num,line-sqr.
endloop.
Reward if helpful.
10-19-2007 1:54 PM
Hi
declare line of type itab and use
both should be of same type
Regards
Anji
10-19-2007 1:54 PM
hi John,
you cannot create internal table this way. pls. try:
Type
TYPES : BEGIN OF ty_line,
num TYPE i,
sqr TYPE i,
END OF ty_line
Work area
DATA : gw_line TYPE ty_line
Internal table
DATA : gt_line TYPE TABLE OF ty_line.
ec