Custom SES TREX Functionality

Development
created by Satish Nair on Jun 26, 2012 11:17 AM, last modified by Satish Nair on Jun 26, 2012 11:43 AM
Version 1
inShare
Custom Development for enabling full-text search for Business Objects in
SAP
Custom SES TREX Functionality
Applies to:
SAP NetWeaver 2004s, mySAP ERP 2005
Created on:
19-06-2012
Author:
Satish Nair, Capgemini, M, Sr. Consultant, AppsOne

Summary:
The SAP NetWeaver Search Engine Service (SES) for business objects is a simple generic interface to enable
indexing and searching of business objects with TREX, SAP NetWeaver’s engine for search and classification. Any
business object in the sense of the Business Object Repository (BOR) can implement the SES methods and is then
subject to the SES features, including simple full text and fuzzy search as well as advanced attribute search. The
SES is part of the SAP NetWeaver Application Server (AS) ABAP.

Purpose:
There are search helps in SAP for which the SES TREX has not been enabled. SAP provides standard business
objects and their classes for which the TREX functionality can be enabled ( eg: Searching a material using it’s long
text by full text and fuzzy search functionality ). There are also, search helps in SAP for which SAP does not
provide standard classes for their business objects. In this case, it becomes imperative to develop their classes as per
requirement, so as to enable these business objects for full text and fuzzy search. ( eg: Searching a group task using
its header long text by full text and fuzzy search – This is for transaction code IA06/7 – Business object 1019 ).

Steps in Extending the Search Engine Service:
The PDF link below gives the procedure for Enabling and activating standard SAP Business objects for SES-TREX
functionality

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/a751a1ec-0a01-0010-f0ba-
89e4c5cd0261?QuickLink=index&overridelayout=true&5003637741546
Additional Business objects can be enabled for indexing and searching through SES.
The Steps involved for this are:
Custom Indexing Class
- Create a custom indexing Class i.e enable a new object for indexing. This object has to implement the interface
IF_COM_SE_BUSOBJ. Add attributes to be indexed for the new object. The attributes can contain the keys of the
base table associated with the business objects along with the short text / description field of this table.
- Add methods to this custom indexing class as per the available methods in the standard indexing class.
Code these methods as per the requirement.
- Additional methods can be added as per the requirement with appropriate coding.
- The above steps will cause the search help to include the short text / description field enabled in the search help.
- To add the long text of a transaction code to be included in the search help, do the following step in the custom
class:
1- Create a method within this custom class to read table STXH using FM ‘READ_TEXT’.
2- Call this method from the method ‘GET_ATTRIBUTE_VALUES’, within the loop when values of other
attributes are extracted.

Example: Create a custom indexing class ‘ZCL_ERP_SE_BUS1019’ for BUS1019. Implement interface
IF_COM_SE_BUSOBJ and add attributes as required as shown below.
Implement interface IF_COM_SE_BUSOBJ



Add Attributes as required


Code the available methods of the interface as per requirement. In BUS1019 the method
‘GET_ATTRIBUTE_VALUES’ is coded for BUS1019 for base table PLKO to extract attributes
PLNTY,
PLNNR, PLNAL and short text LTXT. Sample code for this method for extracting PLNTY is
shown
below:
Methods added:






Sample code for method GET_ATTRIBUTE_VALUES for extracting field PLNTY from table PLKO

LOOP AT lt_plko_total INTO ls_plko_total.
clear ls_object_ids.

* Common block
lr_assist->add_object( ls_object_ids ).
lr_assist->add_attribute_value(
iv_dd_obj = if_com_se_busobj_name_assist=>gc_de_business_object
iv_value = iv_busobj ).

* Header data
ld_attribute = gc_fieldname_plnty.
ld_value = ls_plko_total-plnty.
lr_assist->add_attribute_value(
iv_name = gc_fieldname_plnty
iv_dd_obj = gc_rollname_plnty
iv_value = ls_plko_total-plnty
iv_content_relevant = 'X' ).
endloop.

Additional method ‘ADD_TEXT_TO_CONTENT ‘ is added for extracting long text. This method
is
called from the method ‘GET_ATTRIBUTE_VALUE’. The code snippet for this method is given
below:

CALL FUNCTION 'READ_TEXT'
exporting
id = iv_id
language = iv_langu
name = iv_name
object = lc_object
tables
lines = lt_tline
exceptions
others = 0.

CALL FUNCTION 'CONVERT_ITF_TO_ASCII'
EXPORTING
tab_substitute = ' 1'
IMPORTING
c_datatab = lt_ascii
TABLES
itf_lines = lt_tline.


IF NOT lt_ascii IS INITIAL.
LOOP AT lt_ascii ASSIGNING <lv_ascii>.
CONCATENATE ls_content-content <lv_ascii>
INTO ls_content-content
SEPARATED BY space.
endloop.
endif.
if not ls_content-content is initial.
call method ir_assist->add_content
exporting
iv_value = ls_content-content.
endif.






Configuration (SPRO) Steps:

- Do configuration for the SES functionality of this business object whose path is as given below:

- Add entries for the business object and do its settings as given in below screen shots:




Search Engine Service Administration:

- Using transaction code SES_ADMIN, create this custom index entry and execute its full indexing.


Search Help Creation:

- Create two custom elementary search helps i.e the QUICK and ADVANCED Search help. Use search help exit
COM_SE_F4_HELP_EXIT in their definition. The search help parameters required should be the attributes of the
base table used in the above created custom class.
- Create a custom collective search help which includes both of these elementary search helps. Append this custom
collective search help to the SAP standard Collective Search help of the Field in the transaction code of the business
object for which this functionality is developed.


Final Output:

- After development and activation two separate search modes are added as tab strips to the F4 search help of the
field.
Eg: Screen shot of F4 for material field of transaction code MM02/3 after SES- TREX enablement:


Related Content:
Complete documentation of Business Object Search with SES for developers, including a demo example
(SFLIGHT_SES)
http://help.sap.com/saphelp_nw04s/helpdata/en/6a/9d9d427cab0831e10000000a1550b0/frameset.htm
Administration of the Search Engine Service
http://help.sap.com/saphelp_erp2005/helpdata/en/27/08ef417fc65f24e10000000a1550b0/frameset.htm
TREX RFC connection
http://help.sap.com/saphelp_erp2005/helpdata/en/19/752e4241f51a2ae10000000a1550b0/frameset.htmReference 2