Sometimes there is a requirement for generating dynamic F4 help without using any SE11 Search Help. Through this document we can create F4 help as a popup window by specifying any table at run time.
In this Tutorial we consider a scenario, there is one view having a context node with a single attribute named city (Shown below). Now we need to assign F4 help for that city attribute.
Consider an Internal Table ZCITY as below,
Now go to the IMPL class of view where you have the attribute for which F4 help is required, and Declare following Attribute
gt_city as global table of type zcity
g_ref_decision_popup type ref to IF_BSP_WD_POPUP.
Get the data to be displayed in F4 help popup in to the global table (gt_city) defined in IMPL class of View.Now values needs to be fetched from Database Table to Glodal Table. It is better to write code in the Constructor of IMPL class as it is called once at the time of view object creation.
CALL METHOD super->constructor.
* Get all rows from desired tables
INTO TABLE gt_city.
IF sy–subrc <> 0.
* Error Message
Go to the GET_V method of the field (CITY). Write the following code:
Below code will make your city field look and function as F4 help field. Here we need to specify on clicking of F4 key which outbound will be called.
create object rv_valuehelp_descriptor
exporting iv_outbound_plug = ‘VALUEHELP’.
Create an Outbound plug namely ‘VALUEHELP’ and write the following code. This outbound plug will be called by clicking of F4 function key or clicking on that F4 help icon which is displayed at the right end of the text box.Here we are creating a decision popup by passing a global table and the number of rows to be displayed in the popup.
* Create decision popup
iv_title = ‘City Selection’
iv_visible_row_count = 10
iv_display_table = gt_city ).
* Assign close event CONFIRM_POPUP_CLOSED
iv_event_name = ‘CONFIRM_POPUP_CLOSED’
iv_view = me ).
* Open popup
Create an event named CONFIRM_POPUP_CLOSED. Write the following code.
On closing of the popup window this event will be called as we have specified in the previous step.
“OUTPUTNODE” is the standard context node through which we can access the selected row index and the event generated in Decision Popup Window.
ls_city TYPE zcity,
l_ref_outputnode TYPE REF TO cl_bspwdcmp_bspwdcomponen_cn01,
l_ref_entity TYPE REF TO if_bol_bo_property_access,
lv_row_index TYPE i,
lv_event_name TYPE string.
* Get context node from popup window
l_ref_outputnode ?= g_ref_decision_popup->get_context_node( ‘OUTPUTNODE’ ).
* Get selected row index and event
lv_row_index = l_ref_outputnode->get_selectedrowindex( ).
lv_event_name = l_ref_outputnode->get_event_name( ).
* Close popup
* Check if any row is selected
IF lv_event_name = ‘OK’.
* Get selected row from global table
READ TABLE gt_city INTO ls_city INDEX lv_row_index.
lv_event_name = ls_city–cityname.
* Assign F4 help value
iv_attr_name = ‘city’
iv_value = lv_event_name ).
and you are finally done. This will create a popup with all contents of the table, and on selection of the value it will be filled to the Text Field.
Thanks and Regards,