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

an error about internal table

Former Member
0 Likes
938

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
Read only

Former Member
0 Likes
908

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
Read only

Former Member
0 Likes
909

HI,

Change this

data itab type standard table of line with key table_line.

to

data itab type table of line.

Regards,

Atish

Read only

Former Member
0 Likes
908

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.

Read only

Former Member
0 Likes
908

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

Read only

varma_narayana
Active Contributor
0 Likes
908

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.

Read only

Former Member
0 Likes
908

Hi

declare line of type itab and use

both should be of same type

Regards

Anji

Read only

JozsefSzikszai
Active Contributor
0 Likes
908

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