Quantcast
Viewing all articles
Browse latest Browse all 17

Adding a custom tab to PLM Web UI

Introduction

 

Adding a custom tab to PLM Web UI can be tricky. Luckily SAP has made the PLM Web UI extensible thanks to Service Provider (SP), Floorplan Manager (FPM) and Web Dynpro ABAP (WDA).

 

Environment

 

PLM 7.02 on ERP 6.0 EHP6 SPS04 was used while writing this document.

 

Solution

 

Go to SE18 and use Enhancement Spot /PLMU/ES_FRW_CONSUMER_APPCC to create your own enhancement. Use BAdI definition /PLMU/EX_FRW_CONSUMER_APPCC. Define a filter to restrict to a specific PLM Web UI application (WD_APPLICATION_NAME) and configuration (WDAPPLICATIONCONFIGURATIONID) unless you want your tab to be visible in all applications. For example to add a tab only to the standard Document (DIR) PLM Web UI application define WD_APPLICATION_NAME as /PLMU/WDA_DIR_OIF and WDAPPLICATIONCONFIGURATIONID as /PLMU/WDC_DIR_OIF_CFG. Of course if you have defined an Z application configuration, you would use that instead of the standard one.

 

In the implementing class, method /PLMU/IF_EX_FRW_CONSUMER_APPCC~OVERRIDE_EVENT_OIF define the logic to add the custom tab. To add a custom tab, use the following code:

 

      data ls_uibb            type if_fpm_oif=>ty_s_uibb.

      data lt_uibb            type if_fpm_oif=>ty_t_uibb.

 

 

      clear lt_uibb[].

      clear ls_uibb.

 

 

      ls_uibb-component     = '<WEBDYNPROCOMPONENT>'.

      ls_uibb-interface_view = '<WEBDYNPROCOMPONENTWINDOW>'.

      append ls_uibb to lt_uibb.

 

      try.

          callmethod io_oif->add_mainview

            exporting

              iv_variant_id   = '<VARIANT>'

              iv_mainview_id = '<MAINVIEWID>'

              iv_mainview_name = '<NAMEOFTAB>'

              iv_index       = <INDEXOFTAB>

              iv_subview_id   = '<SUBVIEWID>'

              iv_subview_name = '<SUBVIEWNAME>'

              it_uibb         = lt_uibb.

        catch cx_fpm_floorplan .

      endtry.

 

 

If you want to check if the tab is already visible use the following code:

 

  data lt_mainviews    type if_fpm_oif=>ty_t_mainview.

  data ls_mainviews    type if_fpm_oif=>ty_s_mainview.

  data lv_tabvisible   type boole_d.

 

 

  try.

      callmethod io_oif->get_mainviews

        exporting

          iv_variant_id = '<VARIANT>'

        importing

          et_mainview = lt_mainviews.

 

      loopat lt_mainviews into ls_mainviews.

        if ls_mainviews-variant = '<VARIANT>'and

          ls_mainviews-id     = '<MAINVIEWID>'.

          lv_tabvisible = abap_true.

          exit.

        endif.

      endloop.

    catch cx_fpm_floorplan .

  endtry.

 

 

Data Sharing

 

In PLM Web UI, like any modular implementation, data sharing becomes an issue. Assistance classes are heavily used in PLM Web UI for data sharing. By using the same assistance class in your custom component you will have visibility to the context of the main component. For example in the above example if you wanted to query for the current document type, you would use the following code:

 

  data lo_node            typerefto if_wd_context_node.

  data lo_element         typerefto if_wd_context_element.

  data ls_init            type /plmb/s_dir_init.

 

  if /plmu/cl_dir_appl_assist=>go_context isbound.

    lo_node = /plmu/cl_dir_appl_assist=>go_context->get_child_node( /plmu/if_dir_c=>gc_init ).

 

    if lo_node isbound.

      lo_element = lo_node->get_element(  ).

 

      if lo_element isbound.

        lo_element->get_static_attributes(importing static_attributes = ls_init ).

 

        if ls_init-documenttype eq'XYZ'.

        endif.

      endif.

    endif.

 

 

Event Processing

 

Whenever the custom tab is active, events can be handled in method PROCESS_EVENT of the component interface IF_FPM_UI_BUILDING_BLOCK. When the custom tab isn't active, events can be handled in method SAVE of the component interface IF_FPM_TRANSACTION. For the latter event to be triggered the custom tab must have been initialized meaning the user must have clicked on the tab at least once. When the custom tab is active, it might make sense to also call event processing of the main component.

 

Acknowledgements

 

ABAP source code in this document was formatted using the ABAP code lighter for SCN by George Shlyakhov.


Viewing all articles
Browse latest Browse all 17

Trending Articles