Rafael Reyes
Rafael Reyes

Reputation: 2655

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

I have this method

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.

and when I try to check it displays this error:

enter image description here

Should I declare et_flights as an internal table? --this is a class from the example Flight Model in NetWeaver.

Can someone help me with this?

Upvotes: 1

Views: 22784

Answers (3)

Mostafa Saleh
Mostafa Saleh

Reputation: 21

Try this:

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.

Upvotes: 0

Jagger
Jagger

Reputation: 10524

You probably defined the et_flights parameter as of type SFLIGHT. This type is a structure type even though it defines the transparent table SFLIGHT at the same time. I agree that this might be a little bit confusing for a rookie.

For et_flights use an already available dictionary table type with row structure of SFLIGHT, for example FLIGHTTAB.

If you are projecting just a subset of the attributes from SFLIGHT you will have to use INTO CORRESPONDING FIELDS OF TABLE et_flights in place of INTO TABLE et_flights.

Upvotes: 3

Nelson Miranda
Nelson Miranda

Reputation: 5554

I don't see all of your code but yes, you shoud declare it. You could declare it inside the method, in the class definition as a private member of the class or as a return value of the method.

If you decide to make it as a return value you must declare a type first in the class definition or outside of it, like this;

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.

Hope it helps.

Upvotes: 1

Related Questions