cancel
Showing results for 
Search instead for 
Did you mean: 

Value help for select options (pass the selected values to the select opt)

former_member186783
Participant
0 Kudos

Hi everyone,

I created a custom value help for my select options.

It works fine, when the user clicks on the value help, my own view is displayed, and the user can select the required values:


 lt_range_table =
  wd_this->m_handler->create_range_table(
  i_typename = 'ORGEH' ).
* add a new field to the selection
  wd_this->m_handler->add_selection_field(
  i_id = 'ORGEH'
  i_value_help_id = 'MYSO'
  i_value_help_type = IF_WD_VALUE_HELP_HANDLER=>CO_PREFIX_APPLDEV
  it_result = lt_range_table
  i_read_only = read_only ).

The problem is, how can I pass the values to the select option? When the user selects the values in my view, I have them in an internal table. But how can i pass these values to the select option? I suppose there is declared method for this... but which one?

Thanks

N.

Accepted Solutions (1)

Accepted Solutions (1)

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Are you saying you are using a Freely Programmed Value Help? If so, you would generally use the value help listener to access the source context element that triggered the value help:

http://help.sap.com/saphelp_nw70ehp1/helpdata/en/47/9ef8cc9b5e3c5ce10000000a421937/frameset.htm

You say that you have values - as in plural. Is that correct? Are you wanting to copy multiple values back to the select-option? If so the value help listerner object isn't setup for that. It only gives you access to the one source element. You would need to use component usage to access an interface method of the source component controller and through this method pass a refernce to the m_handler (the select options component handler) into the freely programmed value help.

former_member186783
Participant
0 Kudos

Hi Thomas,

Yes. I'm Using Freely Programmed Value Help.

There are to views 'MAIN' and 'SEL_TREE'.

MAIN view has the :

-m_handler TYPE IF_WD_SELECT_OPTIONS

SEL_TREE is the value help view.

I have multiple values in the value help (It's a tree with the Organizuation Unites of the company ). I 'd like to pass these values to the select option.

How can I pass these values to the select options? I tried it with the VH_WINDOW_CLOSED event.

I fire this event in my SEL_TREE view (this is the view in the WD_VALUE_HELP window)


  wd_comp_controller->fire_VH_WINDOW_CLOSED_evt( ).

I also registered an event handler in the MAIN view for this event, but the event handler method is never called...

What do you mean on "You would need to use component usage to access an interface method of the source component controller and through this method pass a refernce to the m_handler (the select options component handler) into the freely programmed value help."

Can you give some sample code, or some explanation?

Thnaks

N.

former_member186783
Participant
0 Kudos

Here's my source code:


 DATA:
  lr_componentcontroller TYPE REF TO ig_componentcontroller,
  l_ref_cmp_usage TYPE REF TO if_wd_component_usage.
* create the used component
  l_ref_cmp_usage = wd_this->wd_cpuse_select_option( ).
  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_option( ).
* init the select screen
  wd_this->m_handler =
  wd_this->m_wd_select_options->init_selection_screen( ).
*---------------------------------------------------------------------------------------------
DATA lo_so_api TYPE REF TO IF_WD_CONTROLLER.
  lo_so_api = wd_this->m_wd_select_options->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 = 'SEL_TREE' ).

  lt_range_table =
  wd_this->m_handler->create_range_table(
  i_typename = 'ORGEH' ).
* add a new field to the selection
  wd_this->m_handler->add_selection_field(
  i_id = 'ORGEH'
  i_value_help_id = 'MYSO'
  i_value_help_type = IF_WD_VALUE_HELP_HANDLER=>CO_PREFIX_APPLDEV
  it_result = lt_range_table
  i_read_only = read_only ).


thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

So it sounds like your main problem is that the value help event is not getting triggered back in the main component. But why perform the update the select options there? Instead update the selection options within SEL_TREE. You just need to pass the m_handler object reference from your main component into the component usage of the value help.

former_member186783
Participant
0 Kudos

Hi Thomas,

It sounds 100% perfect for me to pass the m_handler. (Actually this was my original idea, to set the select-option in the SEL_TREE but i thought I can't do this) So, how can 'I do that? How can I pass the m_handler to the component usage of the value help?

Thanks

N.

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Probably one of the easiest ways to do this is to create a normal ABAP singleton pattern class. The Parent component and the value help component will then share the same instance fo this one class. The parent compoennt can set an attribute in this singleton class instance for the m_handler and the value help component can access this same attribute/m_handler.

former_member186783
Participant
0 Kudos

Sorry for the stupid question, but it seems I can't acces my attribute:

I create it in the component controller

NODE: 'APP_DATA'

Attribute: M_HANDLER TYPE IF_WD_SELECT_OPTIONS

Cardinality 1..1

Selection 1..1

Singleton = 'X'

I pass the values int he EDOINIT method of MAIN view:


* Get compnent controller API
  lo_component = wd_comp_controller->wd_get_api( ).
  lo_controller ?= lo_component.
* Get the controler context node
  CALL METHOD LO_CONTROLLER->GET_CONTEXT
    RECEIVING
      CONTEXT = lo_context.
*Get the root node
  lo_node = lo_context->root_node.
*Get the child node
  lo_child = lo_node->get_child_node( 'APP_DATA' ).

ls_app_data-m_handler = wd_this->m_handler.
 lo_child->bind_structure( ls_app_data  ).

After this code I test it if the binding is correct:


 DATA: ls_test TYPE wd_comp_controller->element_app_data.

CALL METHOD LO_CHILD->GET_STATIC_ATTRIBUTES
  IMPORTING
    STATIC_ATTRIBUTES = ls_test.

The lstest is correct_. It has the reference for the SelectOption

Now, in the SEL_TREE View:


* Get compnent controller API
  lo_component = wd_comp_controller->wd_get_api( ).
  lo_controller ?= lo_component.
* Get the controler context node
  CALL METHOD LO_CONTROLLER->GET_CONTEXT
    RECEIVING
      CONTEXT = lo_context.
*Get the root node
  lo_node = lo_context->root_node.
*Get the child node
  lo_child = lo_node->get_child_node( 'APP_DATA' ).
*Get the data from the node
  CALL METHOD LO_CHILD->GET_STATIC_ATTRIBUTES
    IMPORTING
      STATIC_ATTRIBUTES = ls_app_data.
  wd_this->m_handler = ls_app_data-m_handler.

The ls_app_data-m_handler is INITIAL. There is no value in it.

What did I do wrongly?

Please help

Thanks

N.

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Your trying to pass the reference via context? Did you define the cross component context mapping? I'm not even sure if cross component context binding with an object reference will work since cross component context binding is done by copy and not by reference. Why not just use the approach I suggested with the singleton class pattern. That works for sure.

former_member186783
Participant
0 Kudos

Well, I tried to handle this case in WDA, but you're 100% right. I created my singleton class, and it works 100% correct (I didn't check the value, but the refernce has something in it )

Million thanks for the help !!!

Bye

N.

0 Kudos

HI ngastnek/Thomas,

Can you tell me how you managed to pass the instance of the assistance/singleton class ?

I am also having the same requirement.I am using Freely programmed search help in the select option.

For me wd_assist value is getting cleared when i am trying to pass the assistance class instance.

lo_cmp_usage = wd_this->wd_cpuse_com_code_sh( ).

IF lo_cmp_usage->has_active_component( ) IS INITIAL. ( Search help component)

lo_cmp_usage->create_component(

assistance_class = wd_assist ).

ENDIF.

This is how i am passing the wd_assist instance to my search help component.

but when i am clicking the search help in my select option the constructor of the search help component is again called and wd_assit value of my current component instance is getting cleared and new instance is getting created.

Thanks In Advance

Ganesh

former_member186783
Participant
0 Kudos

Hi,

Ohh, I spent several hours, when finall I made a working free value help.

This example is very complicated, because here, I created an Organizational tree, as a Org Unit search help

If you need just a table, then it's a little bit easier you can Use the OVS value help (google it! there are several examples )

In this example, I created my tree in a differnet component, then I passed this USED COMPONENT as a parameter (ZDATA_REP01)

Here is my code:



  DATA lo_so_api TYPE REF TO IF_WD_CONTROLLER.
  lo_so_api = wd_this->m_wd_select_options->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 = 'ZDATA_REP01' ).

  lt_range_table =
  wd_this->m_handler->create_range_table(
  i_typename = 'ORGEH' ).
* add a new field to the selection
  wd_this->m_handler->add_selection_field(
  i_id = 'ORGEH'
  i_value_help_id = 'MYSO'
*  i_value_help_type = 'SEARCHHELP'
  i_value_help_type = IF_WD_VALUE_HELP_HANDLER=>CO_PREFIX_APPLDEV
  it_result = lt_range_table
  i_read_only = read_only ).

Former Member
0 Kudos

hi:

    I created a custom value help for my select options.

    I have also encountered similar problems,how get valule from freely programmed help into select options.?

   Can you give some sample code?

  thanks!

former_member186783
Participant
0 Kudos

HI,

  1. Create a component, which retrieves the required value,
  2. Set this component as used component in your WDA application
  3. Define a select option with your search help (the sample code is in the above comment)
  4. I used singleton patern to get the value back to the original component.

Bye

N.

Former Member
0 Kudos

HI:

   First to third, I have completed

   The fourth step, how should I do it? Is there  no specific examples?

   thanks!!

Answers (0)