ITPub博客

首页 > Linux操作系统 > Linux操作系统 > use internal table for select

use internal table for select

原创 Linux操作系统 作者:hekexi316 时间:2010-07-22 14:33:23 0 删除 编辑
Let us to compare the following two programs.
They are almost same , but are different in fact。

resolve problem

error1 =>you cannot use an internal table as a work area.
error2 =>Incorrect nesting: For the statement "ENDSELECT", there is no open structure introduced by "SELECT"

So we can say, when you use the SELECT...ENDSELECT.you cannot use the internal table as work area.
is it correct?


SPAN { font-family: "Courier New"; font-size: 10pt; color: #000000; background: #FFFFFF; } .L1S32 { color: #3399FF; } .L1S33 { color: #4DA619; } .L1S52 { color: #0000FF; } REPORT  ZHKXDB002_SELECT_COLUMNS.

DATA: itab TYPE STANDARD TABLE OF spfli.
DATA: wa LIKE LINE OF itab.

SELECT carrid connid cityfrom cityto
  INTO CORRESPONDING FIELDS OF TABLE itab
  FROM spfli
  WHERE carrid EQ 'LH'.

IF sy-subrc = 0.
  LOOP AT itab INTO wa.
    WRITE: / wa-carrid, wa-connid, wa-cityfrom, wa-cityto.
  ENDLOOP.
ENDIF.

*!!!comment the following lines when you run the programs
WRITE: / '-------------------------------------------------'.
SELECT carrid connid cityfrom cityto
  INTO CORRESPONDING FIELDS OF  itab "no [TABLE]=>error1
*INTO CORRESPONDING FIELDS OF TABLE itab "=>error2
  FROM spfli
  WHERE carrid = 'LH'.
  
  WRITE: / sy-dbcnt,
          wa-carrid, wa-connid, wa-cityfrom, wa-cityto.

ENDSELECT.



====================================
SPAN { font-family: "Courier New"; font-size: 10pt; color: #000000; background: #FFFFFF; } .L1S31 { font-style. italic; color: #808080; } .L1S33 { color: #4DA619; } .L1S52 { color: #0000FF; } REPORT  ZHKXDB003_SELECT_ALLCOLUMNS.

DATA: wa TYPE spfli.

SELECT *
  INTO CORRESPONDING FIELDS OF wa "no error, the type of wa is spfli,not STANDARD TABLE OF spfli.
  FROM spfli
  WHERE carrid = 'LH'.

  WRITE: / sy-dbcnt,
            wa-carrid, wa-connid, wa-cityfrom, wa-cityto.

ENDSELECT.


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/13895577/viewspace-668755/ ,如需转载,请注明出处,否则将追究法律责任。

下一篇: Memo
请登录后发表评论 登录
全部评论

注册时间:2008-05-02

  • 博文量
    38
  • 访问量
    57870