cancel
Showing results for 
Search instead for 
Did you mean: 

How to integrate a Search Help in a dynamically created Select-Option?

Former Member
0 Kudos

I implemented a WebDynpro Component, which has an input field for COUNTRY and a select-option (component WDR_SELECT_OPTIONS) for VENDOR. This vendor is depending on the selected country.

So I implemented a customer value help (based on interface IWD_VALUE_HELP), which only displays the vendors of the selected country. This works pretty fine as long as I use this value help component for statically defined input fields, where I have set the attributes of the according context attributes "Input Help Mode" (="Freely Programmed") and "Input Help Component Usage".

The select-option is created at runtime as follows within the hook method WDDOINIT:


  DATA:
    lr_usage            TYPE REF TO if_wd_component_usage,
    lr_if_controller    TYPE REF TO iwci_wdr_select_options,
    lt_range            TYPE REF TO data.


* initialize select option component
  lr_usage = wd_this->wd_cpuse_vco_selectoption( ).
  IF lr_usage->has_active_component( ) IS INITIAL.
    lr_usage->create_component( ).
  ENDIF. "IF lr_usage->has_active_component( ) IS INITIAL



* initialize selection screen
  lr_if_controller = wd_this->wd_cpifc_vco_selectoption( ).
  wd_this->mr_selopt = lr_if_controller->init_selection_screen( ).

  wd_this->mr_selopt->set_global_options(
                                   i_display_btn_cancel  = abap_false
                                   i_display_btn_check   = abap_false
                                   i_display_btn_reset   = abap_true
                                   i_display_btn_execute = abap_false ).


  lt_range = wd_this->mr_selopt->create_range_table(
                                      i_typename = '/BIC/OIBI_VENDOR' ).
  wd_this->mr_selopt->add_selection_field(
        i_id              = 'VENDOR'
        it_result         = lt_range
        i_description     = 'Vendor'
*{"experimental
        i_value_help_type = if_wd_value_help_handler=>co_prefix_appldev
        i_value_help_id   = 'SH_VENDOR'
*}"experimantal
        ).

The hook method WDDOINIT is processed successfully, but as soon as I click on the button for the input help, the WebDynpro dumps with an UNCAUGHT_EXCEPTION Exception CX_WDR_RR_EXCEPTION. In the browser window the following message is processed:

"Component usage SH_VENDOR does not exist."

Where is my mistake? How can I use the value help in my select-option?

Thanks for any advice!

--MIKE

Accepted Solutions (1)

Accepted Solutions (1)

former_member189058
Active Contributor
0 Kudos

Hi Mike,

What I understand is that you have custom component created for search help.

If that is correct, the following steps would include that component for search help on a certain field.

Step 1: Add you component as the used component , say the usage name that you specify is USG_01

Step 2: Add the component usage to the view on which you are creating the selection screen.

Step 3: When adding the selection option on the selection screen specify that the value help type is freely programmed and provide the name of your usage.


wd_this->mr_selopt->add_selection_field(
        i_id              = 'VENDOR'
        it_result         = lt_range
        i_description     = 'Vendor'
        I_VALUE_HELP_TYPE = IF_WD_VALUE_HELP_HANDLER=>CO_PREFIX_APPLDEV
        I_VALUE_HELP_ID = 'USG_01' ).

Regards,

Reema.

Former Member
0 Kudos

Hi,

this is exactly, what I have done in the Hook Method WDDOINIT:

The hook method WDDOINIT is processed successfully, but as soon as I click on the button for the input help, the WebDynpro dumps with an UNCAUGHT_EXCEPTION Exception CX_WDR_RR_EXCEPTION. In the browser window the following message is processed:

"Component usage SH_VENDOR does not exist."

former_member189058
Active Contributor
0 Kudos

Done......


  DATA:
    l_ref_cmp_usage TYPE REF TO if_wd_component_usage.

* create the used component
  l_ref_cmp_usage = wd_this->wd_cpuse_so( ).
  IF l_ref_cmp_usage->has_active_component( ) IS INITIAL.
    l_ref_cmp_usage->create_component( ).
  ENDIF.

* get a pointer to the interface controller of the select options component
  wd_this->g_wd_so = wd_this->wd_cpifc_so( ).

  DATA lo_so_api TYPE REF TO IF_WD_CONTROLLER.
  lo_so_api = wd_this->g_wd_so->wd_get_api( ).

  DATA lo_so_cmp TYPE REF TO IF_WD_COMPONENT.
  lo_so_cmp = lo_so_api->get_component( ).

  DATA lo_so_cmp_usg TYPE REF TO IF_WD_COMPONENT_USAGE_GROUP.
  lo_so_cmp_usg = lo_so_cmp->create_cmp_usage_group(
      name           = 'MYSO'
      used_component = '<MY SRCH COMPONENT NAME>' ).

* init the select screen
  wd_this->g_so = wd_this->g_wd_so->init_selection_screen( ).

* set global options
  CALL METHOD wd_this->g_so->set_global_options
    EXPORTING
      i_display_btn_cancel  = abap_false
      i_display_btn_check   = abap_false
      i_display_btn_reset   = abap_false
      i_display_btn_execute = abap_false.

* MATNR
* create a range table
  lt_range_table = wd_this->g_so->create_range_table( i_typename = 'MATNR' ).
* add a new field to the selection
  wd_this->g_so->add_selection_field( i_id = 'S_MATNR'
                                      it_result = lt_range_table
                                      I_VALUE_HELP_TYPE = IF_WD_VALUE_HELP_HANDLER=>CO_PREFIX_APPLDEV
                                      I_VALUE_HELP_ID = 'MYSO' ).

View Attributes:

G_SO Type ref to IF_WD_SELECT_OPTIONS

G_WD_SO Type ref to IWCI_WDR_SELECT_OPTIONS

View Properties

Component USe: SO

Component: WDR_SELECT_OPTIONS

There is no need to create the usage of the search help component.

This is tried and tested code.

Regards,

Reema.

Former Member
0 Kudos

Thx for your suggestion, Reema.

I will try this tomorrow and come back to you as soon as I know the outcome of this.

former_member189058
Active Contributor
0 Kudos

sure Mike,....

wish u luck!!!

Former Member
0 Kudos

@Reema:

This was the solution, thank you very much!

tony_dagnillo2
Explorer
0 Kudos

Hello Reema,

I realize that this is an old post but, none the less, your code extract has gotten me much further than my previous attempts to do the same. My problem is that once I select a value from my value help, it is not actually being returned into the select option field of the calling component. I've debugged my VH component. It is properly capturing the value I've selected and firing my data_selected event in the component controller. Up to this point it is behaving the same as other VH's I've used for input fields. I just can't seem to get the chosen value to get sent back to my select option. Any thoughts?

Thanks,

Tony

Former Member
0 Kudos

Hello, all!

That example is not working.

My code sample is below

  DATA:     l_ref_cmp_usage TYPE REF TO if_wd_component_usage,     lt_rng_table    TYPE REF TO data. * create the used component   l_ref_cmp_usage = wd_this->wd_cpuse_so( ).   IF l_ref_cmp_usage->has_active_component( ) IS INITIAL.     l_ref_cmp_usage->create_component( ).   ENDIF. * get a pointer to the interface controller of the select options component   wd_this->g_wd_so = wd_this->wd_cpifc_so( ).   DATA lo_so_api TYPE REF TO if_wd_controller.   lo_so_api = wd_this->g_wd_so->wd_get_api( ).   DATA lo_so_cmp TYPE REF TO if_wd_component.   lo_so_cmp = lo_so_api->get_component( ).   DATA lo_so_cmp_usg TYPE REF TO if_wd_component_usage_group.   lo_so_cmp_usg = lo_so_cmp->create_cmp_usage_group(       name          = 'MYSO'       used_component = '/SAPSRM/WDC_UI_BACKEND_SH' ). * init the select screen   wd_this->g_so = wd_this->g_wd_so->init_selection_screen( ). * set global options   CALL METHOD wd_this->g_so->set_global_options     EXPORTING       i_display_btn_cancel  = abap_false       i_display_btn_check  = abap_false       i_display_btn_reset  = abap_false       i_display_btn_execute = abap_false. * MATNR * create a range table   lt_rng_table = wd_this->g_so->create_range_table( i_typename = 'BBP_WBS_ELEM' ). * add a new field to the selection   wd_this->g_so->add_selection_field( i_id = 'WBS_ELEM_E'                                       it_result = lt_rng_table                                       i_value_help_type = if_wd_value_help_handler=>co_prefix_appldev                                       i_value_help_id = 'MYSO' ).

Answers (5)

Answers (5)

Former Member
0 Kudos

hi:

  please reference follow code:   ZCY_FREEHELP is Web Dynpro component

  DATA LO_SO_API TYPE REF TO IF_WD_CONTROLLER.
  LO_SO_API = WD_THIS->M_WD_SELECT_OPTIONS_V->WD_GET_API( ).
  DATA LO_SO_CMP TYPE REF TO IF_WD_COMPONENT.
  LO_SO_CMP = LO_SO_API->GET_COMPONENT( ).
  DATA LO_SO_CMP_USG TYPE REF TO IF_WD_COMPONENT_USAGE_GROUP.
  LO_SO_CMP_USG = LO_SO_CMP->CREATE_CMP_USAGE_GROUP(
      NAME           = 'MYSO'
      USED_COMPONENT = 'ZCY_FREEHELP' ).

  FREE LT_RANGE_TABLE_V.
  LT_RANGE_TABLE_V = WD_THIS->m_handler_V->CREATE_RANGE_TABLE   ( 'ZCYPHDATE' ).


  WD_THIS->m_handler_V->ADD_SELECTION_FIELD(
       I_ID                         = 'ZCYPHDATE'
       IT_RESULT                    = LT_RANGE_TABLE_V
       I_DESCRIPTION                = '配货计划时间'
       I_VALUE_HELP_TYPE            = IF_WD_VALUE_HELP_HANDLER=>CO_PREFIX_APPLDEV
       I_VALUE_HELP_ID              = 'MYSO'
       I_NO_INTERVALS               = ABAP_FALSE ).

Former Member
0 Kudos

hi:Mike

    I also encountered a similar problem, how to solve this problem?

    thanks

Former Member
0 Kudos

Correct answer was given here:

reema shahbazkar        Aug 26, 2008 11:14 PM              

Former Member
0 Kudos

Hello!

In my case it's not working. What I do wrong?

Former Member
0 Kudos

hi all

this my code

LT_RANGE = LR_HELPER->CREATE_RANGE_TABLE( I_TYPENAME = 'P0001-PERNR'

).

LR_HELPER->ADD_SELECTION_FIELD( I_ID = 'PREM'

IT_RESULT = LT_RANGE

i_read_only = read_only

I_VALUE_HELP_ID = 'HELPERID'

I_VALUE_HELP_STRUCTURE = 'P0001'

I_VALUE_HELP_STRUCTURE_FIELD = 'PERNR'

I_VALUE_HELP_TYPE = IF_WD_VALUE_HELP_HANDLER=>CO_PREFIX_APPLDEV ->this row

error message : Component usage HELPERID does not exist.

how can i open search help ?

Former Member
0 Kudos

Hi Mesut,

I am not sure if you are still interested in the problem.

But I was facing the same problems an figured them out. So for anyone facing the same problem:

The value help is called from the component wdr_select_options. The problem is that the componenent usage you are using does not exist in this component but only in your individual component. You should not add the component usage to the wdr_select_options component because it is a SAP-standard component. The component usage could break on any update. This is why you should create the component usage dynamically at runtime as described above.

Former Member
0 Kudos

Hi,

Did you instantiate the used search help component before using it?

Regards,

Satheesh.

Former Member
0 Kudos

Hi Satheesh.

How do you mean that? Do you mean something like I did with the Select-Option Component, similar to that:


  lr_usage = wd_this->wd_cpuse_vco_selectoption( ).
  IF lr_usage->has_active_component( ) IS INITIAL.
    lr_usage->create_component( ).
  ENDIF. "IF lr_usage->has_active_component( ) IS INITIAL

Former Member
0 Kudos

Hi mike,

Its very easy to create a user difined search help in dynamic select option.Please try to understand below code its selfexplanatory.


 DATA:
  lt_range_table TYPE REF TO data,
 LV_TEXT TYPE STRING,
  read_only      TYPE abap_bool.
  DATA:
  l_ref_cmp_usage TYPE REF TO if_wd_component_usage.
* create the used component
  l_ref_cmp_usage = wd_this->wd_cpuse_select_options( ).
  IF l_ref_cmp_usage->has_active_component( ) IS INITIAL.
    l_ref_cmp_usage->create_component( ).
  ENDIF.
* get a pointer to the interface controller of the select options
*component
  wd_this->m_wd_select_options = wd_this->wd_cpifc_select_options( ).
* init the select screen
  wd_this->m_handler = wd_this->m_wd_select_options->init_selection_screen( ).

lt_range_table = wd_this->m_handler->create_range_table( i_typename = 'J_1IINTCHLN' ).
  wd_this->m_handler->add_selection_field( i_id = 'CHLNNO'
                                           it_result = lt_range_table
                                           i_read_only = read_only
                                           I_VALUE_HELP_ID = 'ZMA_CHALLAN'
                                           I_VALUE_HELP_STRUCTURE = 'ZMAPRR_CHLNHDR'
                                           I_VALUE_HELP_STRUCTURE_FIELD = 'CHLNNO'

                                         ).

If you didnt understand the code feel free to ask.

regards

PG

Former Member
0 Kudos

PG,

thanks for your reply. I know this way of providing search helps.

But my problem is to integrate a search help that is based on WebDynpro Interface IWD_VALUE_HELP, which is a WD component implemented by myself (!!), into my select option.

The way you solved the general issue of customer specific search helps is not solving the problem, that the values that should be presented in the search help popup are depending on other values already entered.