Skip to Content
Technical Articles
Author's profile photo Amy King

Code Snippet Series: Determine the Client Environment

This post is part of a series on code snippets. The complete list of posts in the series is available in the document Code Snippets: A Blog Series.

Knowing the environment in which a Web Dynpro ABAP application is running is necessary if you want to branch logic or show or hide content depending on the client environment. An example is showing the user’s logon name in a header or a copyright notice in a footer when the application is running standalone but hiding these view elements when the application is running in the NetWeaver portal.

   DATA lo_wd_component TYPE REF TO if_wd_component.
   DATA lo_wd_application TYPE REF TO if_wd_application.
   DATA lv_client_environment TYPE i.

   lo_wd_component ?= wd_this->wd_get_api( ).
   lo_wd_application = lo_wd_component->get_application( ).
   lv_client_environment = lo_wd_application->get_client_environment( ).
   CASE lv_client_environment.

       WHEN if_wd_application=>co_client_environment-nwbc.
 *     NetWeaver Business Client

       WHEN if_wd_application=>co_client_environment-portal.
 *     NetWeaver Portal

       WHEN if_wd_application=>co_client_environment-sapgui.
 *     SAPgui

       WHEN if_wd_application=>co_client_environment-standalone.
 *     Standalone

       WHEN if_wd_application=>co_client_environment-unknown.
 *     Unknown client environment


If you are on a version of NetWeaver that supports chaining method calls (NW 7.0 EhP 2 or higher), you may skip declaration of the object references.

   CASE wd_this->wd_get_api( )->get_application( )->get_client_environment( ).


Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.