Skip to content

Instantly share code, notes, and snippets.

@furlan

furlan/ZP_HELLO_OO_6

Created Jan 29, 2012
Embed
What would you like to do?
ZP_HELLO_OO_6
*&---------------------------------------------------------------------*
*& Report ZP_HELLO_OO_5
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT zp_hello_oo_5 NO STANDARD PAGE HEADING.
*----------------------------------------------------------------------*
* CLASS lcl_hello DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_hello DEFINITION.
PUBLIC SECTION.
METHODS: constructor
IMPORTING
ic_name TYPE char30.
METHODS: set
IMPORTING
i_name TYPE char30,
get
RETURNING value(r_name) TYPE char30,
get_full_message
RETURNING value(r_message) TYPE string.
PRIVATE SECTION.
DATA: name TYPE char30.
ENDCLASS. "lcl_hello DEFINITION
*----------------------------------------------------------------------*
* CLASS lcl_hello IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_hello IMPLEMENTATION.
METHOD constructor.
CALL METHOD me->set
EXPORTING
i_name = ic_name.
ENDMETHOD. "constructor
METHOD set.
IF i_name = 'PROCEDURAL!!'.
me->name = 'I would say... I love OO!'.
ELSE.
me->name = i_name.
ENDIF.
ENDMETHOD. "set
METHOD get.
r_name = me->name.
ENDMETHOD. "get
METHOD get_full_message.
CONCATENATE 'Hello:' me->name INTO r_message SEPARATED BY space.
ENDMETHOD. "get_full_message
ENDCLASS. "lcl_hello IMPLEMENTATION
DATA: g_r_hello TYPE REF TO lcl_hello,
g_v_hello TYPE string.
PARAMETERS: p_name TYPE char30 DEFAULT 'World OO!!'.
START-OF-SELECTION.
CREATE OBJECT g_r_hello
EXPORTING
ic_name = p_name.
g_v_hello = g_r_hello->get_full_message( ).
WRITE: / g_v_hello.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment