Maintenance view with MARA joined twice

Hello,
I have a Z table which contains 2 fields containing material number, say: MATNR_1 and MATNR_2. Both have foreign keys pointing to MARA table.
Now I'd like to create a maintenance view for that Z table which will contain texts for both of those matnr fields, taken from MAKT table. So I need a maintenance view which has that Z table as the main table of the view and MARA+MAKT tables joined <u>twice</u>: first for the field MATNR_1 and next for field MATNR_2.
It looks like it is impossible to achieve by just clicking in SE11 - the system takes only the first matnr field into account (MATNR_1) and joining MARA for the second time (for field MATNR_2) seems not possible.
Has anyone an idea how to achieve this ?

I found a solution myself - actually a workaround, here it is if someone is interested:
You can have data from a secondary table (a table that you cannot join by defining the view) filled "manually" at the screen level. When you generate a maintenance objects with the maintenance generator, modify the generated screen by adding a new field to it (for data that you need to be displayed). In PBO of that screen call your additional PBO module which just reads the data from the db table (or from anywhere you want) and fills that field.
You can check standard transaction FI12 to have an example: field BNKA-BANKA is filled exactly with this technique (see PBO of that screen).

Similar Messages

  • Maintenance View with Subset Fields

    Hi All,
    I have created a maintenance view based on a single DB table. Two key fields are defined to be as subset fields. No selection conditions are added to the view. I have used table maintenance genrator to define the screen (one step) along with the events.
    In SM30, i get the popup to fill the subset fields.
    I have created an event for AA (to replace default read). I am filling total attribute here.
    a) Is there some other attribute that i need to fill apart from total?
    I receive following dump
    " Exception condition "NO_VALUE_FOR_SUBSET_IDENT" is raised"
    When i set <status>-sbsid_rcvd = 'R' in read routine along with total, then the above exception doesn't appear.
    But filtering based on the subset values doesn't happen automatically.
    b) I also need have to have routines to perform insert, copy and validation.
    c) Would the contents displayed be automatically filtered based on the subset values or we need to process this in user routines for read and so on?
    As i find very limited documentation available for maintenance views with subset fields, could you suggest me some example to do the above?
    Thanks in Advance,
    Regards,
    Rekha

    Hello Rekha,
    Yes I've same idea, documentation for maintenance screens is inadequate.
    But there is way to find examples for all events,
    table TVIMF is storing the Table name - Event - Form name columns.
    For example when u want to  do something about  "creating a new entry"
    Just go se11 > Table maintenance generator and find related event : 05
    - Then go to TVIMF and display a record for event = 05
    - than go to function group of  maintenance screen of the TABLE in that record
    - find the subroutine form ( TVIMF-FORMNAME) in that function group
    This is a working example for that event, try or copy & use.
    I hope it helps you for the coding for all the events.
    Bulent
    Edited by: Bulent Balci on Aug 5, 2010 11:28 PM
    Edited by: Bulent Balci on Aug 5, 2010 11:29 PM

  • How do I update a view with a join

    I have a module with database block based on a view with joins, so I am not able to perform insert, update & delete directly.
    Therefore I created an unbound item that can be changed. The relevant database record is searched and updated.
    So, with above work around, insert, update & delete is possible.
    This works just fine.
    Now, the 'save icon' in the menu (diskette icon), does not get activated automatically when there are changes to be saved. This is because the view is not changed.
    So, I enable the 'save icon' manually in the when-validate-item trigger. But now when I navigate to another record, the 'save icon' gets de-activated by QMS/headstart code. This is because the view is not changed.
    So, I tried set_record_property (CHANGED_STATUS) to let the application
    know there are changes to be saved.
    But then, I get an error:
    * FRM-40654: Record has been updated by another user. Re-query block to see
    change.
    What is the proper way to handle this problem?
    null

    Peter,
    I think you've gone down the wrong track with your workaround.
    You should base your form on the view and allow update and insert to the view just as if it was a table.
    If you are using Oracle 8i, create an INSTEAD-OF trigger on the view in the database which redirects the DML to insert or update the appropriate table(s) instead of the view.
    If you are pre Oracle 8i, in the form you can create on-insert, on-update, and on-delete triggers to redirect the DML to the appropriate table.
    The only other tricky situation comes if you have items in your form that are server-derived (in the TAPI) of the table(s) in question. If so, you must explicitly code the form to retrieve these server-derived values. Also note that with a view, you cannot have a server derived primary key since there would be no way to retrieve it in the form. (Views don't have a rowid.) You must derive primary key columns in the form when the form is based on the view.
    Regards,
    Lauri

  • Question - View with a join based on two unequal strings.

    Hello -
    First my apologies for the likely novice question.
    I'm creating a view based on two tables as such:
    SELECT *
    FROM table1 LEFT OUTER JOIN table2 ON table1.string = table2.string AND table1.number = table2.number
    Problem: table1.string looks like "A00A01%%%" and table2.string looks like "A1" (which would correspond to "A00A01%%%".
    Question: Can I create the join based on the 4th and 6th character of the string = the other string, or should I create a view with a formula creating a new field and then create a second view? (Note: creating or changing the field in the original table is not an option).
    Thank you.

    Hi,
    Yes, you can do that. Join conditions don't have to be as simple as "ON a.col1 = b.col2"; they can involve functions, like CONCAT and SUBSTR.
    For example:
    FROM            table1
    LEFT OUTER JOIN table2
    ON              SUBSTR (table1.string, 4, 1)
                    ||
                    SUBSTR (table1.string, 6, 1) = table2.string
    ...The query might be faster if you create a function-based index on the join condition from table1. This does not require changing table1 itself. (For a LEFT OUTER JOIN, like this, it probably won't matter.)

  • How to validate enries in Maintenance Views with the help of Events?

    Hello,
    I have a Maint. View. I would like to apply a validation for a specific field of the table. And if there is an entry which is not proper, than I'd need an error message to be issue, and the fields should be open for correction.
    I know this should be managed by Events. I tried many of them, but there was allways some different kind of issuses. E.g. When I used Event 21, the problem was that:  table "total" was not updated with the values I entered, when the Event triggered. More over, when I ussed a simple error message, that appeared on the screen, but when I hit Enter, I got an infinite LOOP, cause Event 21 was again triggered.
    When I tried Event 01, the total table was already updated. But with the program went back to the sceen from where I called the maintenance of the table. And Issues the error message there. When I hit Enter it took me back to maintenance screen. But this is not very nice.
    A bunch of hints would make me very happy, or a good example, which is priceless!
    Thanks and regards,
    Gyula

    Hi priyaranjan,
    Check the data in debug mode whether the record_tab is getting filled or not. If it is not filled use FM 'F4UT_RESULTS_MAP' to fill the data.
    Refer the link F4UT_RESULTS_MAP Standard Search Help Exit for Filling Hit List - Function - ABAP - SAP to know how to use FM.
    Once You get result from FM in to record_tab then sort the table as per your requirement.
    Regards,
    Ravikiran.K

  • View with outer join results wrong number of rows

    Hi,
    When i run a query on a view it returns 2 rows(2 distinct rows), when i run the same query with the select statement which the view is created , it returns only 1 row. According to data the 1 row result is correct, how come twi results. A coding sample as follows. Any help is most appreciated.
    I have a view created based on a outer join of two views in the format;
    create or replace view view1 as
    select ord.order_no order_no,
    ord.del_type del_type,
    det.qty qty
    from detail_view det, order_view ord
    where det.site(+) = ord.site
    and det.part(+) = ord.part
    and nvl(ord.del_type,'_NULL_') <> 'F'
    with read only;
    detail_view & order_view themselves have several group by/sum and union Alls.
    When i run the query on this view
    [Select * from View1 where order_no = 'A30' And del_type = 'B']
    it returns 2 distinct rows. But when i run the select statement which created the View1 with the query it returns only one row!!
    What did i do wrong?
    Thanks
    Sanjeewa

    I cannot reproduce this :
    SCOTT@LSC01> create table detail_view(qty number,site number,part number);
    Table created.
    SCOTT@LSC01> create table order_view(order_no varchar2(10), del_type varchar2(1), site number,part number);
    Table created.
    SCOTT@LSC01>
    SCOTT@LSC01> create or replace view view1 as
      2  select ord.order_no order_no,
      3  ord.del_type del_type,
      4  det.qty qty
      5  from detail_view det, order_view ord
      6  where det.site(+) = ord.site
      7  and det.part(+) = ord.part
      8  and nvl(ord.del_type,'_NULL_') <> 'F'
      9  with read only;
    View created.
    SCOTT@LSC01>
    SCOTT@LSC01> insert into order_view values ('A30','B',1,2);
    1 row created.
    SCOTT@LSC01> insert into order_view values ('A30','B',1,2);
    1 row created.
    SCOTT@LSC01>
    SCOTT@LSC01> Select * from View1 where order_no = 'A30' And del_type = 'B';
    ORDER_NO   D        QTY
    A30        B
    A30        B
    SCOTT@LSC01>
    SCOTT@LSC01> select ord.order_no order_no,
      2  ord.del_type del_type,
      3  det.qty qty
      4  from detail_view det, order_view ord
      5  where det.site(+) = ord.site
      6  and det.part(+) = ord.part
      7  and nvl(ord.del_type,'_NULL_') <> 'F' ;
    ORDER_NO   D        QTY
    A30        B
    A30        Bwhat is your version?

  • Materialized View with recursive join

    Why is this not allowed?
    create materialized view bone_mv
    refresh complete
    on commit
    as
    select
    a.pk
    from
    tablea a,
    tableb b,
    tableb b2
    where
    tablea.col1 = b.col1 and
    tablea.col2 = b2.col2
    If I use "on demand" there is no problem.

    Hi,
    Have you managed to overcome this problem? If so, could you please let me know.
    Thanks
    Raja

  • Maintenance view does not bring the default language in the Text table

    Hi Experts,
    I am creating a maintenance view with the join of two tables
    TAB1 has following fields
    MANDT
    CATEGORY
    TAB2 (is the text table for TAB1) has the following fields
    MANDT
    LANGU
    CATEGORY
    DESCRIPTION
    I have created the maintenance view with
    MANDT
    CATEGORY
    DESCRIPTION
    When Itry to maintain the data through the view I can insert teh data in TAB1 but in TAB2 it doesnt take the default language key.
    I want my default language key as 'EN'.
    I have referred V_T77TMC_EDUTYP, but I cannot find the reason why in my custom view I dont get the language key.
    Request your help.
    Thanks
    Anu.

    Hello Anu,
    I believe that according to definition of maintenance view, for text tables there should be an automatic entry for sy-langu in SPRAS field. So, you should be able to get this without activating any TMG events.
    I suppose you have created a maintenance generator for your maintenance view and updating entries using SM30 for that maintenance view.
    Please check that you have created the text table properly. Check while putting TAB1 in SE16n and pressing enter, do you see TAB2 in 'text table' field ???
    Make sure while defining Foreign key relationship, you have used 'Key fields of a Text table' option.
    Do share if you face any problem ?
    regards,
    Diwakar

  • Maintenance view subset P = S in combination with a non-key.

    We are trying to create a maintenance view with subset selection based
    on a non-key field. However no dialog screen will be created in order to
    select the right data (subset) for list display. We found a referenced
    note of this problem: sap note nr 624459 "subset field is not
    transferred" which is already available in the L7D system.
    -> Does the subset P = S only work in combination with a key field?

    Hi,
    I presume the P = S works for only Primary Key combinations. For eg: If you create maintenance view on MARD table and give values P= S to say only MATNR and WERKS fields. You generate the Table Maintenance. You get the filter for Material and Plant but there is a button F7 new selection .. if you press that you can select the third key field Storage Location as well. Presumably it works for the key fields alone.
    Cordially,
    Shankar Narayanan.

  • Problem to add ADCP-DEPARTMENT into maintenance view

    Hi All,
    I need help urgently on creating a maintenance view of a customized table.
    The Customized Table name is ZTSUBCON, it contains fields below:-
    MANDT     - Client
    BNAME     - User Name in User Master Record
    ... (and other fields)
    I would like to create a maintenance view called ZVSUBCON and this view must be able to show the department of the User Name automatically when user maintain the data.
    Customized View Name : ZVSUBCON, contains fields below:-
    BNAME          - SAP Account that will be input by user thru transaction SM30
    DEPARTMENT     - This should be the information from ADCP table (field : DEPARTMENT), which must automatically display after user key in the SAP account
    ... (and other fields)
    I tried to create a foreign key BNAME with check table USR21, and try to add the table ADCP in "Table/Join Conditions" in SE11, but, it failed.
    Please help me if you know the solution.
    Thanks & Regards,
    Heng Lye

    Hello Heng
    Define your maintenance view with the following tables:
    ZTSUBCON (primary table)
    USR21
    ADRC
    ADRP
    These tables will give the following JOIN conditions:
    USR21     MANDT     =     ZTSUBCON     MANDT
    USR21     BNAME     =     ZTSUBCON     BNAME
    ADRC     ADDRNUMBER     =     USR21     ADDRNUMBER
    ADRP     PERSNUMBER     =     USR21     PERSNUMBER
    To receive the department from table ADCP use the key fields from ADRC and ADRP and fill the maintenance view field using <a href="http://help.sap.com/saphelp_nw04/helpdata/en/91/ca9f4aa9d111d1a5690000e82deaaa/content.htm">Event 21 fill hidden fields</a>
    Regards
      Uwe

  • Regarding maintenance views

    what is the main purpose in creation of maintenace views???????
    and where we use it in real time?????

    Hi
    Maintenance View ( SE54 )
    Maintenance views enable a business-oriented approach to looking at data, while at the same time, making it possible to maintain the data involved. Data from several tables can be summarized in a maintenance view and maintained collectively via this view. That is, the data is entered via the view and then distributed to the underlying tables by the system.
    Please have a look at below link. It will help you.
    http://help.sap.com/saphelp_nw04/helpdata/en/cf/21ed06446011d189700000e8322d00/frameset.htm
    for more detailed info look on:
    http://www.sap-img.com/abap/what-is-the-different-types-and-usage-of-views.htm
    https://www.sdn.sap.com/irj/sdn/wiki?path=/display/home/abap+dictionary&
    Creation of Views:
    1.Go to se11
    2. select view radiobutton and give a name
    3. Create
    4. select type of view you want to create. Such as database view.
    5. give short description
    6. give a table name such as mara
    7. press the pushbutton relationship. here you will find all the tables which are allowed to create view with mara.
    8. select one or mane tables.
    8 copy
    9.save , check and activate.
    <b>Reward points for useful Answers</b>
    Regards
    Anji

  • Maintenance view Events for description in details

    hello i have a maintenance view with 2 screen ( one overview other details ) i want fill a label in the details screen with the description of some code ( custom table with all custom fills )
    but i don't find what event is the right , i try the event 26 , i put a break-point just for check but dont get trigger that event when i display the item in details screen
    Thanks

    thanks i add the form to the event 01 but the breakpoint is not called , i even change the maintenance view i select create modules but don't work , any idea ? maybe i am missing something
    pd: when i create the firts time the form i select create new include

  • Table maintenance view not saving changes

    Hi experts
      I have created a Z table with corresponding maintenance view (with transaction). Also, there is a Z program to insert records into the table from xls file.
      When accesing the maintenance view, I can add and remove entries, but the problem is:
           when I update a record, if the records has been created using the maintenance view, then changes are saved to database, but if I try to modify a record added by using the Z program, none of the modifications are saved to DB.
      I have re-created maintenance view, and table properties (delivery class A, display/maintenance allowed ...) seem to be OK.
    Can someone provide some help with this?.
    Many thanks in advance for your help.
    Best  regards,
    Carlos.

    HI
      Thanks for your answer, but didn't work.
      Below my program (
      CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
        EXPORTING
          filename                = p_fin
          i_begin_col             = 1
          i_begin_row             = 2
          i_end_col               = 9
          i_end_row               = 9999
        TABLES
          intern                  = gt_fichero
        EXCEPTIONS
          inconsistent_parameters = 1
          upload_ole              = 2
          OTHERS                  = 3.
      LOOP AT gt_fichero INTO gs_fichero.
        CASE gs_fichero-col.
          WHEN 1. "Proyecto
            "Validaciones
            gs_unidades-proyecto = gs_fichero-value.
          WHEN 2. "Tipología
            "Validaciones
            gs_unidades-tipologia = gs_fichero-value.
          WHEN 3. "Alias
            "Validaciones
            gs_unidades-identificador = gs_fichero-value.
          WHEN 4. "Superficie
            "Validaciones
            TRANSLATE gs_fichero-value USING ',.'.
            gs_unidades-superficie = gs_fichero-value.
          WHEN 5. "Estado
            "Validaciones
            gs_unidades-estado = gs_fichero-value.
          WHEN 6. "Entrega
            "Validaciones
            gs_unidades-entrega = gs_fichero-value.
          WHEN 7. "PVPCoste
            "Validaciones
            TRANSLATE gs_fichero-value USING ',.'.
            gs_unidades-pvpcoste = gs_fichero-value.
            "Se añade el registro a la tabla de datos maestros
            INSERT ztt_fi_unidades FROM gs_unidades.
            CLEAR gs_unidades.
            IF sy-subrc EQ 0.
              gv_total_correctos = gv_total_correctos + 1.
            ELSE.
              gv_total_erroneos = gv_total_erroneos + 1.
            ENDIF.
            gv_total_registros = gv_total_registros + 1.
          WHEN OTHERS.
        ENDCASE.
      ENDLOOP.

  • Query rewrites with Nested materialized views with different aggregations

    Platform used : Oracle 11g.
    Here is a simple fact table (with measures m1,m2) and dimensions (a) Location (b) Calendar and (c) Product. The business problem is that aggregation operator for measure m1,m2 are different along location dimension and Calendar dimension. The intention is to preaggregate the measures for a product along the calendar dimension and Location dimension and store it as materialized views.
    The direct option is to define a materialized view with Inline queries (Because of the different aggrergation operator, it is not possible to write a query without Inline query). http://download-uk.oracle.com/docs/cd/B28359_01/server.111/b28313/qradv.htm#BABEAJBF documents the limitations that it works only for 'Text match' and 'Equivalent queries' and that is too limiting.
    So decided to have nested materialized view, with first view having just joins(my_dim_mvw_joins), the second view having aggregations along Calendar dimension (my_dim_mvw_calendar) and third view having aggregations along the Location dimension(my_dim_mvw_location). Obviously I do not want the query I fire to know about materialized views and I fire it against the fact table. I see that for the fired query (Which needs aggregations along both Calendar and Location), is rewritten with just second materialized view but not the third. (Had set QUERY_REWRITE_INTEGRITY as TRUSTED) .
    Wanted to know whether there are limitations on Query Writes with nested materialized views? Thanks
    (Have given a simple testable example below. Pls ignore the values given in 'CALENDAR_IDs', 'PRODUCT_IDs' etc as they are the same for all the queries)
    -- Calendar hierarchy table
    CREATE TABLE CALENDAR_HIERARCHY_TREE
    (     "CALENDAR_ID" NUMBER(5,0) NOT NULL ENABLE,
    "HIERARCHY1_ID" NUMBER(5,0),
    "HIERARCHY2_ID" NUMBER(5,0),
    "HIERARCHY3_ID" NUMBER(5,0),
    "HIERARCHY4_ID" NUMBER(5,0),
    CONSTRAINT "CALENDAR_HIERARCHY_TREE_PK" PRIMARY KEY ("CALENDAR_ID")
    -- Location hierarchy table
    CREATE TABLE LOCATION_HIERARCHY_TREE
    (     "LOCATION_ID" NUMBER(3,0) NOT NULL ENABLE,
    "HIERARCHY1_ID" NUMBER(3,0),
    "HIERARCHY2_ID" NUMBER(3,0),
    "HIERARCHY3_ID" NUMBER(3,0),
    "HIERARCHY4_ID" NUMBER(3,0),
    CONSTRAINT "LOCATION_HIERARCHY_TREE_PK" PRIMARY KEY ("LOCATION_ID")
    -- Product hierarchy table
    CREATE TABLE PRODUCT_HIERARCHY_TREE
    (     "PRODUCT_ID" NUMBER(3,0) NOT NULL ENABLE,
         "HIERARCHY1_ID" NUMBER(3,0),
         "HIERARCHY2_ID" NUMBER(3,0),
         "HIERARCHY3_ID" NUMBER(3,0),
         "HIERARCHY4_ID" NUMBER(3,0),
         "HIERARCHY5_ID" NUMBER(3,0),
         "HIERARCHY6_ID" NUMBER(3,0),
         CONSTRAINT "PRODUCT_HIERARCHY_TREE_PK" PRIMARY KEY ("PRODUCT_ID")
    -- Fact table
    CREATE TABLE RETAILER_SALES_TBL
    (     "PRODUCT_ID" NUMBER,
    "PRODUCT_KEY" VARCHAR2(50 BYTE),
    "PLAN_ID" NUMBER,
    "PLAN_PERIOD_ID" NUMBER,
    "PERIOD_ID" NUMBER(5,0),
    "M1" NUMBER,
    "M2" NUMBER,
    "M3" NUMBER,
    "M4" NUMBER,
    "M5" NUMBER,
    "M6" NUMBER,
    "M7" NUMBER,
    "M8" NUMBER,
    "LOCATION_ID" NUMBER(3,0),
    "M9" NUMBER,
    CONSTRAINT "RETAILER_SALES_TBL_LOCATI_FK1" FOREIGN KEY ("LOCATION_ID")
    REFERENCES LOCATION_HIERARCHY_TREE ("LOCATION_ID") ENABLE,
    CONSTRAINT "RETAILER_SALES_TBL_PRODUC_FK1" FOREIGN KEY ("PRODUCT_ID")
    REFERENCES PRODUCT_HIERARCHY_TREE ("PRODUCT_ID") ENABLE,
    CONSTRAINT "RETAILER_SALES_TBL_CALEND_FK1" FOREIGN KEY ("PERIOD_ID")
    REFERENCES CALENDAR_HIERARCHY_TREE ("CALENDAR_ID") ENABLE
    -- Location dimension definition to promote query rewrite
    create DIMENSION LOCATION_DIM
    LEVEL CHAIN IS LOCATION_HIERARCHY_TREE.HIERARCHY1_ID
    LEVEL CONSUMER_SEGMENT IS LOCATION_HIERARCHY_TREE.HIERARCHY3_ID
    LEVEL STORE IS LOCATION_HIERARCHY_TREE.LOCATION_ID
    LEVEL TRADING_AREA IS LOCATION_HIERARCHY_TREE.HIERARCHY2_ID
    HIERARCHY PROD_ROLLUP (
    STORE CHILD OF
    CONSUMER_SEGMENT CHILD OF
    TRADING_AREA CHILD OF
    CHAIN
    -- Calendar dimension definition
    create DIMENSION CALENDAR_DIM
    LEVEL MONTH IS CALENDAR_HIERARCHY_TREE.HIERARCHY3_ID
    LEVEL QUARTER IS CALENDAR_HIERARCHY_TREE.HIERARCHY2_ID
    LEVEL WEEK IS CALENDAR_HIERARCHY_TREE.CALENDAR_ID
    LEVEL YEAR IS CALENDAR_HIERARCHY_TREE.HIERARCHY1_ID
    HIERARCHY CALENDAR_ROLLUP (
    WEEK CHILD OF
    MONTH CHILD OF
    QUARTER CHILD OF
    YEAR
    -- Materialized view with just joins needed for other views
    CREATE MATERIALIZED VIEW my_dim_mvw_joins build immediate refresh complete enable query rewrite as
    select product_id, lht.HIERARCHY1_ID, lht.HIERARCHY2_ID, lht.HIERARCHY3_ID, lht.location_id, cht.HIERARCHY1_ID year,
    cht.HIERARCHY2_ID quarter, cht.HIERARCHY3_ID month, cht.calendar_id week, m1, m3, m7, m9
    from retailer_sales_tbl RS, calendar_hierarchy_tree cht, location_hierarchy_tree lht
    WHERE RS.period_id = cht.CALENDAR_ID
    and RS.location_id = lht.location_id
    and cht.CALENDAR_ID in (10,236,237,238,239,608,609,610,611,612,613,614,615,616,617,618,619,1426,1427,1428,1429,1430,1431,1432,1433,1434,1435,1436,1437,1438,1439,1440,1441,1442,1443,1444,1445,1446,1447,1448,1449,1450,1451,1452,1453,1454,1455,1456,1457,1458,1459,1460,1461,1462,1463,1464,1465,1466,1467,1468,1469,1470,1471,1472,1473,1474,1475,1476,1477)
    AND product_id IN (5, 6, 7, 8, 11, 12, 13, 14, 17, 18, 19, 20)
    AND lht.location_id IN (2, 3, 11, 12, 13, 14, 15, 4, 16, 17, 18, 19, 20)
    -- Materialized view which aggregate along calendar dimension
    CREATE MATERIALIZED VIEW my_dim_mvw_calendar build immediate refresh complete enable query rewrite as
    select product_id, HIERARCHY1_ID , HIERARCHY2_ID , HIERARCHY3_ID ,location_id, year, quarter, month, week,
    sum(m1) m1_total, sum(m3) m3_total, sum(m7) m7_total, sum(m9) m9_total,
    GROUPING_ID(product_id, location_id, year, quarter, month, week) dim_mvw_gid
    from my_dim_mvw_joins
    GROUP BY product_id, HIERARCHY1_ID , HIERARCHY2_ID , HIERARCHY3_ID , location_id,
    rollup (year, quarter, month, week);
    -- Materialized view which aggregate along Location dimension
    CREATE MATERIALIZED VIEW my_dim_mvw_location build immediate refresh complete enable query rewrite as
    select product_id, year, quarter, month, week, HIERARCHY1_ID, HIERARCHY2_ID, HIERARCHY3_ID, location_id,
    sum(m1_total) m1_total_1, sum(m3_total) m3_total_1, sum(m7_total) m7_total_1, sum(m9_total) m9_total_1,
    GROUPING_ID(product_id, HIERARCHY1_ID, HIERARCHY2_ID, HIERARCHY3_ID, location_id, year, quarter, month, week) dim_mvw_gid
    from my_dim_mvw_calendar
    GROUP BY product_id, year, quarter, month, week,
    rollup (HIERARCHY1_ID, HIERARCHY2_ID, HIERARCHY3_ID, location_id)
    -- SQL Query Fired (for simplicity have used SUM as aggregation operator for both, but they will be different)
    select product_id, year, HIERARCHY1_ID, HIERARCHY2_ID,
    sum(m1_total) m1_total_1, sum(m3_total) m3_total_1, sum(m7_total) m7_total_1, sum(m9_total) m9_total_1
    from
    select product_id, HIERARCHY1_ID , HIERARCHY2_ID , year,
    sum(m1) m1_total, sum(m3) m3_total, sum(m7) m7_total, sum(m9) m9_total
    from
    select product_id, lht.HIERARCHY1_ID , lht.HIERARCHY2_ID , lht.HIERARCHY3_ID ,lht.location_id, cht.HIERARCHY1_ID year, cht.HIERARCHY2_ID quarter, cht.HIERARCHY3_ID month, cht.calendar_id week,m1,m3,m7,m9
    from
    retailer_sales_tbl RS, calendar_hierarchy_tree cht, location_hierarchy_tree lht
    WHERE RS.period_id = cht.CALENDAR_ID
    and RS.location_id = lht.location_id
    and cht.CALENDAR_ID in (10,236,237,238,239,608,609,610,611,612,613,614,615,616,617,618,619,1426,1427,1428,1429,1430,1431,1432,1433,1434,1435,1436,1437,1438,1439,1440,1441,1442,1443,1444,1445,1446,1447,1448,1449,1450,1451,1452,1453,1454,1455,1456,1457,1458,1459,1460,1461,1462,1463,1464,1465,1466,1467,1468,1469,1470,1471,1472,1473,1474,1475,1476,1477)
    AND product_id IN (5, 6, 7, 8, 11, 12, 13, 14, 17, 18, 19, 20)
    AND lht.location_id IN (2, 3, 11, 12, 13, 14, 15, 4, 16, 17, 18, 19, 20)
    GROUP BY product_id, HIERARCHY1_ID , HIERARCHY2_ID , HIERARCHY3_ID , location_id, year
    ) sales_time
    GROUP BY product_id, year,HIERARCHY1_ID, HIERARCHY2_ID
    This Query rewrites only with my_dim_mvw_calendar. (as saw in Query Plan and EXPLAIN_MVIEW). But we would like it to use my_dim_mvw_location as that has aggregations for both dimensions.

    blackhole001 wrote:
    Hi all,
    I'm trying to make my programmer's life easier by creating a database view for them to query the data, so they don't have to worry about joining tables. This sounds like a pretty horrible idea. I say this because you will eventually end up with programmers that know nothing about your data model and how to properly interact with it.
    Additionally, what you will get is a developer that takes one of your views and see's that of the 20 columns in it, it has 4 that he needs. If all those 4 columns comes from a simple 2 table join, but the view has 8 tables, you're wasting a tonne of resources by using the view (and heaven forbid they have to join that view to another view to get 4 of the 20 columns from that other view as well).
    Ideally you'd write stored routines that satisfy exactly what is required (if you are the database resource and these other programmers are java, .net, etc... based) and the front end developers would call those routines customized for an exact purpose.
    Creating views is not bad, but it's by no means a proper solution to having developers not learn or understand SQL and/or the data model.

  • Problem in Selection Conditions Maintenance View

    Hello Gurus.
    I've created a maintenance view for a ZTABLE, in this maintenance view in TABLE/JOIN Conditions i defined a relationship beetween my ZTABLE and SKAT.
    Untill this point its fine. But when i go to the tab of selection conditions, there already there two automatic conditions. And i can't edit these conditions.
    Why this is happening?? Anyone knows??
    Thanks in advance

    Hi There,
    Those are the Primary fields or key fields sharing the common data,, This is required to maintain the data consistency. SAP's major strength is its data integrity...
    You will not be able to edit primary keys since these values are maintained in several other tables too. changing at one place and keeping it as is in another table lead to data inconsistency.
    let me know if you have further queries.
    don't forget to rward pionts if found useful.
    Thanks-

Maybe you are looking for