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/
,如需转载,请注明出处,否则将追究法律责任。