abap 内表的小问题
TYPES:BEGINOFline,column1TYPEi,column2TYPEi,column3TYPEi,ENDOFline.TYPESitabTYPElineO...
TYPES: BEGIN OF line,
column1 TYPE i,
column2 TYPE i,
column3 TYPE i,
END OF line.
TYPES itab TYPE line OCCURS 10.
DATA tab1 TYPE itab.
DATA tab2 LIKE tab1 WITH HEADER LINE.
line-column1 = 4.
line-column2 = 5.
line-column3 = 6.
append line to tab1.
LOOP AT tab1.
write: / tab1-column1, tab1-column2, tab1-column3.
ENDLOOP.
为什么会有错误???? 展开
column1 TYPE i,
column2 TYPE i,
column3 TYPE i,
END OF line.
TYPES itab TYPE line OCCURS 10.
DATA tab1 TYPE itab.
DATA tab2 LIKE tab1 WITH HEADER LINE.
line-column1 = 4.
line-column2 = 5.
line-column3 = 6.
append line to tab1.
LOOP AT tab1.
write: / tab1-column1, tab1-column2, tab1-column3.
ENDLOOP.
为什么会有错误???? 展开
2011-06-30
展开全部
data: BEGIN OF line,
column1 TYPE i,
column2 TYPE i,
column3 TYPE i,
END OF line.
DATA tab2 LIKE TABLE OF line WITH HEADER LINE.
line-column1 = 4.
line-column2 = 5.
line-column3 = 6.
append line to tab2.
LOOP AT tab2.
write: / tab2-column1, tab2-column2, tab2-column3.
ENDLOOP.
用F1帮助去查查TYPES与DATA的语法。
column1 TYPE i,
column2 TYPE i,
column3 TYPE i,
END OF line.
DATA tab2 LIKE TABLE OF line WITH HEADER LINE.
line-column1 = 4.
line-column2 = 5.
line-column3 = 6.
append line to tab2.
LOOP AT tab2.
write: / tab2-column1, tab2-column2, tab2-column3.
ENDLOOP.
用F1帮助去查查TYPES与DATA的语法。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你是报什么错误,是loop报错了吗?
代码改成这样试试,这样定义工作区域和内部表是目前最标准的写法!
TYPES: BEGIN OF ty_line,
column1 TYPE i,
column2 TYPE i,
column3 TYPE i,
END OF ty_line.
data wa_line type ty_line. line是工作区域
data it_itab1 type standard table of ty_line. itab是内部表
wa_line-column1 = 4.
wa_line-column2 = 5.
wa_line-column3 = 6.
append wa_line to it_tab1.
loop at it_tab1 into wa_line.
write:/wa_column1,wa_column2,wa_column3,
endloop.
代码改成这样试试,这样定义工作区域和内部表是目前最标准的写法!
TYPES: BEGIN OF ty_line,
column1 TYPE i,
column2 TYPE i,
column3 TYPE i,
END OF ty_line.
data wa_line type ty_line. line是工作区域
data it_itab1 type standard table of ty_line. itab是内部表
wa_line-column1 = 4.
wa_line-column2 = 5.
wa_line-column3 = 6.
append wa_line to it_tab1.
loop at it_tab1 into wa_line.
write:/wa_column1,wa_column2,wa_column3,
endloop.
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
...........line 只是一个结构 但是还没定义成工作区间 还不能用。。。。。需要再data定义下。下面的loop at tab1 tab1只是一个没有表头的内表 是不能进行你代码里的操作的。帮你改了下
TYPES: BEGIN OF line,
column1 TYPE i,
column2 TYPE i,
column3 TYPE i,
END OF line.
TYPES itab TYPE line OCCURS 10 .
DATA tab1 TYPE itab WITH HEADER LINE .
DATA tab2 LIKE tab1 .
data line TYPE line.
line-column1 = 4.
line-column2 = 5.
line-column3 = 6.
append line to tab1.
LOOP AT tab1.
write: / tab1-column1, tab1-column2, tab1-column3.
ENDLOOP.
TYPES: BEGIN OF line,
column1 TYPE i,
column2 TYPE i,
column3 TYPE i,
END OF line.
TYPES itab TYPE line OCCURS 10 .
DATA tab1 TYPE itab WITH HEADER LINE .
DATA tab2 LIKE tab1 .
data line TYPE line.
line-column1 = 4.
line-column2 = 5.
line-column3 = 6.
append line to tab1.
LOOP AT tab1.
write: / tab1-column1, tab1-column2, tab1-column3.
ENDLOOP.
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询