‎2009 Mar 14 3:28 AM
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.
‎2009 Mar 14 5:28 AM
Vinay,
Guess the problem is with declaration of data object EID.. try...
Data EID(3) type N.~Jose
‎2009 Mar 14 4:44 AM
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
‎2009 Mar 14 5:28 AM
Vinay,
Guess the problem is with declaration of data object EID.. try...
Data EID(3) type N.~Jose
‎2009 Mar 14 1:07 PM
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.