Here we define a class which creates different types of instances of cl_animal class and the advantage on this is that we can use the cl_introduce class to act on any child class of cl_animal type. The purpose is to not change the interface and use a common procedure that is going to be prepared to function on these classes.
Finally the code ends like this:
start-of-selection. data wa_animal type ref to cl_animal. wa_animal = cl_animal_factory=>create_animal( 1 ). cl_introducer=>introduce( wa_animal ). " The i_animal parameter is implicitly specified. Useful when is only one parameter. write /. wa_animal = cl_animal_factory=>create_animal( 2 ). cl_introducer=>introduce( i_animal = wa_animal ). " The i_animal parameter is explicitly specified and is necessary its use when is more than one paramter. write /. wa_animal = cl_animal_factory=>create_animal( 3 ). cl_introducer=>introduce( wa_animal ). Serkan AKKAVAK Computer Engineer ABAP Developer & SAP S/4 HANA Logistics Team Lead Contact : serkurumsal@yandex.com |
Social Plugin