Application Development and Automation 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: 
Read only

Field is unknow in the class

1190_5939_439
Active Participant
0 Likes
384

Hi Experts

I am ready for calulating ball volume, the code and screent is following . But there is some error that I don't define get_volumn.

Can you help me ? Thanks


REPORT zjgltest02.

CLASS ball DEFINITION.
  PUBLIC SECTION.
    CONSTANTS pi TYPE f VALUE '3.14'.
    METHODS: get_volumn IMPORTING VALUE(radius) TYPE i
                        RETURNING VALUE(volumn) TYPE f.

ENDCLASS.

CLASS ball IMPLEMENTATION.
  METHOD get_volumn.
    volumn = 4 * pi * radius  * radius * radius  / 3.
  ENDMETHOD.
ENDCLASS.

DATA:volumn   TYPE        f,
     ball_obj TYPE REF TO ball.
DATA:res TYPE p DECIMALS 2.
PARAMETERS:radius TYPE i.

START-OF-SELECTION.
  CREATE OBJECT ball_obj.
  volumn = ball_obj->get_volumn(radius).
  MOVE volumn TO res.
  WRITE:/res.
1 ACCEPTED SOLUTION
Read only

joltdx
Active Contributor
338

Hi!

Yes, whey you type

volumn = ball_obj->get_volumn(radius).

The systems thinks that get_volumn is a variable and that you want to specify the length to read with (radius). Instead, you need to include spaces around radius so it is interpreted as a method call:

volumn = ball_obj->get_volumn( radius ).

You also need to add spaces to the WRITE statement:

WRITE: / res.
1 REPLY 1
Read only

joltdx
Active Contributor
339

Hi!

Yes, whey you type

volumn = ball_obj->get_volumn(radius).

The systems thinks that get_volumn is a variable and that you want to specify the length to read with (radius). Instead, you need to include spaces around radius so it is interpreted as a method call:

volumn = ball_obj->get_volumn( radius ).

You also need to add spaces to the WRITE statement:

WRITE: / res.