03-20-2007 12:55 PM
How can I check if there are any "live" controls in ABAP.
I have tried to use method cl_gui_cfw=>get_living_dynpro_controls, but it does not bring anything.
I might be using it for the wrong purpose?
Regards
03-26-2007 7:53 AM
Hello Johan
The possible reason why you do not get any results is demonstrated in the following sample report. Method cl_gui_cfw=>get_living_dynpro_controls only returns references to controls having lifetime = dynpro_lifetime (defined in type-pool CNTO).
*&---------------------------------------------------------------------*
*& Report ZUS_SDN_CHECK_CONTROLS *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
REPORT ZUS_SDN_CHECK_CONTROLS .
TYPE-POOLS: cnto.
DATA:
gt_list TYPE cnto_control_list,
go_docking TYPE REF TO cl_gui_docking_container,
go_docking1 TYPE REF TO cl_gui_docking_container.
START-OF-SELECTION.
" Create control using default lifetime
CREATE OBJECT go_docking
* EXPORTING
* LIFETIME = lifetime_default
EXCEPTIONS
OTHERS = 99.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
REFRESH: gt_list.
CALL METHOD cl_gui_cfw=>get_living_dynpro_controls
IMPORTING
control_list = gt_list.
DESCRIBE TABLE gt_list.
WRITE: / 'Living controls with default lifetime =', syst-tfill.
" Create control using dynpro lifetime
CREATE OBJECT go_docking1
EXPORTING
lifetime = cl_gui_container=>lifetime_dynpro
EXCEPTIONS
OTHERS = 99.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
REFRESH: gt_list.
CALL METHOD cl_gui_cfw=>get_living_dynpro_controls
IMPORTING
control_list = gt_list.
DESCRIBE TABLE gt_list.
WRITE: / 'Living controls with lifetime dynpro =', syst-tfill.
END-OF-SELECTION.
* NOTE: Coding of method cl_gui_cfw=>get_living_dynpro_controls:
*METHOD GET_LIVING_DYNPRO_CONTROLS.
** control_list
*
* DATA: L_PROGRAM TYPE SYST-REPID,
* L_STACKPOS TYPE I,
* L_LIFETIME type ty_CFW_LIFETIME.
*
* SYSTEM-CALL KERNEL_INFO 'DYNPRO_PROGRAM' L_PROGRAM.
* SYSTEM-CALL KERNEL_INFO 'DYNPRO_STACK_POS' L_STACKPOS.
**
* LOOP AT CFW_LIFETIMELIST INTO L_LIFETIME
* WHERE LIFETIME = CNTL_LIFETIME_DYNPRO " only dynpro
* " lifetime !!!
* AND DYNPRO_PROGRAM = L_PROGRAM
* AND DYNPRO_NR = SY-DYNNR
* AND STACKLEVEL = L_STACKPOS
* and not ref is initial.
* APPEND L_LIFETIME-REF TO CONTROL_LIST.
* ENDLOOP.
*
*ENDMETHOD.
Regards
Uwe
03-26-2007 7:53 AM
Hello Johan
The possible reason why you do not get any results is demonstrated in the following sample report. Method cl_gui_cfw=>get_living_dynpro_controls only returns references to controls having lifetime = dynpro_lifetime (defined in type-pool CNTO).
*&---------------------------------------------------------------------*
*& Report ZUS_SDN_CHECK_CONTROLS *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
REPORT ZUS_SDN_CHECK_CONTROLS .
TYPE-POOLS: cnto.
DATA:
gt_list TYPE cnto_control_list,
go_docking TYPE REF TO cl_gui_docking_container,
go_docking1 TYPE REF TO cl_gui_docking_container.
START-OF-SELECTION.
" Create control using default lifetime
CREATE OBJECT go_docking
* EXPORTING
* LIFETIME = lifetime_default
EXCEPTIONS
OTHERS = 99.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
REFRESH: gt_list.
CALL METHOD cl_gui_cfw=>get_living_dynpro_controls
IMPORTING
control_list = gt_list.
DESCRIBE TABLE gt_list.
WRITE: / 'Living controls with default lifetime =', syst-tfill.
" Create control using dynpro lifetime
CREATE OBJECT go_docking1
EXPORTING
lifetime = cl_gui_container=>lifetime_dynpro
EXCEPTIONS
OTHERS = 99.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
REFRESH: gt_list.
CALL METHOD cl_gui_cfw=>get_living_dynpro_controls
IMPORTING
control_list = gt_list.
DESCRIBE TABLE gt_list.
WRITE: / 'Living controls with lifetime dynpro =', syst-tfill.
END-OF-SELECTION.
* NOTE: Coding of method cl_gui_cfw=>get_living_dynpro_controls:
*METHOD GET_LIVING_DYNPRO_CONTROLS.
** control_list
*
* DATA: L_PROGRAM TYPE SYST-REPID,
* L_STACKPOS TYPE I,
* L_LIFETIME type ty_CFW_LIFETIME.
*
* SYSTEM-CALL KERNEL_INFO 'DYNPRO_PROGRAM' L_PROGRAM.
* SYSTEM-CALL KERNEL_INFO 'DYNPRO_STACK_POS' L_STACKPOS.
**
* LOOP AT CFW_LIFETIMELIST INTO L_LIFETIME
* WHERE LIFETIME = CNTL_LIFETIME_DYNPRO " only dynpro
* " lifetime !!!
* AND DYNPRO_PROGRAM = L_PROGRAM
* AND DYNPRO_NR = SY-DYNNR
* AND STACKLEVEL = L_STACKPOS
* and not ref is initial.
* APPEND L_LIFETIME-REF TO CONTROL_LIST.
* ENDLOOP.
*
*ENDMETHOD.
Regards
Uwe