<type table> 不是内部 table OCCURS n 规范缺失

<type table> is not an internal table OCCURS n specification is missing

我有这个方法

METHOD get_flights_range.

   DATA ls_flight TYPE sflight.

   CALL METHOD check_authority
    EXPORTING
      iv_carrid   = iv_carrid
      iv_activity = gc_auth_display.

  SELECT carrid connid fldate seatsmax seatsocc
         FROM sflight
         INTO TABLE et_flights
         WHERE carrid  = iv_carrid
           AND connid IN it_connid.

  IF sy-subrc <> 0.
    RAISE EXCEPTION TYPE zcx_bcuser_no_data.
  ELSE.
    SORT et_flights BY percentage.
    LOOP AT et_flights INTO ls_flight.
      ls_flight-percentage = ls_flight-seatsocc / ls_flight-seatsmax * 100.
      MODIFY  et_flights
        FROM  ls_flight
        INDEX sy-tabix
        TRANSPORTING percentage.
    ENDLOOP.

    SORT et_flights BY percentage DESCENDING.

  ENDIF.

ENDMETHOD.

当我尝试检查时,它显示此错误:

我应该将 et_flights 声明为内部 table 吗? --这是来自 NetWeaver 中的示例飞行模型的 class。

有人可以帮我解决这个问题吗?

我没有看到你的所有代码,但是是的,你应该声明它。您可以在方法内部声明它,在 class 定义中作为 class 的私有成员或方法的 return 值。

如果您决定将其作为 return 值,您必须首先在 class 定义中或定义之外声明一个类型,如下所示;

class myclass definition.
public section.
  types ty_mytable type standard table of sflight.
  methods mymethod exporting mydata type ty_mytable.
endclass.

class myclass implementation.
  method mymethod.
    select * from sflight into table mydata. 
  endmethod.
endclass.

希望对您有所帮助。

您可能将 et_flights 参数定义为 SFLIGHT 类型。这种类型是结构类型,尽管它同时定义了透明table SFLIGHT。我同意这对于菜鸟来说可能有点令人困惑。

对于 et_flights 使用行结构为 SFLIGHT 的现有字典 table 类型,例如 FLIGHTTAB.

如果您只投影 SFLIGHT 的属性子集,则必须使用 INTO CORRESPONDING FIELDS OF TABLE et_flights 代替 INTO TABLE et_flights

试试这个:

types : begin of Zflight , 
          Carrid like sflight-carrid , 
          connid like sflight-connid ,
          fldate like sflight-fldate ,
          seatmax like sflight-seatmax , 
          seatsocc like sflight-seatsocc , 
        end of zflight . 

data : et_flights type table zflight . 

SELECT carrid connid fldate seatsmax seatsocc
  FROM sflight
  INTO TABLE et_flights
 WHERE carrid  = iv_carrid
   AND connid IN it_connid.