<type table =“”>不是内部表OCCURS n规范缺失</type>

时间:2015-03-09 00:36:55

标签: sap abap

我有这个方法

enter image description here

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.

当我尝试检查时,会显示以下错误:

enter image description here

我应该将et_flights声明为内部表吗? - 这是NetWeaver中示例Flight Model中的一个类。

有人可以帮我这个吗?

3 个答案:

答案 0 :(得分:3)

您可能已将et_flights参数定义为SFLIGHT类型。此类型是结构类型,即使它同时定义透明表SFLIGHT。我同意这对新秀来说可能有点混乱。

对于et_flights,请使用行结构为SFLIGHT的已有字典表类型,例如FLIGHTTAB

如果您只预测SFLIGHT的一部分属性,则必须使用INTO CORRESPONDING FIELDS OF TABLE et_flights代替INTO TABLE et_flights

答案 1 :(得分:1)

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

如果您决定将其作为返回值,则必须先在类定义中或在其外部声明类型,如下所示;

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.

希望它有所帮助。

答案 2 :(得分:0)

试试这个:

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.