SAP TREX_EXT_INDEX Function Module for Index Documents
TREX_EXT_INDEX is a standard trex ext index SAP function module available within SAP R/3 or S/4 Hana systems, depending on your version and release level. It is used for Index Documents processing and below is the pattern details for this FM, showing its interface including any import and export parameters, exceptions etc. there is also a full "cut and paste" ABAP pattern code example, along with implementation ABAP coding, documentation and contribution comments specific to this or related objects.
See here to view full function module documentation and code listing for trex ext index FM, simply by entering the name TREX_EXT_INDEX into the relevant SAP transaction such as SE37 or SE38.
Function Group: TREX_EXT_INDEX
Program Name: SAPLTREX_EXT_INDEX
Main Program: SAPLTREX_EXT_INDEX
Appliation area:
Release date: N/A
Mode(Normal, Remote etc): Normal Function Module
Update:

Function TREX_EXT_INDEX pattern details
In-order to call this FM within your sap programs, simply using the below ABAP pattern details to trigger the function call...or see the full ABAP code listing at the end of this article. You can simply cut and paste this code into your ABAP progrom as it is, including variable declarations.CALL FUNCTION 'TREX_EXT_INDEX'"Index Documents.
EXPORTING
I_INDEX_ID = "IndexId
I_RFC_DESTINATION = "RFC Destination
* I_INDEXSERVER_LOCATION = "Host:Port
* I_USE_QUEUESERVER = 'X' "Use QueueServer
* I_KEEP_LUW = '' "Only for debugging: keep logical unit of work
* I_FLUSH_AFTER_INDEX = '' "Flush documents after indexing
I_INDEX_DOCUMENT_LIST = "Documents for indexing
* I_TRANSACTION_ID = "obsolete
I_AUTO_OPTIMIZE = 0 "1: Optimization is done after indexing
IMPORTING
E_RETURN_ERROR_DOC = "Error documents
E_RETURN_CODE = "Return code
E_RETURN_TEXT = "Return text
E_COMPONENT_RUNTIME = "run time of the trex components
EXCEPTIONS
CONVERSION_ERROR = 1 RFCSERVER_ERROR = 2 ERROR = 3
IMPORTING Parameters details for TREX_EXT_INDEX
I_INDEX_ID - IndexId
Data type: TREX_RFC-INDEX_IDOptional: No
Call by Reference: Yes
I_RFC_DESTINATION - RFC Destination
Data type: TREX_RFC-RFC_DESTINATIONOptional: No
Call by Reference: Yes
I_INDEXSERVER_LOCATION - Host:Port
Data type: TREX_RFC-LOCATIONOptional: Yes
Call by Reference: Yes
I_USE_QUEUESERVER - Use QueueServer
Data type: TREX_RFC-FLAGDefault: 'X'
Optional: Yes
Call by Reference: Yes
I_KEEP_LUW - Only for debugging: keep logical unit of work
Data type: TREX_RFC-FLAGDefault: ''
Optional: No
Call by Reference: Yes
I_FLUSH_AFTER_INDEX - Flush documents after indexing
Data type: TREX_RFC-FLAGDefault: ''
Optional: Yes
Call by Reference: Yes
I_INDEX_DOCUMENT_LIST - Documents for indexing
Data type: TREXT_INDEX_DOCSOptional: No
Call by Reference: Yes
I_TRANSACTION_ID - obsolete
Data type: TREXD_TRANSACTION_IDOptional: Yes
Call by Reference: Yes
I_AUTO_OPTIMIZE - 1: Optimization is done after indexing
Data type: TREX_RFC-BOOLEANOptional: No
Call by Reference: Yes
EXPORTING Parameters details for TREX_EXT_INDEX
E_RETURN_ERROR_DOC - Error documents
Data type: TREXT_INDEX_DOCSOptional: No
Call by Reference: Yes
E_RETURN_CODE - Return code
Data type: TREX_RFC-RETURN_CODEOptional: No
Call by Reference: Yes
E_RETURN_TEXT - Return text
Data type: TREX_RFC-RETURN_TEXTOptional: No
Call by Reference: Yes
E_COMPONENT_RUNTIME - run time of the trex components
Data type: TREXS_COMPONENT_RUNTIMEOptional: No
Call by Reference: Yes
EXCEPTIONS details
CONVERSION_ERROR - Error during conversion to or from UTF-8
Data type:Optional: No
Call by Reference: Yes
RFCSERVER_ERROR - TREXRfcServer Error
Data type:Optional: No
Call by Reference: Yes
ERROR - Error, see error message
Data type:Optional: No
Call by Reference: Yes
Copy and paste ABAP code example for TREX_EXT_INDEX Function Module
The ABAP code below is a full code listing to execute function module POPUP_TO_CONFIRM including all data declarations. The code uses the original data declarations rather than the latest in-line data DECLARATION SYNTAX but I have included an ABAP code snippet at the end to show how declarations would look using the newer method of declaring data variables on the fly. This will allow you to compare and fully understand the new inline method. Please note some of the newer syntax such as the @DATA is not available until a later 4.70 service pack (SP8), which i why i have stuck to the origianl for this example.| DATA: | ||||
| lv_i_index_id | TYPE TREX_RFC-INDEX_ID, " | |||
| lv_conversion_error | TYPE TREX_RFC, " | |||
| lv_e_return_error_doc | TYPE TREXT_INDEX_DOCS, " | |||
| lv_e_return_code | TYPE TREX_RFC-RETURN_CODE, " | |||
| lv_rfcserver_error | TYPE TREX_RFC, " | |||
| lv_i_rfc_destination | TYPE TREX_RFC-RFC_DESTINATION, " | |||
| lv_error | TYPE TREX_RFC, " | |||
| lv_e_return_text | TYPE TREX_RFC-RETURN_TEXT, " | |||
| lv_i_indexserver_location | TYPE TREX_RFC-LOCATION, " | |||
| lv_i_use_queueserver | TYPE TREX_RFC-FLAG, " 'X' | |||
| lv_e_component_runtime | TYPE TREXS_COMPONENT_RUNTIME, " | |||
| lv_i_keep_luw | TYPE TREX_RFC-FLAG, " '' | |||
| lv_i_flush_after_index | TYPE TREX_RFC-FLAG, " '' | |||
| lv_i_index_document_list | TYPE TREXT_INDEX_DOCS, " | |||
| lv_i_transaction_id | TYPE TREXD_TRANSACTION_ID, " | |||
| lv_i_auto_optimize | TYPE TREX_RFC-BOOLEAN. " 0 |
|   CALL FUNCTION 'TREX_EXT_INDEX' "Index Documents |
| EXPORTING | ||
| I_INDEX_ID | = lv_i_index_id | |
| I_RFC_DESTINATION | = lv_i_rfc_destination | |
| I_INDEXSERVER_LOCATION | = lv_i_indexserver_location | |
| I_USE_QUEUESERVER | = lv_i_use_queueserver | |
| I_KEEP_LUW | = lv_i_keep_luw | |
| I_FLUSH_AFTER_INDEX | = lv_i_flush_after_index | |
| I_INDEX_DOCUMENT_LIST | = lv_i_index_document_list | |
| I_TRANSACTION_ID | = lv_i_transaction_id | |
| I_AUTO_OPTIMIZE | = lv_i_auto_optimize | |
| IMPORTING | ||
| E_RETURN_ERROR_DOC | = lv_e_return_error_doc | |
| E_RETURN_CODE | = lv_e_return_code | |
| E_RETURN_TEXT | = lv_e_return_text | |
| E_COMPONENT_RUNTIME | = lv_e_component_runtime | |
| EXCEPTIONS | ||
| CONVERSION_ERROR = 1 | ||
| RFCSERVER_ERROR = 2 | ||
| ERROR = 3 | ||
| . " TREX_EXT_INDEX | ||
ABAP code using 7.40 inline data declarations to call FM TREX_EXT_INDEX
The below ABAP code uses the newer in-line data declarations. This allows you to see the coding differences/benefits of the later inline syntax. Please note some of the newer syntax below, such as the @DATA is not available until 4.70 EHP 8.| "SELECT single INDEX_ID FROM TREX_RFC INTO @DATA(ld_i_index_id). | ||||
| "SELECT single RETURN_CODE FROM TREX_RFC INTO @DATA(ld_e_return_code). | ||||
| "SELECT single RFC_DESTINATION FROM TREX_RFC INTO @DATA(ld_i_rfc_destination). | ||||
| "SELECT single RETURN_TEXT FROM TREX_RFC INTO @DATA(ld_e_return_text). | ||||
| "SELECT single LOCATION FROM TREX_RFC INTO @DATA(ld_i_indexserver_location). | ||||
| "SELECT single FLAG FROM TREX_RFC INTO @DATA(ld_i_use_queueserver). | ||||
| DATA(ld_i_use_queueserver) | = 'X'. | |||
| "SELECT single FLAG FROM TREX_RFC INTO @DATA(ld_i_keep_luw). | ||||
| DATA(ld_i_keep_luw) | = ''. | |||
| "SELECT single FLAG FROM TREX_RFC INTO @DATA(ld_i_flush_after_index). | ||||
| DATA(ld_i_flush_after_index) | = ''. | |||
| "SELECT single BOOLEAN FROM TREX_RFC INTO @DATA(ld_i_auto_optimize). | ||||
Search for further information about these or an SAP related objects