Could you explain me the difference? I understand that IS BOUND is to know if a reference holds an instance of an object. But using INITIAL appears to fulfill this requirement also, so there must be other difference I'm not seeing.
I've done this code for testing this and the output is
<b>INITIAL before CREATE OBJECT: TRUE
NOT BOUND before CREATE OBJECT: TRUE
INITIAL after CREATE OBJECT: FALSE
NOT BOUND after CREATE OBJECT: FALSE
INITIAL after CLEAR: TRUE
NOT BOUND after CLEAR: TRUE</b>
CLASS lcl_test DEFINITION. PUBLIC SECTION. DATA: atrib1 TYPE i. METHODS: constructor. ENDCLASS. "lcl_test DEFINITION *----------------------------------------------------------------------* * CLASS lcl_test IMPLEMENTATION *----------------------------------------------------------------------* * *----------------------------------------------------------------------* CLASS lcl_test IMPLEMENTATION. METHOD constructor. atrib1 = 1. ENDMETHOD. "lcl_test ENDCLASS. "lcl_test DEFINITION CONSTANTS: c_true TYPE string VALUE 'TRUE', c_false TYPE string VALUE 'FALSE'. DATA: o_test TYPE REF TO lcl_test, g_bool TYPE string. START-OF-SELECTION. IF o_test IS INITIAL. g_bool = c_true. ELSE. g_bool = c_false. ENDIF. WRITE: /,'INITIAL before CREATE OBJECT:',g_bool. IF o_test IS NOT BOUND. g_bool = c_true. ELSE. g_bool = c_false. ENDIF. WRITE: /,'NOT BOUND before CREATE OBJECT:',g_bool. ************************* CREATE OBJECT o_test. ************************* IF o_test IS INITIAL. g_bool = c_true. ELSE. g_bool = c_false. ENDIF. WRITE: /,'INITIAL after CREATE OBJECT:',g_bool. IF o_test IS NOT BOUND. g_bool = c_true. ELSE. g_bool = c_false. ENDIF. WRITE: /,'NOT BOUND after CREATE OBJECT:',g_bool. ************************* CLEAR o_test. ************************* IF o_test IS INITIAL. g_bool = c_true. ELSE. g_bool = c_false. ENDIF. WRITE: /,'INITIAL after CLEAR:',g_bool. IF o_test IS NOT BOUND. g_bool = c_true. ELSE. g_bool = c_false. ENDIF. WRITE: /,'NOT BOUND after CLEAR:',g_bool.
Could you please explain the difference?
Thanks
Message was edited by:
Alejandro Bindi