Application Development 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: 

an error about internal table

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

Former Member
0 Kudos

HI,

Change this

data itab type standard table of line with key table_line.

to

data itab type table of line.

Regards,

Atish

6 REPLIES 6

Former Member
0 Kudos

HI,

Change this

data itab type standard table of line with key table_line.

to

data itab type table of line.

Regards,

Atish

Former Member
0 Kudos

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.

Former Member
0 Kudos

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

varma_narayana
Active Contributor
0 Kudos

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.

Former Member
0 Kudos

Hi

declare line of type itab and use

both should be of same type

Regards

Anji

JozsefSzikszai
Active Contributor
0 Kudos

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