Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

You may only define methods between "CLASS ... IMPLEMENTATION" and "ENDCLAS

Please help me!

i don't know what to do.

I've created 1 class and 2 subclasses. i've done exactly as it is in solutions but still i get the message:

<b>You may only define methods between "CLASS ... IMPLEMENTATION" and "ENDCLASS".</b>

in my DEFINITION part there are only PRIVATE, PUBLIC, PROTECTED attributes and methods and in my IMPLEMENTATION part there is definition od those methods but still i get this damn message. anyone any suggestion?

i can post my code if u would like ...

thanx!

Tags:
Former Member
replied

I have copied all of your code and even created the includes and put the corresponding code in the includes. I am not getting a syntax error. Here is the code. You must be missing something somewhere.

  • Main Program


report zbc404_88_main.

include zbc400_88_lcl_airplane.
include zbc404_88_lcl_passanger_plane.
include zbc404_88_lcl_cargo_plane.

data: ref_lcl_passanger_airplane type ref to lcl_passanger_airplane,
      ref_lcl_cargo_airplane type ref to lcl_cargo_airplane.

start-of-selection.

  call method lcl_airplane=>display_n_o_airplanes.

  create object ref_lcl_passanger_airplane exporting
         im_name = 'LH Berlin'
         im_planetype = '747-400'
         im_n_o_seats = 580.
  create object ref_lcl_cargo_airplane exporting
         im_name = 'US Hercules'
         im_planetype = 'Galaxy'
         im_cargo_max = 30000.

  call method ref_lcl_passanger_airplane->display_attributes.

  call method ref_lcl_cargo_airplane->display_attributes.

  call method lcl_airplane=>display_n_o_airplanes.

  • lcl_airplane includ


*----------------------------------------------------------------------*
*   INCLUDE ZBC400_88_LCL_AIRPLANE                                     *
*----------------------------------------------------------------------*

class lcl_airplane definition.

  public section.

    types: name_type(25) type c.
    constants: pos_1 type i value 30.

    methods: constructor importing
    im_name type name_type
    im_planetype type saplane-planetype,
    display_attributes.

*set_attributes IMPORTING im_name TYPE name_type
*im_planetype TYPE saplane-planetype

    class-methods: display_n_o_airplanes.

  protected section.
    data: name type name_type,
    planetype type saplane-planetype.

  private section.

    class-data: n_o_airplanes type i.

endclass.

*---------------------------------------------------------------------*
* CLASS lcl_airplane IMPLEMENTATION
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
class lcl_airplane implementation.

  method constructor.
    name = im_name.
    planetype = im_planetype.
    n_o_airplanes = n_o_airplanes + 1.
  endmethod.

*METHOD set_attributes.

*name = im_name.
*planetype = im_planetype.
*n_o_airplanes = n_o_airplanes + 1.

*ENDMETHOD.

  method display_attributes.

    write: / 'Name of the airplane: '(001), at pos_1 name,
    / 'Plane type: '(002), at pos_1 planetype.

  endmethod.

  method display_n_o_airplanes.
    write: /, / 'Total number of airplanes: '(ca1),
    at pos_1 n_o_airplanes left-justified, /.
  endmethod.

endclass.

  • lcl_passenger_airplane include.


*---------------------------------------------------------------------*
* CLASS lcl_passanger_airplane DEFINITION
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
class lcl_passanger_airplane definition inheriting from lcl_airplane.

  public section.

    methods: constructor importing
    im_name type name_type
    im_planetype type saplane-planetype
    im_n_o_seats type sflight-seatsmax,
    display_attributes redefinition.

  private section.

    data: n_o_seats type sflight-seatsmax.

endclass.

*---------------------------------------------------------------------*
* CLASS lcl_passanger_airplane IMPLEMENTATION
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
class lcl_passanger_airplane implementation.

  method constructor.

    call method super->constructor exporting
    im_name = im_name
    im_planetype = im_planetype.
    n_o_seats = im_n_o_seats.
  endmethod.

  method display_attributes.

    call method super->display_attributes.
    write: / 'Number of seats: '(003), 25 n_o_seats, /.

  endmethod.

endclass.


  • Lcl_cargo_airplane include


*---------------------------------------------------------------------*
* CLASS lcl_cargo_airplane DEFINITION
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
class lcl_cargo_airplane definition inheriting from lcl_airplane.

  public section.

    methods: constructor importing
    im_name type name_type
    im_planetype type saplane-planetype
    im_cargo_max type p,
    display_attributes redefinition.

  private section.
    data: cargo_max type scplane-cargomax.


endclass.

*---------------------------------------------------------------------*
* CLASS lcl_cargo_airplane IMPLEMENTATION
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
class lcl_cargo_airplane implementation.

  method constructor.

    call method super->constructor exporting
    im_name = im_name
    im_planetype = im_planetype.

    cargo_max = im_cargo_max.

  endmethod.

  method display_attributes.

    call method super->display_attributes.
    write: / 'Maximal cargo: '(004),
    at pos_1 cargo_max left-justified, /.

  endmethod.

endclass.


Again this is working great for me.

Regards,

Rich Heilman

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question