‎2007 Jul 16 1:58 PM
Hi,
I created code like this:
CLASS item DEFINITION.
PUBLIC SECTION.
METHODS:
constructor IMPORTING matnr type matnr
sstuf type sstuf,
write_result.
PROTECTED SECTION.
DATA: matnr type matnr,
maktx type maktx.
METHODS: get_maktx,
get_stuff.
endclass.
class item implementation.
method constructor.
data: obiekt type ref to item.
me->matnr = matnr.
"me->sstuf = sstuf.
call method: get_maktx, get_stuff.
call method obiekt->write_result.
method get_maktx.
select single maktx from mara into maktx where matnr = 'A103'.
ENDMETHOD.
method get_stuff.
select single stuff from mara into stuff where matnr = 'A103'.
endmethod.
method write_result.
write: maktx, stuff.
uline.
endmethod.
endclass.
After F8 i get info that: "statement endmethod missing".
What should i change in code?
Regards,
Joanna
‎2007 Jul 16 2:10 PM
Well, your first problem is that you are missing the ENDMETHOD for your CONSTRUCTOR method, but you will have other problems as well.
class item implementation.
method constructor.
data: obiekt type ref to item.
me->matnr = matnr.
"me->sstuf = sstuf.
call method: get_maktx, get_stuff.
call method obiekt->write_result.
ENDMETHOD . " <------ RIGHT HERE
method get_maktx.
select single maktx from mara into maktx where matnr = 'A103'.
ENDMETHOD.
REgards,
RIch HEilman
‎2007 Jul 16 2:08 PM
Hi,
So is this a FORM or a method. You open with FORM, but close with END METHOD and END CLASS.
If it is a FORM, then end with an ENDFORM. If it is a method, then you must begin with a METHOD statement.
Refre the link:
https://forums.sdn.sap.com/click.jspa?searchID=3880163&messageID=3220888
<b>Reward points</b>
Regards
‎2007 Jul 16 2:10 PM
Well, your first problem is that you are missing the ENDMETHOD for your CONSTRUCTOR method, but you will have other problems as well.
class item implementation.
method constructor.
data: obiekt type ref to item.
me->matnr = matnr.
"me->sstuf = sstuf.
call method: get_maktx, get_stuff.
call method obiekt->write_result.
ENDMETHOD . " <------ RIGHT HERE
method get_maktx.
select single maktx from mara into maktx where matnr = 'A103'.
ENDMETHOD.
REgards,
RIch HEilman
‎2007 Jul 16 2:18 PM
This modified example, may help you further.
report zrich_0001 .
*---------------------------------------------------------------------*
* CLASS item DEFINITION
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
class item definition.
public section.
methods:
constructor importing matnr type matnr,
write_result.
protected section.
data: matnr type matnr,
maktx type maktx,
groes type groes.
methods: get_maktx,
get_groes.
endclass.
*---------------------------------------------------------------------*
* CLASS item IMPLEMENTATION
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
class item implementation.
method constructor.
me->matnr = matnr.
call method: get_maktx, get_groes.
call method me->write_result.
endmethod.
method get_maktx.
select single maktx
from makt into me->maktx
where matnr = me->matnr.
endmethod.
method get_groes.
select single groes from mara into groes
where matnr = me->matnr.
endmethod.
method write_result.
write:/ me->matnr, me->maktx, me->groes.
uline.
endmethod.
endclass.
data: o_ref type ref to item.
start-of-selection.
create object o_ref
exporting
matnr = 'A103'.
Regards,
RIch Heilman
‎2007 Jul 16 2:56 PM