cancel
Showing results for 
Search instead for 
Did you mean: 

How can IWD_VALUE_HELP return multiple values, instead of one

Former Member
0 Kudos

Hello expert,

I have requirement to use F4 help to return multiple values to the using WD component. Basically in my main WD component, I have a View where I have a list box, this list box has a F4 assigned to it, clicking on the F4 brings up hte F4 help, in the F4 help, user can select multiple values which should be returned to my main component / view to be displayed in the list box.

I'd implement IWD_VALUE_HELP to create my own F4 help component. However I have difficulty to return multiple values. As I understand there is only way to return data from F4 help to the calling Main WD component / view:

Item_LISTENER->F4_CONTEXT_ELEMENT->set_attribute( name = 'MYATTRName' value = myvalue).

Do you guys know how to archive what is required here?

Thanks

Jayson

Accepted Solutions (1)

Accepted Solutions (1)

ChrisPaine
Active Contributor
0 Kudos

There are multiple ways,

but given that in the help you have the reference to the F4 Context element ->Item_LISTENER->F4_CONTEXT_ELEMENT and it is a true reference - you can use this as the starting point to get to any attribute of your context. - So you could use it to get to a child node of the element, or various different attributes of the element - or another node completely (just use the get_(parent/child)_node methods to get anything in the context.

This is probably the easiest - but it relies on you only using that help component in the one single application and is not very reusable!

Alternatively populate the values into the event raised when the help returns and then handle that event, read the values and do your context population there. Much more reusable, but a little more complex.

Former Member
0 Kudos

Chris,

not very sure what you mean by the first option. Through Item_LISTENER->F4_CONTEXT_ELEMENT you can only set an attribute, not a node.

Also the main component / view expects only one value from the F4 help component, this one value will be then put into the context attribute in the main component view. So even if you pass a node instead of attribute in Item_LISTENER->F4_CONTEXT_ELEMENT, the main component view won't know how to handle it, I guess.

Appreciate if you could elaborate.

ChrisPaine
Active Contributor
0 Kudos

Hello Jayson,

the element reference that is passed into the IWD_VALUE_HELP implementing component is the element of the calling application's context.

Therefore you can use methods like

IF_WD_CONTEXT_ELEMENT->GET_NODE

(to get the parent node of the element) and

IF_WD_CONTEXT_ELEMENT->GET_CHILD_NODE

to get access to other parts of the context.

say for example your value help should populate a pop-in table with multiple entries.

your application allows you to choose a type of ice-cream cone and then to choose the flavour of ice-cream (multi selection)has a structure like:

Context_root

--> List_of_ice_creams (0..n)

-


>Ice_cream_flavours(1..n)

In the element of list_of_ice_creams you have an attribute "flavour" which links to your value help.

Choosing this value-help should allow you to select multiple flavours, return these and populate them into the sub-node Ice_cream_flavours.

Within your custom value help you can get a reference to the node Ice_cream_flavours by calling the method

lo_flavour_node = IItem_LISTENER->F4_CONTEXT_ELEMENT->GET_CHILD_NODE("ICE_CREAM_FLAVOURS"). You could then populate this in you value help component.

As I mentioned - this isn't great as it means the value help cannot really be used elsewhere as it has a dependency on the structure of the calling context. But that may not be an issue for you.

Hope that helps,

Chris

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

I am expecting that table which showing search result in WD component(implementing interface IWD_VALUE_HELP) is bounded to context node.

if it is true then on the close of popup(IWD_VALUE_HELP) you must be catching event in your calling application. through this event you can return the set of selected elements in the form of WDR_CONTEXT_ELEMENT_SET as event parameter(s).

In your event handler get the event parameter and loop through all the context element set and get all elements and its attributes.

Thanks,

Rahul

Former Member
0 Kudos

Rahul

I think you're talking about the event VH_WINDOW_CLOSED. However this event is fired by the framework, not by the F4 help component, how can I pass the selected items as event parameters in the event?

Do you have some code to share this piece?

Thanks

Jayson

Former Member
0 Kudos

Jayson,

It depends how you want to close your popup. let say you have OK button on your popup window and on the click of OK button you want to raise the event with selected entries and close the popup:

this code go in component controller of your IWD_value_help WD component

l_data_selected TYPE  wdr_context_element_set.

  l_data_selected = lr_node->get_selected_elements(
including_lead_selection = abap_true ). " get the selected entries 

    wd_this->fire_ev_selected_entries_evt(
    selected_entries = l_data_selected
    ). " pass selected entries as event parameters


    wd_this->m_value_help_listener->close_window( ).

    wd_this->fire_vh_window_closed_evt(
    ). " this is to close the popup window

Thanks,

Rahul

Former Member
0 Kudos

Thank you both chris and Rahul, I need to try both of your suggestions, both seems solving my problem.