Check in CRM if program running in dialog mode

Problem: you want to check if your code is executed in the dialog mode or not.

Solution: There is an easy way to do it in the CRM. Simply call FM COM_PARTNER_DIALOG_MODE_CHECK and it will return proper information.

CALL FUNCTION 'COM_PARTNER_DIALOG_MODE_CHECK'
  EXCEPTIONS
    no_dialog = 1
    OTHERS    = 2.
IF sy-subrc = 0.
  " dialog mode
ELSEIF sy-subrc = 1.
  " no dialog mode
ELSE.
  " error
  MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CALL FUNCTION 'COM_PARTNER_DIALOG_MODE_CHECK'
  EXCEPTIONS
    no_dialog = 1
    OTHERS    = 2.
IF sy-subrc = 0.
  " dialog mode
ELSEIF sy-subrc = 1.
  " no dialog mode
ELSE.
  " error
  MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.

Additionally you can always check SY-BATCH value.

Komentowanie jest zakończone.