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

value not being passed in class implementation

Former Member
0 Likes
597

Hi All,

i tried to do this simple class program , i tried to pass a value 100 to a class and tried to display it in the screen.

the value is not being passed.




*---------------------------------------------------------------------*
*       CLASS ABC DEFINITION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS ABC DEFINITION.

  PUBLIC SECTION.
    DATA:  EID TYPE N.
    METHODS DISPLAY IMPORTING IM_EID TYPE N.

ENDCLASS.                    "ABC DEFINITION



*---------------------------------------------------------------------*
*       CLASS ABC IMPLEMENTATION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS ABC IMPLEMENTATION.

  METHOD DISPLAY.
    EID = IM_EID.
    WRITE: ' the number you entered is : ', EID.
  ENDMETHOD.                    "display

ENDCLASS.                    "ABC IMPLEMENTATION




START-OF-SELECTION.

  DATA VAR TYPE N.
  DATA: OBJ1 TYPE REF TO ABC.
  CREATE OBJECT OBJ1.

  CALL METHOD OBJ1->DISPLAY
    EXPORTING
      IM_EID = 100.


when i put a debug point at 'EID = IM_EID.' in the class implementation, here the value 100 from IM_EID is not passed to EID.

It is always showing EID value as 0,

does anyone know the reason, is there anything wrong in te declaration of EID.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
569

Vinay,

Guess the problem is with declaration of data object EID.. try...

Data EID(3) type N.

~Jose

3 REPLIES 3
Read only

Former Member
0 Likes
569

Try to pass the values directly to EID.

*---------------------------------------------------------------------*
*       CLASS ABC DEFINITION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS ABC DEFINITION.

  PUBLIC SECTION.
    DATA:  EID TYPE N.
    METHODS DISPLAY IMPORTING EID TYPE N.

ENDCLASS.                    "ABC DEFINITION



*---------------------------------------------------------------------*
*       CLASS ABC IMPLEMENTATION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS ABC IMPLEMENTATION.

  METHOD DISPLAY.
*    EID = EID.
    WRITE: ' the number you entered is : ', EID.
  ENDMETHOD.                    "display

ENDCLASS.                    "ABC IMPLEMENTATION




START-OF-SELECTION.

  DATA VAR TYPE N.
  DATA: OBJ1 TYPE REF TO ABC.
  CREATE OBJECT OBJ1.

  CALL METHOD OBJ1->DISPLAY
    EXPORTING
      EID = 100.

Check the above codes works

Regards,

Gurpreet

Read only

Former Member
0 Likes
570

Vinay,

Guess the problem is with declaration of data object EID.. try...

Data EID(3) type N.

~Jose

Read only

0 Likes
569

Hi jose,

you are right, i changed the declaration to EID(3) type N,

it is working,

and i also changed the declaration to EID type i,

then also it is working,

so it might be that when we are using type N, we should specify number of digits.

thanks for your time both of you.