*Copyright (c) 2009, J.Rumpf, www.web-dreamer.de / BSD Licence *All rights reserved. * *Redistribution and use in source and binary forms, with or without modification *are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, th * is list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * Neither the name of the owner nor the names of its contributors may be used * to endorse or promote products derived from this software without specific * prior written permission. * *THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND *ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED *WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE *FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL *DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR *SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER *CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, *OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. TYPE-POOLS: rsdrc. CONSTANTS: cube TYPE rsinfoprov VALUE 'ZYOURINFOPROVIDER'. DATA: cube_struct TYPE string, fact_struct TYPE string. "generic structure with ALL Characteristics and Keyfigures of the Cube CONCATENATE '/bic/v' cube 'j' INTO cube_struct. * cube_struct = 'YOUR_STRUCTURE'. "Facttable of the Cube - be carfull in Big Cubes - there is an 'f' and an 'g' CONCATENATE '/bic/v' cube 'f' INTO fact_struct. TYPES: t_cube_struct TYPE TABLE OF /BIC/VZYOURINFOPROVIDERJ "== Set on YOUR Target Structure or the content of cube_struct !!! WITH DEFAULT KEY INITIAL SIZE 0. DATA: e_th_sfc TYPE rsdri_th_sfc, "Characteristics of the Cube e_th_sfk TYPE rsdri_th_sfk, "Keyfigures of the cube line_of_e_th_sfc TYPE rsdri_s_sfc, line_of_e_th_sfk TYPE rsdri_s_sfk, ddic TYPE dd_x031l_table, "Datadictonary for later use ldic LIKE LINE OF ddic, "Ddic row fact_ddic TYPE dd_x031l_table, "fact_ddic my_structure TYPE REF TO data, "Structure of DDIC g_t_data TYPE t_cube_struct, "table-typ of return-table t_all_data TYPE t_cube_struct, "Table-type of return-table c_first_call TYPE rs_bool, " First-call r_seloption TYPE rsdri_t_range, "Selection-Table w_seloption TYPE LINE OF rsdri_t_range, "Selection-Row end_of_data TYPE rs_bool, "Last Call infoprov TYPE rsinfoprov " Infoprovider = cube . ********************************************************************** "Sometimes your Structure has Columns you don't have in your Cube " Here you can add this columns to be ignored by the cube. " !!! Please note - the function will aggregate on it's standard key figure behaviour " if you don't add all relevant primary keys! DATA: ignore_list TYPE STANDARD TABLE OF fieldname. ldic-fieldname = 'MY_IGNORE_COLUMN_NAME'. APPEND ldic-fieldname TO ignore_list. ********************************************************************** " From here you go with your selection on your cube - for each selection " you need to copy the following lines DATA: z_infoobjekt TYPE /bic/oiz_infoobjekt. " == Important because of the selection-type " Selection-Condition: z_infoobjekt = 'my_selection'. w_seloption-chanm = 'Z_INFOOBJEKT'. "technical name of InfoObjekt w_seloption-sign = 'I'. " Include w_seloption-compop = 'EQ'. " EQUAL w_seloption-low = z_infoobjekt. " APPEND w_seloption TO r_seloption. ********************************************************************** * No change from here necessary. FIELD-SYMBOLS: TYPE ANY. DATA: fact_ref TYPE REF TO cl_abap_structdescr. CREATE DATA my_structure TYPE (fact_struct). "Struktur-Objekt der Faktentabelle lesen fact_ref ?= cl_abap_tabledescr=>describe_by_data_ref( my_structure ). CALL METHOD fact_ref->get_ddic_object "DDIC Beschreibung auslesen RECEIVING p_object = fact_ddic EXCEPTIONS not_found = 1 no_ddic_type = 2 OTHERS = 3. DATA: descr_ref TYPE REF TO cl_abap_structdescr. CREATE DATA my_structure TYPE (cube_struct). descr_ref ?= cl_abap_tabledescr=>describe_by_data_ref( my_structure ). "Struktur-Objekt der zu lesenden Objekte lesen CALL METHOD descr_ref->get_ddic_object " DDic Beschreibung auslesen RECEIVING p_object = ddic EXCEPTIONS not_found = 1 no_ddic_type = 2 OTHERS = 3. DATA: wa_rol LIKE ldic-fieldname. LOOP AT ddic INTO ldic. " Iterate over all relevant Keyfigures READ TABLE ignore_list FROM ldic-fieldname INTO wa_rol. IF sy-subrc NE 0. READ TABLE fact_ddic WITH KEY rollname = ldic-rollname ASSIGNING . "Compare if rollname of fact-table is in Cube-structure - if it is ne 0; IF sy-subrc NE 0. " Key-Figure line_of_e_th_sfc-chanm = ldic-fieldname. INSERT line_of_e_th_sfc INTO TABLE e_th_sfc. ELSE. " must be a characteristic line_of_e_th_sfk-kyfnm = ldic-fieldname. " INSERT line_of_e_th_sfk INTO TABLE e_th_sfk. " !! Be carefull by Cubes with many keyfigures see above !! ENDIF. ENDIF. ENDLOOP. infoprov = cube. " Just for type-matching. WHILE ( end_of_data NE 'X'). " As long as not end_of_data CALL FUNCTION 'RSDRI_INFOPROV_READ' EXPORTING i_infoprov = cube i_th_sfc = e_th_sfc i_th_sfk = e_th_sfk i_t_range = r_seloption * I_TH_TABLESEL = * I_T_RTIME = * I_REFERENCE_DATE = SY-DATUM * I_ROLLUP_ONLY = RS_C_TRUE * I_T_REQUID = * I_SAVE_IN_TABLE = ' ' * I_TABLENAME = * I_SAVE_IN_FILE = ' ' * I_FILENAME = i_packagesize = 10000 * I_MAXROWS = 0 i_authority_check = rsdrc_c_authchk-none "use if you want to check auth * I_CURRENCY_CONVERSION = 'X' * I_USE_DB_AGGREGATION = RS_C_TRUE * I_USE_AGGREGATES = RS_C_TRUE * I_READ_ODS_DELTA = RS_C_FALSE * I_CALLER = RSDRS_C_CALLER-RSDRI * I_DEBUG = RS_C_FALSE * I_CLEAR = RS_C_FALSE IMPORTING e_t_data = g_t_data e_end_of_data = end_of_data * E_AGGREGATE = * E_SPLIT_OCCURRED = * E_T_MSG = * E_STEPUID = CHANGING c_first_call = c_first_call EXCEPTIONS illegal_input = 1 illegal_input_sfc = 2 illegal_input_sfk = 3 illegal_input_range = 4 illegal_input_tablesel = 5 no_authorization = 6 illegal_download = 7 illegal_tablename = 8 trans_no_write_mode = 9 inherited_error = 10 x_message = 11 OTHERS = 12 . IF sy-subrc NE 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF. APPEND LINES OF g_t_data TO t_all_data. ENDWHILE.