SAP TREX_EXT_AGGREGATE Function Module for Calculates aggregation
TREX_EXT_AGGREGATE is a standard trex ext aggregate SAP function module available within SAP R/3 or S/4 Hana systems, depending on your version and release level. It is used for Calculates aggregation 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 aggregate FM, simply by entering the name TREX_EXT_AGGREGATE into the relevant SAP transaction such as SE37 or SE38.
Function Group: TREX_EXT_TM
Program Name: SAPLTREX_EXT_TM
Main Program: SAPLTREX_EXT_TM
Appliation area:
Release date: N/A
Mode(Normal, Remote etc): Normal Function Module
Update:

Function TREX_EXT_AGGREGATE 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_AGGREGATE'"Calculates aggregation.
EXPORTING
I_INDEX_ID = "Index Id
* I_REQUESTED_RESULTS = 6 "6: Aggregate requested (other value obsolete)
* I_JOIN_CONDITIONS = "Static join condition
* I_KEY_FIGURES = "Key figures
* I_INDEX_ALIAS_OPERATION = "Index Alias Operation
* I_TOP_TYPE = 0 "0, 1 (top k), 2 (top sum), 3 (top percent)
* I_TOP_VALUE = '' "
* I_TOP_MAX_EQUALS = 0 "
* I_NULL_SID = "Null sid for olap count distinct queries
* I_STAR_COUNT = "Star count
* I_FACTOR_KEY_FIGURES = "Factor key figures
* I_SCHEMA_NAME = '' "HDB only: schema name
* I_FACTOR_ATTRIBUTES = "Factor attributes
I_COMP_DESCR = "Description of the aggregation result table
* I_STAGING = 0 "Obsolete
* I_QUERY_ID = "Query Id for tracing
* I_SWITCH_ON_TRACE = "1: python trace, 2: executor (plan), 3:1+ 2
* I_TRACE_COMPONENTS = "Trace components
* I_USE_DFI = 0 "DimFunction Index: 0 default, 1 on, 2 off
* I_DEBUG_COMMANDS = "Debug commands
* I_PLACEHOLDERS = "Placeholder
* I_ACCEPT_DATA_LOSS = ABAP_FALSE "Obsolete
* I_RFC_DESTINATION = "RFC Destination
* I_VALUE_HANDLING = '' "Optional: Value handling for call transformation
* I_CALCULATION_VIEW = '' "Calculation view
* I_RESULT_INDEX_NAME = "Index Id for Result Index
* I_COMMIT_ID = "
* I_REQUEST_FLAGS = "Only numeric chars with max. length 19 are accepted.
* I_HAVING_FILTER = '' "
* I_RESULT_CHUNK_SIZE = 0 "TREX only: Result chunk size (number of cells)
* I_RESULT_CHUNK_SIZE_ROW = 0 "Result chunk size (number of rows) N2206286: Overrides number of cells
* I_CALC_MODEL = "HANA only: calculation model
* I_RESULT_FROM = 1 "from
* I_RESULT_TO = 0 "to
I_QUERY_ENTRIES = "Query Entries
* I_SORT_ATTRIBUTES = "Sort attributes
* I_REQ_ATTRIBUTES = "Requested attributes
* I_REQ_ATTRIBUTES_2 = "Requested attributes (enhanced)
IMPORTING
E_RETURN_CODE = "Return code
E_HANDLE_ID = "HANA only: Handle id for TREX_EXT_GET_NEXT_AGGR_RESULT
E_RETURN_TEXT = "Return text
E_RETURN_TEXT_LONG = "HANA only: Return text (no truncation)
E_COMPONENT_RUNTIME = "Run time of the TREX components
E_TRACE = "Trace
E_DFI_USED = "
E_MORE_PACKAGES = "1: more packages to be transferred
E_NO_OF_HITS = "Number of hits returned
E_NO_OF_ALL_HITS = "Total number of hits in index
CHANGING
* C_AGGREGATION_RESULT = "BW only: Aggregation result
EXCEPTIONS
CONVERSION_ERROR = 1 ERROR = 2
IMPORTING Parameters details for TREX_EXT_AGGREGATE
I_INDEX_ID - Index Id
Data type: TREX_RFC-INDEX_IDOptional: No
Call by Reference: Yes
I_REQUESTED_RESULTS - 6: Aggregate requested (other value obsolete)
Data type: TREX_RFC-REQUESTED_RESULTSDefault: 6
Optional: Yes
Call by Reference: Yes
I_JOIN_CONDITIONS - Static join condition
Data type: TREXT_STATIC_JOIN_CONDITIONOptional: Yes
Call by Reference: Yes
I_KEY_FIGURES - Key figures
Data type: TREXT_KEY_FIGUREOptional: Yes
Call by Reference: Yes
I_INDEX_ALIAS_OPERATION - Index Alias Operation
Data type: TREXT_INDEX_ALIAS_OPERATIONOptional: Yes
Call by Reference: Yes
I_TOP_TYPE - 0, 1 (top k), 2 (top sum), 3 (top percent)
Data type: TREX_RFC-TOP_TYPEOptional: Yes
Call by Reference: Yes
I_TOP_VALUE -
Data type: TREX_RFC-TOP_VALUEDefault: ''
Optional: Yes
Call by Reference: Yes
I_TOP_MAX_EQUALS -
Data type: TREX_RFC-MAX_RESULTSOptional: Yes
Call by Reference: Yes
I_NULL_SID - Null sid for olap count distinct queries
Data type: IOptional: Yes
Call by Reference: Yes
I_STAR_COUNT - Star count
Data type: TREXT_STAR_COUNTOptional: Yes
Call by Reference: Yes
I_FACTOR_KEY_FIGURES - Factor key figures
Data type: TREXT_FACTOR_KEY_FIGURESOptional: Yes
Call by Reference: Yes
I_SCHEMA_NAME - HDB only: schema name
Data type: TREX_RFC-INDEX_IDDefault: ''
Optional: No
Call by Reference: Yes
I_FACTOR_ATTRIBUTES - Factor attributes
Data type: TREXT_FACTOR_ATTRIBUTESOptional: Yes
Call by Reference: Yes
I_COMP_DESCR - Description of the aggregation result table
Data type: TREXT_COMP_DESCROptional: No
Call by Reference: Yes
I_STAGING - Obsolete
Data type: TREX_RFC-BOOLEANOptional: Yes
Call by Reference: Yes
I_QUERY_ID - Query Id for tracing
Data type: TREX_RFC-QUERY_IDOptional: Yes
Call by Reference: Yes
I_SWITCH_ON_TRACE - 1: python trace, 2: executor (plan), 3:1+ 2
Data type: NUMC2Optional: Yes
Call by Reference: Yes
I_TRACE_COMPONENTS - Trace components
Data type: CHAR128Optional: Yes
Call by Reference: Yes
I_USE_DFI - DimFunction Index: 0 default, 1 on, 2 off
Data type: TREX_RFC-BOOLEANOptional: Yes
Call by Reference: Yes
I_DEBUG_COMMANDS - Debug commands
Data type: CHAR128Optional: Yes
Call by Reference: Yes
I_PLACEHOLDERS - Placeholder
Data type: TREXT_PLACEHOLDERSOptional: Yes
Call by Reference: Yes
I_ACCEPT_DATA_LOSS - Obsolete
Data type: ABAP_BOOLDefault: ABAP_FALSE
Optional: Yes
Call by Reference: Yes
I_RFC_DESTINATION - RFC Destination
Data type: TREX_RFC-RFC_DESTINATIONOptional: Yes
Call by Reference: Yes
I_VALUE_HANDLING - Optional: Value handling for call transformation
Data type: STRINGDefault: ''
Optional: Yes
Call by Reference: Yes
I_CALCULATION_VIEW - Calculation view
Data type: STRINGDefault: ''
Optional: Yes
Call by Reference: Yes
I_RESULT_INDEX_NAME - Index Id for Result Index
Data type: TREXD_INDEX_IDOptional: Yes
Call by Reference: Yes
I_COMMIT_ID -
Data type: TREXD_TRANSACTION_IDOptional: Yes
Call by Reference: Yes
I_REQUEST_FLAGS - Only numeric chars with max. length 19 are accepted.
Data type: CLIKEOptional: Yes
Call by Reference: Yes
I_HAVING_FILTER -
Data type: STRINGDefault: ''
Optional: Yes
Call by Reference: Yes
I_RESULT_CHUNK_SIZE - TREX only: Result chunk size (number of cells)
Data type: INT4Optional: Yes
Call by Reference: Yes
I_RESULT_CHUNK_SIZE_ROW - Result chunk size (number of rows) N2206286: Overrides number of cells
Data type: INT4Optional: Yes
Call by Reference: Yes
I_CALC_MODEL - HANA only: calculation model
Data type: STRINGOptional: Yes
Call by Reference: Yes
I_RESULT_FROM - from
Data type: IDefault: 1
Optional: Yes
Call by Reference: Yes
I_RESULT_TO - to
Data type: IOptional: Yes
Call by Reference: Yes
I_QUERY_ENTRIES - Query Entries
Data type: TREXT_QUERY_ENTRIESOptional: No
Call by Reference: Yes
I_SORT_ATTRIBUTES - Sort attributes
Data type: TREXT_SORT_ATTRIBUTESOptional: Yes
Call by Reference: Yes
I_REQ_ATTRIBUTES - Requested attributes
Data type: TREXT_ATTRIBUTESOptional: Yes
Call by Reference: Yes
I_REQ_ATTRIBUTES_2 - Requested attributes (enhanced)
Data type: TREXT_REQ_ATTRIBUTES_EXTOptional: Yes
Call by Reference: Yes
EXPORTING Parameters details for TREX_EXT_AGGREGATE
E_RETURN_CODE - Return code
Data type: TREX_RFC-RETURN_CODEOptional: No
Call by Reference: Yes
E_HANDLE_ID - HANA only: Handle id for TREX_EXT_GET_NEXT_AGGR_RESULT
Data type: STRINGOptional: No
Call by Reference: Yes
E_RETURN_TEXT - Return text
Data type: TREX_RFC-RETURN_TEXTOptional: No
Call by Reference: Yes
E_RETURN_TEXT_LONG - HANA only: Return text (no truncation)
Data type: STRINGOptional: No
Call by Reference: Yes
E_COMPONENT_RUNTIME - Run time of the TREX components
Data type: TREXS_COMPONENT_RUNTIMEOptional: No
Call by Reference: Yes
E_TRACE - Trace
Data type: TREXT_LINES_WITH_LBOptional: No
Call by Reference: Yes
E_DFI_USED -
Data type: TREX_RFC-BOOLEANOptional: No
Call by Reference: Yes
E_MORE_PACKAGES - 1: more packages to be transferred
Data type: TREX_RFC-BOOLEANOptional: No
Call by Reference: Yes
E_NO_OF_HITS - Number of hits returned
Data type: IOptional: No
Call by Reference: Yes
E_NO_OF_ALL_HITS - Total number of hits in index
Data type: IOptional: No
Call by Reference: Yes
CHANGING Parameters details for TREX_EXT_AGGREGATE
C_AGGREGATION_RESULT - BW only: Aggregation result
Data type: STANDARD TABLEOptional: Yes
Call by Reference: Yes
EXCEPTIONS details
CONVERSION_ERROR - Error during conversion
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
ERROR - Error, see error message
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
Copy and paste ABAP code example for TREX_EXT_AGGREGATE 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_e_return_code | TYPE TREX_RFC-RETURN_CODE, " | |||
| lv_conversion_error | TYPE TREX_RFC, " | |||
| lv_c_aggregation_result | TYPE STANDARD TABLE, " | |||
| lv_e_handle_id | TYPE STRING, " | |||
| lv_i_requested_results | TYPE TREX_RFC-REQUESTED_RESULTS, " 6 | |||
| lv_i_join_conditions | TYPE TREXT_STATIC_JOIN_CONDITION, " | |||
| lv_i_key_figures | TYPE TREXT_KEY_FIGURE, " | |||
| lv_i_index_alias_operation | TYPE TREXT_INDEX_ALIAS_OPERATION, " | |||
| lv_i_top_type | TYPE TREX_RFC-TOP_TYPE, " 0 | |||
| lv_i_top_value | TYPE TREX_RFC-TOP_VALUE, " '' | |||
| lv_i_top_max_equals | TYPE TREX_RFC-MAX_RESULTS, " 0 | |||
| lv_i_null_sid | TYPE I, " | |||
| lv_i_star_count | TYPE TREXT_STAR_COUNT, " | |||
| lv_i_factor_key_figures | TYPE TREXT_FACTOR_KEY_FIGURES, " | |||
| lv_error | TYPE TREXT_FACTOR_KEY_FIGURES, " | |||
| lv_e_return_text | TYPE TREX_RFC-RETURN_TEXT, " | |||
| lv_i_schema_name | TYPE TREX_RFC-INDEX_ID, " '' | |||
| lv_i_factor_attributes | TYPE TREXT_FACTOR_ATTRIBUTES, " | |||
| lv_i_comp_descr | TYPE TREXT_COMP_DESCR, " | |||
| lv_i_staging | TYPE TREX_RFC-BOOLEAN, " 0 | |||
| lv_i_query_id | TYPE TREX_RFC-QUERY_ID, " | |||
| lv_i_switch_on_trace | TYPE NUMC2, " | |||
| lv_i_trace_components | TYPE CHAR128, " | |||
| lv_i_use_dfi | TYPE TREX_RFC-BOOLEAN, " 0 | |||
| lv_i_debug_commands | TYPE CHAR128, " | |||
| lv_i_placeholders | TYPE TREXT_PLACEHOLDERS, " | |||
| lv_i_accept_data_loss | TYPE ABAP_BOOL, " ABAP_FALSE | |||
| lv_i_rfc_destination | TYPE TREX_RFC-RFC_DESTINATION, " | |||
| lv_e_return_text_long | TYPE STRING, " | |||
| lv_i_value_handling | TYPE STRING, " '' | |||
| lv_i_calculation_view | TYPE STRING, " '' | |||
| lv_i_result_index_name | TYPE TREXD_INDEX_ID, " | |||
| lv_i_commit_id | TYPE TREXD_TRANSACTION_ID, " | |||
| lv_i_request_flags | TYPE CLIKE, " | |||
| lv_i_having_filter | TYPE STRING, " '' | |||
| lv_i_result_chunk_size | TYPE INT4, " 0 | |||
| lv_i_result_chunk_size_row | TYPE INT4, " 0 | |||
| lv_i_calc_model | TYPE STRING, " | |||
| lv_i_result_from | TYPE I, " 1 | |||
| lv_e_component_runtime | TYPE TREXS_COMPONENT_RUNTIME, " | |||
| lv_e_trace | TYPE TREXT_LINES_WITH_LB, " | |||
| lv_i_result_to | TYPE I, " 0 | |||
| lv_e_dfi_used | TYPE TREX_RFC-BOOLEAN, " | |||
| lv_i_query_entries | TYPE TREXT_QUERY_ENTRIES, " | |||
| lv_e_more_packages | TYPE TREX_RFC-BOOLEAN, " | |||
| lv_i_sort_attributes | TYPE TREXT_SORT_ATTRIBUTES, " | |||
| lv_e_no_of_hits | TYPE I, " | |||
| lv_i_req_attributes | TYPE TREXT_ATTRIBUTES, " | |||
| lv_e_no_of_all_hits | TYPE I, " | |||
| lv_i_req_attributes_2 | TYPE TREXT_REQ_ATTRIBUTES_EXT. " |
|   CALL FUNCTION 'TREX_EXT_AGGREGATE' "Calculates aggregation |
| EXPORTING | ||
| I_INDEX_ID | = lv_i_index_id | |
| I_REQUESTED_RESULTS | = lv_i_requested_results | |
| I_JOIN_CONDITIONS | = lv_i_join_conditions | |
| I_KEY_FIGURES | = lv_i_key_figures | |
| I_INDEX_ALIAS_OPERATION | = lv_i_index_alias_operation | |
| I_TOP_TYPE | = lv_i_top_type | |
| I_TOP_VALUE | = lv_i_top_value | |
| I_TOP_MAX_EQUALS | = lv_i_top_max_equals | |
| I_NULL_SID | = lv_i_null_sid | |
| I_STAR_COUNT | = lv_i_star_count | |
| I_FACTOR_KEY_FIGURES | = lv_i_factor_key_figures | |
| I_SCHEMA_NAME | = lv_i_schema_name | |
| I_FACTOR_ATTRIBUTES | = lv_i_factor_attributes | |
| I_COMP_DESCR | = lv_i_comp_descr | |
| I_STAGING | = lv_i_staging | |
| I_QUERY_ID | = lv_i_query_id | |
| I_SWITCH_ON_TRACE | = lv_i_switch_on_trace | |
| I_TRACE_COMPONENTS | = lv_i_trace_components | |
| I_USE_DFI | = lv_i_use_dfi | |
| I_DEBUG_COMMANDS | = lv_i_debug_commands | |
| I_PLACEHOLDERS | = lv_i_placeholders | |
| I_ACCEPT_DATA_LOSS | = lv_i_accept_data_loss | |
| I_RFC_DESTINATION | = lv_i_rfc_destination | |
| I_VALUE_HANDLING | = lv_i_value_handling | |
| I_CALCULATION_VIEW | = lv_i_calculation_view | |
| I_RESULT_INDEX_NAME | = lv_i_result_index_name | |
| I_COMMIT_ID | = lv_i_commit_id | |
| I_REQUEST_FLAGS | = lv_i_request_flags | |
| I_HAVING_FILTER | = lv_i_having_filter | |
| I_RESULT_CHUNK_SIZE | = lv_i_result_chunk_size | |
| I_RESULT_CHUNK_SIZE_ROW | = lv_i_result_chunk_size_row | |
| I_CALC_MODEL | = lv_i_calc_model | |
| I_RESULT_FROM | = lv_i_result_from | |
| I_RESULT_TO | = lv_i_result_to | |
| I_QUERY_ENTRIES | = lv_i_query_entries | |
| I_SORT_ATTRIBUTES | = lv_i_sort_attributes | |
| I_REQ_ATTRIBUTES | = lv_i_req_attributes | |
| I_REQ_ATTRIBUTES_2 | = lv_i_req_attributes_2 | |
| IMPORTING | ||
| E_RETURN_CODE | = lv_e_return_code | |
| E_HANDLE_ID | = lv_e_handle_id | |
| E_RETURN_TEXT | = lv_e_return_text | |
| E_RETURN_TEXT_LONG | = lv_e_return_text_long | |
| E_COMPONENT_RUNTIME | = lv_e_component_runtime | |
| E_TRACE | = lv_e_trace | |
| E_DFI_USED | = lv_e_dfi_used | |
| E_MORE_PACKAGES | = lv_e_more_packages | |
| E_NO_OF_HITS | = lv_e_no_of_hits | |
| E_NO_OF_ALL_HITS | = lv_e_no_of_all_hits | |
| CHANGING | ||
| C_AGGREGATION_RESULT | = lv_c_aggregation_result | |
| EXCEPTIONS | ||
| CONVERSION_ERROR = 1 | ||
| ERROR = 2 | ||
| . " TREX_EXT_AGGREGATE | ||
ABAP code using 7.40 inline data declarations to call FM TREX_EXT_AGGREGATE
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 REQUESTED_RESULTS FROM TREX_RFC INTO @DATA(ld_i_requested_results). | ||||
| DATA(ld_i_requested_results) | = 6. | |||
| "SELECT single TOP_TYPE FROM TREX_RFC INTO @DATA(ld_i_top_type). | ||||
| "SELECT single TOP_VALUE FROM TREX_RFC INTO @DATA(ld_i_top_value). | ||||
| DATA(ld_i_top_value) | = ''. | |||
| "SELECT single MAX_RESULTS FROM TREX_RFC INTO @DATA(ld_i_top_max_equals). | ||||
| "SELECT single RETURN_TEXT FROM TREX_RFC INTO @DATA(ld_e_return_text). | ||||
| "SELECT single INDEX_ID FROM TREX_RFC INTO @DATA(ld_i_schema_name). | ||||
| DATA(ld_i_schema_name) | = ''. | |||
| "SELECT single BOOLEAN FROM TREX_RFC INTO @DATA(ld_i_staging). | ||||
| "SELECT single QUERY_ID FROM TREX_RFC INTO @DATA(ld_i_query_id). | ||||
| "SELECT single BOOLEAN FROM TREX_RFC INTO @DATA(ld_i_use_dfi). | ||||
| DATA(ld_i_accept_data_loss) | = ABAP_FALSE. | |||
| "SELECT single RFC_DESTINATION FROM TREX_RFC INTO @DATA(ld_i_rfc_destination). | ||||
| DATA(ld_i_value_handling) | = ''. | |||
| DATA(ld_i_calculation_view) | = ''. | |||
| DATA(ld_i_having_filter) | = ''. | |||
| DATA(ld_i_result_from) | = 1. | |||
| "SELECT single BOOLEAN FROM TREX_RFC INTO @DATA(ld_e_dfi_used). | ||||
| "SELECT single BOOLEAN FROM TREX_RFC INTO @DATA(ld_e_more_packages). | ||||
Search for further information about these or an SAP related objects