Você está na página 1de 13

Search UIBB

This tutorial explains how to make use of generic component (FPM_SEARCH_UIBB) for the
purpose of creating search criteria and result.
This tutorial is split into two parts
1. Modelling the Feeder class
2. Configuring the Search component with feeder class
Part 1: Modelling the feeder class
Scenario: You are supposed to model a feeder class that provides the search functionality to
retrieve flight information from the table SFLIGHT.
Step 1: Go the transaction class builder (SE24) and create a class.

Step 2: In the interface tab of the class, implement the interface IF_FPM_GUIBB_SEARCH.
This interface also implements an interface IF_FPM_GUIBB along with it.

Note: All the methods of the interfaces are supposed to be implemented manually. When I
include an interface it only creates the definition part by listing the methods in the methods tab.
When I say implement the method of interface, it means double click on the method and activate
the method individually even if the method is going to be empty or not going to be used by you
all the time. The reason is that all the methods are called in a sequence in the runtime framework
as below. If the sequence of method being called is not implemented then system throws a dump.

Note: Get data method is like PBO and is called every time before displaying the screen.
If the data to be displayed has been modified and if the EV_DATA_CHANGED parameter of
the GET_DATA has not been set to true then the changes will not reflect on the screen. Which
means the system will not render the particular portion of the screen again. So use the parameter
wisely so that it is set to true only screen needs to be changed. It can optimize your performance.
Step 3: In the attributes tab of the class create the attributes as shown below.
Two attributes structure and internal table for the table has been created in the class. The purpose
of structure is to build the layout for the search criteria and the internal table is to store the result
from the search criteria as well as to define the layout of the output table.

The internal table has been declared programmatically.

Step 4: Write the following code in the GET_DEFINITION method.

data : wa_fields type dfies, " Work area dicitonary field attributes
it_fields type ddfields, " Internal table Dicitonary field attributes
ls_field_desc like line of et_field_description_result. " Work area result
column description
* Creating the field catalog
eo_field_catalog_attr ?= cl_abap_structdescr=>describe_by_data( ms_sflight ).
* Assigning the result catalog
eo_field_catalog_result ?= cl_abap_tabledescr=>describe_by_data( mt_sflight )
.
* Assigning field description
it_fields = eo_field_catalog_attr->get_ddic_field_list( ).
loop at it_fields into wa_fields.
ls_field_desc-name = wa_fields-fieldname.
ls_field_desc-text = wa_fields-fieldtext.
append ls_field_desc to et_field_description_result.
clear ls_field_desc.
endloop.

Code Explanation:
GET_DEFINITION method of the feeder class is called by the FPM framework at the time of
configuration to get the necessary layout to be built on the screen. This method has three
important parameters which are to be filled.
1. EO_FIELD_CATALOG_ATTR
2. EO_FIELD_CATALOG_RESULT
3. ET_FIELD_DESCRIPTION_RESULT
EO_FIELD_CATALOG_ATTR: This exporting variable is of type
CL_ABAP_STRUCTDESCR and it used to export the object reference of the structure for which
we are going to create search criteria. In our example, we are going to retrieve the value from the
SFLIGHT Table based on the selection criteria of the same table. Hence with the RTTI services
we have created the object reference for the structure MS_FLIGHT and passed it to the Field
catalog attribute. Since the method returns the object reference of type
CL_ABAP_TYPE_DESCRIPTION which is more generic to the type of target variable
widening cast is being done.
EO_FIELD_CATALOG_RESULT: This exporting variable is of type
CL_ABAP_TABLEDESCR and is used to export the object reference of table which is going to
be displayed as the result. This structure determines the columns of the table to be displayed.
Hence with RTTI services we have created the object reference for the table MT_SFLIGHT and
passed it to the EO_FIELD_CATALOG_RESULT parameter.
ET_FIELD_DESCRIPTION_RESULT: This exporting parameter is an internal which is
needs to be filled for the purpose of providing the column description for the table. We need to
fill the field name and field text in the table. I have retrieved the field name and field text with
RTTI class and passed the value to it. This internal can also be filled through hard coding.

Step 5: Implement the method PROCESS_EVENT as below.

data : lt_where_string type rsds_where_tab.
data : lo_exe type ref to cx_fpmgb.
check io_event->mv_event_id = if_fpm_guibb_search=>fpm_execute_search.
* Convert the search query into sql string
try.
cl_fpm_guibb_search_conversion=>to_abap_select_where_tab(
exporting
it_fpm_search_criteria = it_fpm_search_criteria " search criteria for GUIB
B Search
iv_table_name = 'SFLIGHT' " Table Name
* io_field_catalog = " Runtime Type Service
s
importing
et_abap_select_table = lt_where_string
).
catch cx_fpmgb into lo_exe. " GUIBB Exceptions
* Exception part handled here
endtry.
* Fetching the result
select *
from sflight
into table mt_sflight
up to iv_max_num_results rows
where (lt_where_string).

Code Explanation:
When user enter the selection criteria and click on search button we are supposed to retrieve
value for the search criteria. The importing parameter IO_EVENT contains the event id for the
action triggered on the screen using which the code blocks for the event handling can be
segregated. This method also has an importing parameter named
IT_FPM_SEARCH_CRITERIA which contain the selection criteria entered by the user on the
screen. SAP has also provided with a standard class to convert the user entered search criteria
into condition string or select option etc. Hence making use of the standard functionality
available I am converting the selection criteria into selection condition string and pass it on to
table to retrieve the result. The result is stored in the attribute of the class.
Step 6: Implement the following code in the GET_DATA method.

check io_event->mv_event_id = if_fpm_guibb_search=>fpm_execute_search.
et_result_list = mt_sflight.
Code Explanation:
I am passing the result set from the class attribute to the screen by checking the FPM event
triggered.
This completes the modelling the feeder class. Lets go and take a look at configuring the
component for search (FPM_SEARCH_UIBB) with the information from feeder class.

Part 2: Configuration of Search component with feeder class modelled.
Note: All the demo applications will be created using the OVP floor plan in this tutorial.
Whenever system throws an error that configuration does not exist in this tutorial click on new to
create the configuration.
Step 1: Create an application for the OVP component FPM_OVP_COMPONENT.

Step 2: Right click on the application and create the application configuration.

Enter the name for the application and click on new.

Enter the description and assign it to a package.
Step 3: Create a component configuration for the component OVP. Click on the button assign
component configuration and enter the name for the component configuration.

By assigning the name for the component configuration a link will appear in the column
configuration name. Click on the link, the system will display a message as component
configuration does not exist. Click new to create the component configurations.

Enter a description and assign the package to it.
Step 4: In the FLUID designer, add the Search UIBB as shown below. Choose the UIBB from
the list of UIBB available.

Select the UIBB enter the name for the feeder class configuration and click enter. You will get a
message stating the configuration does not exist. Select the lead for the UIBB and click on
configure UIBB. Create a new configuration.

A popup will prompt for the feeder class, enter the name of the feeder class created and click on
edit parameters. Since we have not added any parameters in the GET_PARAMETERS method
system will display a message. Click on ok to continue.

Note: GET_DEFAULT parameters, CHECK_CONFIGURATION,
GET_DEFAULT_CONFIGURATION and GET_DEFINITON method of the feeder class will
be called by the time you click on configure.

Step 5: Add the search criteria by clicking the search criteria button.

A pop up will appear with the list of fields in the structure SFLIGHT. Choose the selection
criteria you want. In this example I am going to select all the fields as the search criteria and
restrict the search criteria display to 3 so that only three fields are initially shown as search
criteria and user can add any fields later in the screen as search criteria.

You can now see the search criteria in the preview panel. The no of search criteria by default is
set to 4 so you will see four fields. The top four columns on the list will be displayed over there.
Here I am moving the flight date to 3
rd
position and setting the no of search fields as 3 in the
general settings panel.
Step 6: Now to add the columns for the result table click on the button columns of result list. You
can also select a list UIBB and transfer the result data to the list UIBB.

A popup will appear asking you to select the fields for the column choose the required field and
click on ok.
In the preview panel you will be able to see the search criteria and its result table being created.

I have modified the general settings with below value.

Check and save the configuration.
Test the application:

Output:

Note: If we wanted to fill the values for the drop down for Airline, then we are supposed to fill
the value in the parameter ET_FIELD_DESCRIPTION_ATTR. Attribute ENUMERATION has
to be filled with the value set.
This Example illustrates how to set a search criteria using Generic Search UIBB and display the
result in the result table of the search UIBB, in the later tutorials we will further expand this
application so as to display the result in the List UIBB and not in that of Search UIBB this will
help us learn the possibilities of data transfer from one UIBB to another UIBB using static
attributes of the feeder class and Singleton concept.

Você também pode gostar