Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

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

Former Member
0 Kudos

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!

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Maja,

I suppose you are trying to do OO example given in SAPGenie.com.. I also tried it sometime ago...It was working properly... Maybe u must be having some small errors...

Do it like this..

1) <b>In the main program, just write this code.</b>

REPORT ZPROG_CARGO .

INCLUDE zbc404_hf_lcl_airplane.

  • Sub classes

INCLUDE zbc404_hf_lcl_passenger_plane.

INCLUDE zbc404_hf_lcl_cargo_plane.

DATA:

  • Type ref to sub classes. Note: It is not necesssary to make typeref to

  • the superclass

o_passenger_airplane TYPE REF TO lcl_passenger_airplane,

o_cargo_plane TYPE REF TO lcl_cargo_plane.

START-OF-SELECTION.

  • Display initial number of instances = 0

CALL METHOD lcl_airplane=>display_n_o_airplanes.

  • Create objects

CREATE OBJECT o_passenger_airplane

EXPORTING

im_name = 'LH505'

im_planetype = 'Boing 747'

im_n_o_seats = 350.

CREATE OBJECT o_cargo_plane

EXPORTING

im_name = 'AR13'

im_planetype = 'DC 3'

im_cargomax = 35.

  • Display attributes

CALL METHOD o_passenger_airplane->display_attributes.

CALL METHOD o_cargo_plane->display_attributes.

CALL METHOD lcl_airplane=>display_n_o_airplanes.

2) <b>Double click on the first include and create an include program. Write the following code...</b>

CLASS lcl_airplane DEFINITION.

PUBLIC SECTION.

TYPES: t_name(25) TYPE c.

METHODS:

constructor IMPORTING im_name TYPE t_name

im_planetype TYPE saplane-planetype,

display_attributes.

CLASS-METHODS:

display_n_o_airplanes.

PROTECTED SECTION.

  • Private attributes

DATA: name(25) TYPE c,

planetype TYPE saplane-planetype.

  • Private static attribute

CLASS-DATA n_o_airplanes TYPE i.

ENDCLASS.

CLASS lcl_airplane IMPLEMENTATION.

METHOD constructor.

name = im_name.

planetype = im_planetype.

  • Counts number of instances

n_o_airplanes = n_o_airplanes + 1.

ENDMETHOD.

METHOD display_attributes.

WRITE:/ 'Name:', name, 'Planetype:', planetype.

ENDMETHOD.

METHOD display_n_o_airplanes.

WRITE: / 'No. planes:', n_o_airplanes.

ENDMETHOD.

ENDCLASS.

3)<b> In the second include, write this code.</b>

CLASS lcl_passenger_airplane DEFINITION INHERITING FROM lcl_airplane.

PUBLIC SECTION.

METHODS:

constructor IMPORTING im_name TYPE t_name

im_planetype TYPE saplane-planetype

im_n_o_seats TYPE sflight-seatsmax,

  • Redefinition of superclass method display_attributes

display_attributes REDEFINITION.

PRIVATE SECTION.

DATA: n_o_seats TYPE sflight-seatsmax.

ENDCLASS.

CLASS lcl_passenger_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.

  • The redefined display_attributes method

METHOD display_attributes.

CALL METHOD super->display_attributes.

WRITE: / 'No. seats:', n_o_seats.

ENDMETHOD.

ENDCLASS.

4) <b>In the third include , write this code.</b>

CLASS lcl_cargo_plane DEFINITION INHERITING FROM lcl_airplane.

PUBLIC SECTION.

METHODS:

constructor IMPORTING im_name TYPE t_name

im_planetype TYPE saplane-planetype

im_cargomax type scplane-cargomax,

  • Redefinition of superclass method display_attributes

display_attributes REDEFINITION.

PRIVATE SECTION.

DATA:cargomax TYPE scplane-cargomax.

ENDCLASS.

CLASS lcl_cargo_plane IMPLEMENTATION.

METHOD constructor.

CALL METHOD super->constructor

EXPORTING im_name = im_name

im_planetype = im_planetype.

cargomax = im_cargomax.

ENDMETHOD.

METHOD display_attributes.

  • The redefined display_attributes method

CALL METHOD super->display_attributes.

WRITE: / 'Cargo max:', cargomax.

ENDMETHOD.

ENDCLASS.

5) <b>Activate everything and this will work..</b>

Regards,

SP.<b></b>

25 REPLIES 25

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Please post your code so we can take a look.

Regards,

Rich Heilman

former_member181962
Active Contributor
0 Kudos

POsting your code would help us to help you better.

0 Kudos

&----


*& Report ZBC404_88_MAIN *

*& *

&----


*& *

*& *

&----


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 lcl_passanger_airplane->display_attributes.

CALL METHOD lcl_cargo_airplane->display_attributes.

CALL METHOD lcl_airplane=>display_n_o_airplanes.

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.

&----


*& Report ZBC404_88_LCL_CARGO_PLANE *

*& *

&----


*& *

*& *

&----


*REPORT zbc404_88_lcl_cargo_plane.

----


  • 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.

&----


*& Report ZBC404_88_LCL_PASSANGER_PLANE *

*& *

&----


*& *

*& *

&----


*REPORT zbc404_88_lcl_passanger_plane.

----


  • 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.

0 Kudos

Not sure since I don't have your includes, but it seems that you are missing the ENDCLASS at the bottom of the program.




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.
  
<b>endclass.</b>

Regards,

Rich Heilman

0 Kudos

no, no it is there...

i didn't copy/paste it.

my bad!

0 Kudos
*---------------------------------------------------------------------*
* 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. 
<b>endcalss.</b>

<<<<<----this is missing really or forgot to post it.

regards

vijay

0 Kudos

Also, these should be referenceing the object, right?

  call method <b>ref_lcl_passanger_airplane-></b>display_attributes.

  call method <b>ref_lcl_cargo_airplane-></b>display_attributes.

  call method lcl_airplane=>display_n_o_airplanes.

It is working good for me now.

Regards,

Rich Heilman

0 Kudos

Check this out..

REPORT zbc404_88_main.

*INCLUDE zbc400_88_lcl_airplane.

*INCLUDE zbc404_88_lcl_passanger_plane.

*INCLUDE zbc404_88_lcl_cargo_plane.

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.

&----


*& Report ZBC404_88_LCL_CARGO_PLANE *

*& *

&----


*& *

*& *

&----


*REPORT zbc404_88_lcl_cargo_plane.

----


  • 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.

&----


*& Report ZBC404_88_LCL_PASSANGER_PLANE *

*& *

&----


*& *

*& *

&----


*REPORT zbc404_88_lcl_passanger_plane.

----


  • 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.

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.

0 Kudos

no, no.

this part is ref obj.

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.

and this one is calling methods for displaying attributes:

CALL METHOD lcl_passanger_airplane->display_attributes.

CALL METHOD lcl_cargo_airplane->display_attributes.

0 Kudos

Change them to

CALL METHOD

<b>ref_</b>lcl_passanger_airplane->display_attributes.

CALL METHOD <b>ref_</b>lcl_cargo_airplane->display_attributes.

as the objects are created as ref_lcl_passanger_airplane and ref_lcl_cargo_airplane, you can't refer to them as lcl_passanger_airplane and

lcl_cargo_airplane

0 Kudos

The way that this is coded, with the ->, you are saying that these are instances methods. If that is the case you need to be calling them from the object, not the static class. So, to fix this you either have to make them static methods and use the =>, or change the statements to use the objects that you created previously.

CALL METHOD <b>ref_lcl</b>_passanger_airplane->display_attributes.

CALL METHOD <b>ref_</b>lcl_cargo_airplane->display_attributes.


or



CALL METHOD lcl_passanger_airplane<b>=></b>display_attributes.

CALL METHOD lcl_cargo_airplane<b>=></b>display_attributes.


Regards,

Rich Heilman

0 Kudos

CALL METHOD lcl_airplane=>display_n_o_airplanes.

this one is static.

0 Kudos

Yes, that is the only one that is static. So that call is ok. In the definition, you have that method defined as a CLASS-METHOD, which means its static, and can be called that.


* In your class def
<b>CLASS-METHODS:</b> display_n_o_airplanes.



* It can be called like this.
CALL METHOD lcl_airplane=>display_n_o_airplanes.


Regards,

Rich Heilman

former_member181962
Active Contributor
0 Kudos

YOu are missing an <b>endclass</b> statement for the last class implementation.

Former Member
0 Kudos

are you calling STATIC methods here,

CALL METHOD lcl_passanger_airplane->display_attributes.

CALL METHOD lcl_cargo_airplane->display_attributes.

CALL METHOD lcl_airplane=>display_n_o_airplanes.

Then it should be

CALL METHOD lcl_passanger_airplane<b>=></b>display_attributes.

or it is instance method:

CALL METHOD REF_LCL_PASSANGER_AIRPLANE->DISPLAY_ATTRIBUTES.

Former Member
0 Kudos

Hi,

Where have you defined the method display_attributes?

Thanks

Aswin

Sorry..please ignore.

0 Kudos

METHOD display_attributes.

WRITE: / 'Name of the airplane: '(001), AT pos_1 name,

/ 'Plane type: '(002), AT pos_1 planetype.

ENDMETHOD.

in lcl_airplane class.

Former Member
0 Kudos

Hi Maja,

I suppose you are trying to do OO example given in SAPGenie.com.. I also tried it sometime ago...It was working properly... Maybe u must be having some small errors...

Do it like this..

1) <b>In the main program, just write this code.</b>

REPORT ZPROG_CARGO .

INCLUDE zbc404_hf_lcl_airplane.

  • Sub classes

INCLUDE zbc404_hf_lcl_passenger_plane.

INCLUDE zbc404_hf_lcl_cargo_plane.

DATA:

  • Type ref to sub classes. Note: It is not necesssary to make typeref to

  • the superclass

o_passenger_airplane TYPE REF TO lcl_passenger_airplane,

o_cargo_plane TYPE REF TO lcl_cargo_plane.

START-OF-SELECTION.

  • Display initial number of instances = 0

CALL METHOD lcl_airplane=>display_n_o_airplanes.

  • Create objects

CREATE OBJECT o_passenger_airplane

EXPORTING

im_name = 'LH505'

im_planetype = 'Boing 747'

im_n_o_seats = 350.

CREATE OBJECT o_cargo_plane

EXPORTING

im_name = 'AR13'

im_planetype = 'DC 3'

im_cargomax = 35.

  • Display attributes

CALL METHOD o_passenger_airplane->display_attributes.

CALL METHOD o_cargo_plane->display_attributes.

CALL METHOD lcl_airplane=>display_n_o_airplanes.

2) <b>Double click on the first include and create an include program. Write the following code...</b>

CLASS lcl_airplane DEFINITION.

PUBLIC SECTION.

TYPES: t_name(25) TYPE c.

METHODS:

constructor IMPORTING im_name TYPE t_name

im_planetype TYPE saplane-planetype,

display_attributes.

CLASS-METHODS:

display_n_o_airplanes.

PROTECTED SECTION.

  • Private attributes

DATA: name(25) TYPE c,

planetype TYPE saplane-planetype.

  • Private static attribute

CLASS-DATA n_o_airplanes TYPE i.

ENDCLASS.

CLASS lcl_airplane IMPLEMENTATION.

METHOD constructor.

name = im_name.

planetype = im_planetype.

  • Counts number of instances

n_o_airplanes = n_o_airplanes + 1.

ENDMETHOD.

METHOD display_attributes.

WRITE:/ 'Name:', name, 'Planetype:', planetype.

ENDMETHOD.

METHOD display_n_o_airplanes.

WRITE: / 'No. planes:', n_o_airplanes.

ENDMETHOD.

ENDCLASS.

3)<b> In the second include, write this code.</b>

CLASS lcl_passenger_airplane DEFINITION INHERITING FROM lcl_airplane.

PUBLIC SECTION.

METHODS:

constructor IMPORTING im_name TYPE t_name

im_planetype TYPE saplane-planetype

im_n_o_seats TYPE sflight-seatsmax,

  • Redefinition of superclass method display_attributes

display_attributes REDEFINITION.

PRIVATE SECTION.

DATA: n_o_seats TYPE sflight-seatsmax.

ENDCLASS.

CLASS lcl_passenger_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.

  • The redefined display_attributes method

METHOD display_attributes.

CALL METHOD super->display_attributes.

WRITE: / 'No. seats:', n_o_seats.

ENDMETHOD.

ENDCLASS.

4) <b>In the third include , write this code.</b>

CLASS lcl_cargo_plane DEFINITION INHERITING FROM lcl_airplane.

PUBLIC SECTION.

METHODS:

constructor IMPORTING im_name TYPE t_name

im_planetype TYPE saplane-planetype

im_cargomax type scplane-cargomax,

  • Redefinition of superclass method display_attributes

display_attributes REDEFINITION.

PRIVATE SECTION.

DATA:cargomax TYPE scplane-cargomax.

ENDCLASS.

CLASS lcl_cargo_plane IMPLEMENTATION.

METHOD constructor.

CALL METHOD super->constructor

EXPORTING im_name = im_name

im_planetype = im_planetype.

cargomax = im_cargomax.

ENDMETHOD.

METHOD display_attributes.

  • The redefined display_attributes method

CALL METHOD super->display_attributes.

WRITE: / 'Cargo max:', cargomax.

ENDMETHOD.

ENDCLASS.

5) <b>Activate everything and this will work..</b>

Regards,

SP.<b></b>

0 Kudos

Hi!

i've done as u've said:

CALL METHOD ref_passenger_airplane->display_attributes.

CALL METHOD ref_cargo_plane->display_attributes.

instead of:

CALL METHOD passenger_airplane->display_attributes.

CALL METHOD cargo_plane->display_attributes.

but there is still the same error that points cursor on Includes ZBC404_88_<b>LCL_CARGO_PLANE</b>

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

any other suggestions?

0 Kudos

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 Kudos

really don't know what was wrong...

now i copied your's and is working fine for me 2!

Thank you Rich!

0 Kudos

I have been able to re-create your error. Please check and make sure that in all your includes that you have a ENDCLASS statement at the end of all of your class defintions and implementations. I took away the ENDCLASS statement at the end of the cargo include and I am now getting your error. Please check and make sure that all classes are ended with a ENDCLASS.

Regards,

Rich Heilman

Former Member
0 Kudos

Hi Maja,

Is your program working properly now??

Regards,

SP.

0 Kudos

it is working now. thanks 2 all!

p.s. sorry for opening another topic with the same subject...

Message was edited by: Maja Zugaj

0 Kudos

Glad that we got thru that! I'm almost convinced that you were missing an ENDCLASS in one of the includes, but anyway, it is working now. Good for you!

Regards,

Rich Heilman