Skip to Content

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.


Image1.jpg

Consider an Internal Table ZCITY as below,

Image1.jpg

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.

Image3.jpg

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.

METHOD constructor.
CALL METHOD super->constructor.

* Get all rows from desired tables
SELECT *
FROM zcity
INTO TABLE gt_city.

IF sysubrc <> 0.
* Error Message
ENDIF.
ENDMETHOD.

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
               
type cl_bsp_wd_valuehelp_navdescr
               
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.

METHOD op_valuehelp.
 
FREE g_ref_decision_popup.
* Create decision popup
g_ref_decision_popup
=

        comp_controller->window_manager->create_decision_popup(
                                                        iv_title
= ‘City Selection’
                                                        iv_visible_row_count
= 10
                                                        iv_display_table
= gt_city ).
* Assign close event CONFIRM_POPUP_CLOSED
g_ref_decision_popup
->set_on_close_event(

                            iv_event_name = ‘CONFIRM_POPUP_CLOSED’
                            iv_view
= me ).      
* Open popup
g_ref_decision_popup
->open( ).

ENDMETHOD.



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.

METHOD eh_onconfirm_popup_closed.
DATA:
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
g_ref_decision_popup
->close( ).

* 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.
l_ref_entity ?=

          me->typed_context->city->collection_wrapper->get_current( ).
lv_event_name
= ls_citycityname.

* Assign F4 help value
l_ref_entity
->set_property_as_string(

                     iv_attr_name = ‘city’

                                       iv_value = lv_event_name ).

ENDIF.
ENDMETHOD.

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,

Pratheek


To report this post you need to login first.

2 Comments

You must be Logged on to comment or reply to a post.

Leave a Reply