on 2024 Aug 27 5:07 PM
Hello.
I would like some help on how I can make two classes in code talk to each other, I want to create a Set Handeler of an ALV of a class that is further down in the code.
for exemple, in this code i have ALV in Report but i need set the handle in Control class, there are some on to call the method in below class in code?
CLASS cl_report DEFINITION.
PUBLIC SECTION.
METHODS: select,
display.
PRIVATE SECTION.
DATA: lt_mara TYPE TABLE OF mara.
ENDCLASS.
CLASS cl_report IMPLEMENTATION.
METHOD select.
SELECT *
FROM mara
INTO TABLE me->lt_mara.
ENDMETHOD.
METHOD display.
DATA: lo_alv TYPE REF TO cl_salv_table.
TRY.
cl_salv_table=>factory(
IMPORTING
r_salv_table = lo_alv
CHANGING
t_table = me->lt_mara ).
CATCH cx_salv_msg.
ENDTRY.
* Display ALV, verificando se deve ou não ser Popup.
IF lo_alv IS BOUND.
* DEFININ EVENTS
DATA: o_events TYPE REF TO cl_salv_events_table.
o_events = lo_alv->get_event( ).
SET HANDLER cl_control->handler FOR o_events.
lo_alv->display( ).
ENDIF.
ENDMETHOD.
ENDCLASS.
CLASS cl_control DEFINITION.
PUBLIC SECTION.
METHODS: constructor,
init,
handler FOR EVENT link_click OF cl_salv_events_table.
PRIVATE SECTION.
DATA: o_report TYPE REF TO cl_report.
ENDCLASS.
CLASS cl_control IMPLEMENTATION.
METHOD constructor.
CREATE OBJECT o_report.
ENDMETHOD.
METHOD init.
o_report->select( ).
o_report->display( ).
ENDMETHOD.
METHOD handler.
BREAK-POINT.
ENDMETHOD.
ENDCLASS.
INITIALIZATION.
DATA: o_cntr TYPE REF TO cl_control.
CREATE OBJECT o_cntr.
o_cntr->init( ).
Use a CLASS cl_control DEFINITION DEFERRED before using it in the first class.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
82 | |
12 | |
10 | |
10 | |
10 | |
9 | |
8 | |
7 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.