‎2007 Dec 13 3:36 PM
Hi all ,
i am new to oops , i want to print the table 5 in the output.
I have written the code under,
I cant understand why it is not executing.
I wil give u fuul points If u modify and make it work.
class sasi definition..
public section.
methods ravi.
data: h type i,
j type i value 1,
res type i.
endclass.
class sasi implementation.
method ravi.
do 10 times.
data h type i.
move 5 to h.
write:/ h , ' * ' , j , '=' , h*j.
enddo.
endmethod.
*
*
*start-of-selection.
*data obj type ref to sasi.
*create object type obj.
*call method obj->ravi.
endclass.
regards
Sashi
‎2007 Dec 13 3:42 PM
&----
*& Report Z_HOLA_MUNDO *
*& *
&----
*& *
*& *
&----
REPORT z_hola_mundo LINE-SIZE 80.
----
CLASS sasi DEFINITION
----
*
----
CLASS sasi DEFINITION..
PUBLIC SECTION.
METHODS ravi.
DATA: h TYPE i,
j TYPE i VALUE 1,
res TYPE i.
ENDCLASS. "sasi DEFINITION
----
CLASS sasi IMPLEMENTATION
----
*
----
CLASS sasi IMPLEMENTATION.
METHOD ravi.
DATA: x TYPE i.
DO 10 TIMES.
DATA h TYPE i.
MOVE 5 TO h.
x = h * j.
WRITE:/ h , ' * ' , j , '=' , x.
ENDDO.
ENDMETHOD. "ravi
ENDCLASS. "sasi IMPLEMENTATION
START-OF-SELECTION.
DATA obj TYPE REF TO sasi.
CREATE OBJECT obj.
CALL METHOD obj->ravi.
‎2007 Dec 13 3:42 PM
&----
*& Report Z_HOLA_MUNDO *
*& *
&----
*& *
*& *
&----
REPORT z_hola_mundo LINE-SIZE 80.
----
CLASS sasi DEFINITION
----
*
----
CLASS sasi DEFINITION..
PUBLIC SECTION.
METHODS ravi.
DATA: h TYPE i,
j TYPE i VALUE 1,
res TYPE i.
ENDCLASS. "sasi DEFINITION
----
CLASS sasi IMPLEMENTATION
----
*
----
CLASS sasi IMPLEMENTATION.
METHOD ravi.
DATA: x TYPE i.
DO 10 TIMES.
DATA h TYPE i.
MOVE 5 TO h.
x = h * j.
WRITE:/ h , ' * ' , j , '=' , x.
ENDDO.
ENDMETHOD. "ravi
ENDCLASS. "sasi IMPLEMENTATION
START-OF-SELECTION.
DATA obj TYPE REF TO sasi.
CREATE OBJECT obj.
CALL METHOD obj->ravi.
‎2007 Dec 13 3:42 PM
It's not syntax checking because you the statement <b>write h*j.</b> is not a valid ABAP statement. You need p = h * j. write p.
As the program stands it doesn't do anything. You've just got a local class.
You need to put the "start-of-selection" bit after the ENDCLASS, and even then, the syntax is <b> CREATE OBJECT obj.</b>
Do all of this and you'll have a syntactically correct program, rather like Francisco Javier Carrillo Maldonado's above. But it will only print out<b> 5 * 1 = 5</b> 10 times. Not the five times table.
matt