
An application that uses the ABAP Dictionary search help can find out whether it is running in the Web Dynpro environment by querying the attribute IS_ACTIVE of class CL_WEB_DYNRPO:
IF CL_WEB_DYNPRO=>is_active = abap_true. ... ELSE. ... ENDIF.