*&---------------------------------------------------------------------*
*& Report YSAP_CONSTRUCTOR
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ysap_constructor.
TABLES: pa0002.
PARAMETERS: pernr TYPE pa0002-pernr.
*----------------------------------------------------------------------*
* CLASS class1 DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS class1 DEFINITION.
PUBLIC SECTION.
DATA: BEGIN OF stru,
pernr TYPE pa0002-pernr,
vorna TYPE pa0002-vorna,
nachn TYPE pa0002-nachn,
begda TYPE pa0002-begda,
endda TYPE pa0002-endda,
END OF stru.
DATA: itab LIKE TABLE OF stru,
wa LIKE stru.
METHODS: constructor,
another.
ENDCLASS. "class1 DEFINITION
*----------------------------------------------------------------------*
* CLASS class1 IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS class1 IMPLEMENTATION.
METHOD constructor.
WRITE: / 'This is constructor method.' COLOR 6.
SELECT * FROM pa0002 INTO CORRESPONDING FIELDS OF TABLE itab WHERE pernr EQ pernr.
LOOP AT itab INTO wa.
WRITE: / wa-pernr, wa-vorna, wa-nachn, wa-begda, wa-endda.
ENDLOOP.
SKIP.
ENDMETHOD. "constructor
METHOD another.
WRITE: / 'this is another method' COLOR 5.
ENDMETHOD. "another
ENDCLASS. "class1 IMPLEMENTATION
start-of-selection.
data: object1 type ref to class1.
create object object1.
call method object1->another.
*& Report YSAP_CONSTRUCTOR
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ysap_constructor.
TABLES: pa0002.
PARAMETERS: pernr TYPE pa0002-pernr.
*----------------------------------------------------------------------*
* CLASS class1 DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS class1 DEFINITION.
PUBLIC SECTION.
DATA: BEGIN OF stru,
pernr TYPE pa0002-pernr,
vorna TYPE pa0002-vorna,
nachn TYPE pa0002-nachn,
begda TYPE pa0002-begda,
endda TYPE pa0002-endda,
END OF stru.
DATA: itab LIKE TABLE OF stru,
wa LIKE stru.
METHODS: constructor,
another.
ENDCLASS. "class1 DEFINITION
*----------------------------------------------------------------------*
* CLASS class1 IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS class1 IMPLEMENTATION.
METHOD constructor.
WRITE: / 'This is constructor method.' COLOR 6.
SELECT * FROM pa0002 INTO CORRESPONDING FIELDS OF TABLE itab WHERE pernr EQ pernr.
LOOP AT itab INTO wa.
WRITE: / wa-pernr, wa-vorna, wa-nachn, wa-begda, wa-endda.
ENDLOOP.
SKIP.
ENDMETHOD. "constructor
METHOD another.
WRITE: / 'this is another method' COLOR 5.
ENDMETHOD. "another
ENDCLASS. "class1 IMPLEMENTATION
start-of-selection.
data: object1 type ref to class1.
create object object1.
call method object1->another.
No comments:
Post a Comment