Part #1
NOTE
: I had to break this weblog up into two parts because I see to have hit some sort of size limitation somewhere. My weblog kept getting cutoff at a certain point. The following is a link to[ part two | https://weblogs.sdn.sap.com/cs/weblog/view/wlg/975].This example was futher enhanced in BSP Value Input Help Popups Version 3.0.
Download Link
Now you can download the code and screen shots here.if_bsp_servicesget_simple_helpvalues2, that may not be present on older support packages. If that is so, just substitute with the older version: cl_bsp_services=>if_bsp_servicesget_simple_helpvalues.
Next up I have included the Download Custom BSP Element in this solution. This is completely optional, but does allow the user to download the value list similar to the functionality in the class ABAP Search Help. If you are interested in Element please have a look at the following weblog: Creating a BSP Extension for Downloading a Table.
Finally I have used a JavaScript library created by Matt Kruse that allows for the Movement of the Popup Box. This library is free for Commercial or Private use. However I can not re-distribute the source code. You must download it yourself from its original home .</p>
Before we get started with the code in this example, I wanted to throw out one other option for getting to the code. I have a zip file that includes all the source code and screen shots (not reduced to meet the SDN size limit). I submitted this content to SDN nearly a month ago, hoping to include it with this weblog. However I am still waiting for approval. I decided to go ahead and offer it to anyone who wants it via E-mail until I can post it on SDN. You can send your requests to tjung@kimball.com . Please let me know if you need me to rename the ZIP file extension. I have already shared this with some people who have contacted me off-line about the Value Input Help Popup.
BSP Elements
We start off our solution with two new BSP Elements. The first one I named inputHelpDrag. It is very simple in that it only contains a little bit of JavaScript that must be included in the hosting page to allow our popup IFrame to be movable. This element is optional. If it is not inserted, we just will have a stationary popup.
The second element I named inputHelp. For its Properties we have Element: content = Blank and Further Options with User-Defined Validation and "PAGE DONE" is not returned at end of BSP element both checked. Now because we are wrapping this element around both the listBox and the inputField, we have quite a few attributes. I wanted to expose almost all attributes from both inner elements. However the new element can be used with minimal input. The most important attributes are the new ones I added to control the popup. The first is multiple. This controls if you want single or multipe selection (it defaults to single). Next we have the attribute dataRef. This attribute accepts the name of the data dictionary reference that will be used for simple value help values. This is nice for code/description combinations. Finally we have rfcFunction and rfcDest. This is for when you want to program the Help Value data retrival your self. You can supply the name of the RFC that you want called by the processing page. The rfcDest defaults to NONE (local system).
NEW
in this version we have the attributes for the third type of value selection, Selection by BAPI. These new values are OBJNAME, OBJTYPE, PARAM, and KEYFIELD. These will allow us to specify the Business Object that the BAPI will use to pull our Search Help Definition from. The following is a screen shot of all the attributes:MOVE me->id TO <wa_params>-value.
ENDIF.
APPEND INITIAL LINE TO params ASSIGNING factory(
disabled = me->disabled
encode = me->encode
id = me->id
id_postfix = '__listBox'
multiple = 'TRUE'
selections = me->selections
size = '2'
width = me->width ).
****Render the List Box
WHILE m_page_context->element_process( element = listbox ) = co_element_continue.
ENDWHILE. "End Listbox Render
me->print_string( ' ' ).
****Build the Help Image
DATA: image TYPE REF TO cl_htmlb_image.
DATA: img_src TYPE string.
img_src = cl_bsp_mimes=>sap_icon( `ICON_PERSONAL_HELP` ).
****Create the Image
image ?= cl_htmlb_image=>factory( id = me->id
id_postfix = '__image'
onclientclick = onhelp2
src = img_src ).
****Render the Image
WHILE m_page_context->element_process( element = image ) = co_element_continue.
ENDWHILE. "End Image Render
ELSE.
****Single selection - We will render an inputfield. The '_' Fields are for
****Model Binding
DATA: inputfield TYPE REF TO cl_htmlb_inputfield.
inputfield ?= cl_htmlb_inputfield=>factory(
alignment = me->alignment
description = me->description
design = me->design
disabled = me->disabled
encode = me->encode
id = me->id
id_postfix = '__inputField'
invalid = me->invalid
maxlength = me->maxlength
required = me->required
required = me->required
showhelp = 'true'
onvaluehelp = onhelp2
size = me->size
size = me->size
style = me->style
tooltip = me->tooltip
type = 'STRING'
value = me->value
value = me->value
visible = me->visible
visible = me->visible
width = me->width ).
****Render the Input Field
WHILE m_page_context->element_process( element = inputfield ) = co_element_continue.
ENDWHILE. "End Input Field Render
ENDIF.
DATA html TYPE string.
DATA: url_string TYPE url.
****Build the URL to the Dummy - Loading... Page
CLEAR params.
DATA: iframe_dummy_url TYPE string.
CALL METHOD cl_http_ext_webapp=>create_url_for_bsp_application
EXPORTING
bsp_application = 'zes_keg_shared'
bsp_start_page = 'dummy.htm'
bsp_start_parameters = params
IMPORTING
local_url = iframe_dummy_url.
****Render the IFrame
CONCATENATE html
`
Before we go any further I should probably give you the few lines of code from the inputHelpDrag element as well. I am loading a piece of JavaScript that I found on the Internet. The code is Free for Commercial or Private use. However I am not allowed to re-distribute the source code. You can get it yourself from the original webpage .
<xhtmlb:pager id = "mu_pg1"
onPage = "pager_onPage"
vMax = "load_values_from_formfield( model2 ).
endif.
if input is available, dispatch this input to subcomponent.
this call is only necessary for toplevel controllers.
( if this is not a toplevel controller or no input is present,
this call returns without any action)
dispatch_input( ).
if any of the controllers has requested a navigation,
do not try to display, but leave current processing
if is_navigation_requested( ) is not initial.
return.
endif.
****Requested Simple Help Values
if not model2->data_ref is initial.
model2->get_helpvalues_simple( ).
****Requested Help Values Via an RFC Exit
elseif not model2->rfcfunction is initial.
model2->get_helpvalues_exit( ).
elseif not model2->objtype is initial.
model2->get_helpvalues_bapi( ).
else.
model2->message = 'Element ID can not be blank'(e03).
endif.
****Multi or Single Select?
if model2->multiple = abap_true.
model2->selectionmode = cl_htmlb_tableview=>c_tableselection_multiselect.
else.
model2->selectionmode = cl_htmlb_tableview=>c_tableselection_singleselect.
endif.
****Call our View
view = create_view( view_name = 'InputHelp.bsp' ).
view->set_attribute( name = 'model' value = model2 ).
call_view( view ).
endmethod.