Skip to Content
author's profile photo Former Member
Former Member

Cluster table used as Virtual Cube

Hello all!

I have a cluster table which works as a virtual cube and it works fine. Recently I had to add a new attribute (navigation attribute) to it and then all the data which was on the table became unreadable, i.e., the "import from database" command started causing the exception "An exception with the type CX_SY_IMPORT_MISMATCH_ERROR occurred, but was neither handled locally, nor declared in a RAISING...". All data stored to the cluster table AFTER the new attribute could be read normally.

I checked the functions that I had created for reading and writing (import from, export to) and identified that the layout of one of the fields imported became different and that was why old data was causing issues (the layout read didn't match).

My problem is that I can't force my users to delete and reload all the data to the virtual cube, it would be too time consuming. I'd need some program or utility that could convert the old data to the new format but I don't know how to do it.

If anyone knows such utility or has any suggestion about the topic, please let me know.

Cheers!

Rubem

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Posted on Sep 07, 2011 at 10:37 AM

    Hi,

    the structure at IMPORT got to be the same as at EXPORT.

    so i can think of two general approaches:

    A:

    - Describe structure with RTTI before EXPORT

    - Export structure description together wit data

    - Import structure description and use CREATE DATA and ASIGGN ->* to build internal table/ wa

    - Import data

    B:

    - Create different DDIC-Structures for each version of your virtual cube

    - Store version information in an attribute of your cluster table

    - use CREATE DATA and ASIGGN ->* to build internal table/ wa

    - Import data

    A is more flexible, B is much faster to build and easy to understand. And B might be the solution for your actual problem..

    below some code for method A (excerpt w/o data definitions) - the IMPORT part might help to convert the data - just use CREATE DATA wirhount any handle but static types (old type/new type) followed by aSSIGN and IMPORT,

    have fun!

    hp

    Export;

    * Get tables decription
        call method cl_abap_tabledescr=>describe_by_data
          exporting
            p_data      = lt_data
          receiving
            p_descr_ref = go_type_descr.
        go_table_descr ?= go_type_descr.
    
    * get structures description
        go_data_descr =  go_table_descr->get_table_line_type( ).
        go_struct_descr ?= go_data_descr.
        gt_component_tab = go_struct_descr->get_components( ). "descr with ref
    
    
    * get DDIC definitions
        loop at   gt_component_tab into gs_component_descr.
          go_elem_descr ?= gs_component_descr-type.
          gs_dfies = go_elem_descr->get_ddic_field( ).
          append gs_dfies to gt_dfies.
        endloop.
    
    **********************************************************************
    
    
    * Now DDIC names are known and can be exported together with data
        call function 'C149_RECN_GET_NEXT'
          importing
            number = gv_recn.
    
    
        gv_srtfd =  gv_recn.
        gs_indx-aedat = sy-datum.
        gs_indx-usera = sy-uname.
        gs_indx-begdt = sy-datum.
        gs_indx-enddt = '99991231'.
        gs_indx-pgmid = sy-repid.
    
    * NOTE: all data has to be exported together
    *       - subsequent export statements would overwrite
    *         so that only the last export statement has any effect
        export struct_tab = gt_dfies[]
               data_tab = lt_data[]
                   to database indx(zq)
                   from gs_indx
                   id gv_srtfd.
    

    Import

    
    * Import data - structure first
        import  struct_tab = gt_dfies[]
          from database indx(zq)
          to   gs_indx
          id gv_srtfd.
    
        if gt_dfies[] is initial. "would DUMP - return
          message i015(zdgf) with 'ID =' gv_srtfd 'not found' space.
          return.
        endif.
    **********************************************************************
    
    * Create table with same structure as exported
    *** buld components table
        refresh gt_component_tab.
        loop at gt_dfies into gs_dfies.
          gs_component_descr-name = gs_dfies-tabname.
          go_type_descr = cl_abap_elemdescr=>describe_by_name( gs_dfies-tabname ).
    *    go_elem_descr ?= go_type_descr.
          gs_component_descr-type ?= go_type_descr.
          insert gs_component_descr into table gt_component_tab.
        endloop.
    
    
    *TRY.
        call method cl_abap_structdescr=>create
          exporting
            p_components = gt_component_tab
    *    p_strict     = TRUE
          receiving
            p_result     = go_imp_struct_descr.
    
    * CATCH cx_sy_struct_creation .
    *ENDTRY.
    
    *
        try.
            call method cl_abap_tabledescr=>create
              exporting
                p_line_type  = go_imp_struct_descr
    *    p_table_kind = TABLEKIND_STD
    *    p_unique     = ABAP_FALSE
    *    p_key        =
    *    p_key_kind   = KEYDEFKIND_DEFAULT
              receiving
                p_result     = go_import_table_descr.
    
          catch cx_sy_table_creation .
    
        endtry.
    
        create data go_table type handle go_import_table_descr.
        assign go_table->* to <table>.
    
    **********************************************************************
    * Import step 2 - data
    * Import data - structure first
        import  data_tab = <table>
          from database indx(zq)
          to   gs_indx
          id gv_srtfd.
    

    Edited by: Holger Pakirnus on Sep 7, 2011 12:39 PM

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.