我有这个方法
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声明为内部表吗? - 这是NetWeaver中示例Flight Model中的一个类。
有人可以帮我这个吗?
答案 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.