Code: Alles auswählen.
REPORT zzrwtest.
CLASS lcl_alpha DEFINITION FINAL.
PUBLIC SECTION.
METHODS main.
METHODS set_matnr
IMPORTING matnr TYPE matnr
RETURNING VALUE(ergebnis) type abap_bool.
ENDCLASS.
CLASS lcl_beta DEFINITION CREATE PRIVATE FINAL.
PUBLIC SECTION.
CLASS-METHODS get_instance
RETURNING VALUE(result) TYPE REF TO lcl_beta.
METHODS get_data
IMPORTING
bla TYPE char01
peng TYPE char01
RETURNING VALUE(result) TYPE mara.
METHODS get_matnr
RETURNING VALUE(result) TYPE matnr.
ENDCLASS.
CLASS lcl_alpha IMPLEMENTATION.
METHOD main.
DATA(ergebnis) = me->set_matnr( SWITCH #( lcl_beta=>get_instance( )->get_matnr( )
WHEN lcl_beta=>get_instance( )->get_data( bla = 'A' peng = 'B' )-matnr )
THEN lcl_beta=>get_instance( )->get_data( bla = 'A' peng = 'B' )-matnr )
ELSE SPACE ).
ENDMETHOD.
ENDCLASS.
CLASS lcl_beta IMPLEMENTATION.
METHOD get_data.
ENDMETHOD.
ENDCLASS.
Die Klasse LCL_BETA=>GET_INSTANCE( darf nicht mit "FOR TESTING" angelegt werden, da sie schon von Nicht-Testcoding referiert wird.