FM to check if Gui is active :
DATA : lw_gui_actif TYPE c.
CALL FUNCTION 'GUI_IS_AVAILABLE'
IMPORTING
return = lw_gui_actif.
FM to check if code is executed in dialog mode :
DATA : lw_is_dialog TYPE xfeld.
CALL FUNCTION 'ZFM_CHECK_DIALOG_MODE'
IMPORTING
ew_is_dialog = lw_is_dialog. " = X si en mode Dialog, vide sinon
Code for FM ZFM_CHECK_DIALOG_MODE :
*"----------------------------------------------------------------------
*"*"Interface locale :
*" EXPORTING
*" REFERENCE(EW_IS_DIALOG) TYPE XFELD
*"----------------------------------------------------------------------
DATA : lw_type TYPE xuustyp.
ew_is_dialog = 'X'.
" Get User type (A : dialog mode)
" -------------------------------
CLEAR lw_type.
SELECT SINGLE ustyp INTO lw_type FROM usr02 WHERE bname = sy-uname.
IF lw_type NE 'A'.
ew_is_dialog = ''.
RETURN.
ENDIF.
" Check dialog mode (Not batch, Not RFC, not background mode)
" -----------------------------------------------------------
IF NOT ( sy-batch IS INITIAL
AND sy-binpt IS INITIAL
AND sy-callr IS INITIAL ).
ew_is_dialog = ''.
ENDIF.
Search tag: SAPGUI, SAP-GUI
About the author