on 05-07-2010 1:46 AM
Hello,
I was intrigued by a recent thread:
[Thread: WD4A - catch event on cursor field change |;
I've often come across the problem posed by standard value helps not eventing that the user has made a selection. and reading the posts here - others often have the same problem.
Has anyone experimented with some way of embedding a standard search help within a freely programmed value help? As the freely programmed help does allow for eventing on selection - if a generic component could be built in whcih we could just pass the search help id that we want to use - but also have an event we could trap on return of the search help.
Sounds like it should be possible - and would be a nice little piece of code to share with the community...
Anyone fancy a challenge?
Cheers,
Chris
I'm going to close this question and mark as resolved - if you're looking for the resolution, please refer to my blog - posted earlier.
Cheers,
Chris
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I was looking at the code behind class CL_WDR_VALUE_HELP_HANDLER
and it seems to me that there is an event fired on close of all value helps - which could be trapped and used to make other changes to the context - even when using a standard value help...
- in the local class definition of lcl_handler there is a method:
METHOD on_window_closed.
super->on_window_closed( ).
* inform application about window close
me->component_usage->child_component->fire_event(
controller_name = 'COMPONENTCONTROLLER'
event_name = 'VH_WINDOW_CLOSED' ).
ENDMETHOD. "on_window_closed
anyone had any luck trapping this event? I'm going to give it a try!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
So close but so far...:
within my component controller I created an event
method ON_VH_CLOSED .
update_based_on_change( cl_wdr_value_help_handler=>m_context_element ).
endmethod.
which would be called when the window closed.
I managed this by creating a WD Class which listened for the close event of the value help window:
3 static methods:
method REGISTER_LISTENER.
ao_component = listening_component.
set handler handle_vh_close.
set handler on_ddic_search..
endmethod.
method on_ddic_search.
cl_wdr_value_help_handler=>if_wd_value_help_forward~set_context(
context_element = cl_wdr_value_help_handler=>m_context_element
context_attribute = cl_wdr_value_help_handler=>m_attribute_info-name ).
endmethod.
method HANDLE_VH_CLOSE.
ao_component->fire_event(
controller_name = 'COMPONENTCONTROLLER'
event_name = 'VH_WINDOW_CLOSED' ).
endmethod.
The on_ddic_search and HANDLE_VH_CLOSE were marked as event handlers for
CL_WDR_VALUE_HELP_HANDLER
IF_WD_VALUE_HELP_FORWARD~~VALUE_HELP_CLOSED
and
CL_WDR_VALUE_HELP_HANDLER
IF_WD_VALUE_HELP_FORWARD~DDIC
in the WDINIT of my controller I told my class to call my event if it found the event
(post split to avoid silly formatting issues)
* register as value help listener
data: lo_listener type ref to cl_wdr_component,
lo_component_api type ref to if_wd_component,
lo_component type ref to if_wd_component.
lo_component_api = wd_this->wd_get_api( ).
lo_component = lo_component_api->get_component( ).
lo_listener ?= lo_component.
zpa_pa_empl_maintain_vh=>register_listener(
listening_component = lo_listener ).
* add reference to handler
lo_component->add_event_handler(
listener_name = 'COMPONENTCONTROLLER'
handler_name = 'ON_VH_CLOSED'
controller_name = 'COMPONENTCONTROLLER'
event_name = 'VH_WINDOW_CLOSED' ).
BUT the data transport from the value help context change has not yet taken place - so the context has not yet been updated!
So although the event is fired after the search help window is closed... the search help hasn't yet updated the context value!
Immensely infuriating! - If anyone know how to get at these pending values it would be great.
In the meantime I think I'll just create a event listener for attribute changes on my context element- registering on launch of my value help and deregistering afterward. At least then I should have the changed value!
YES I did it!
I was almost there!
all I did was change the triggering of my event slightly. when the window closes I start listening for change of context events.
method HANDLE_VH_CLOSE.
* window is closing - register change of context element
set handler on_search_context_changed.
endmethod.
The ON_SEARCH_CONTEXT_CHANGED method is an event listener for
CL_WDR_CONTEXT_ELEMENT
ON_ATTRIBUTE_CHANGED
when the context changes - is updated I immedately stop listening and fire my event.
method ON_SEARCH_CONTEXT_CHANGED.
* deactivate handler
set handler on_search_context_changed activation abap_false.
ao_component->fire_event(
controller_name = 'COMPONENTCONTROLLER'
event_name = 'VH_WINDOW_CLOSED' ).
endmethod.
So now when my user selects from the standard value help - all the other dependent fields of the context are also updated...
Nice...
Anyone see any issues with the above solution?
Chris
the whole solution is better documented in this blog:
[ASUG UI Influence Council, you're wrong! (well sort of -ish, not really at all).|http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/20054] [original link is broken] [original link is broken] [original link is broken];
Hopefully this helps anyone who finds this thread when looking for a solution on how to event from close of a standard value help.
Cheers,
Chris
User | Count |
---|---|
83 | |
24 | |
12 | |
9 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.