Selection from maintenance view

Hi,
I have created and activated a maintenance view from tables EKPO and EKKO. I needed an outer join so I had to use maintenance view instead of datbase view. When I see the data in the view using SE11 it works fine. However, when I try to select some fields from it using code it gives me an error message.
Eg.
REPORT Z_TEST_REP.
TABLES: Z_MAINTVIEW.
SELECT * FROM Z_MAINTVIEW.
WRITE: / Z_MAINTVIEW-MYFIELD1.
ENDSELECT.
When activating, this gives me the error message: "Z_MAINTVIEW" is not defined in the ABAP Dictionary as a table, projection view or database view.
Does this mean that it is not possible to select single fields from a maintenance view using the select statement? Is there any way I can do this? Any help is appreciated. Thanks.
Khan

Hi Khan,
it is in the nature of EKKO (header) and EKPO (items) that you have 1 to n records (ittems) in EKPO with the same EBELN (purchase order document number). They all have different EBELP (item number values).
I just tried: You can create a database view with tables EKKO and EKPO with join condition EKKO-EBELN = EKPO-EBELN. In the view you also need EKKO-MANDT = EKPO-MANDT to make sure you stay in your client.
In the view fields, put all fields you want and/or need.
You can select from this view; works great.
Alternative: Use BAPI_PO_GETDETAIL to get all the header and item data you need. This is 100 % compliant with standard and (as I am convinced) with any programming guidelines.
- OK as I don't know the business scenario, it might be lesss than most appropriate...
Regards,
Clemens

Similar Messages

  • How to extract data from maintenance view

    Hi experts,
    How can I select the data from maintenance view. As you know select query doesn't work on the maintenance view. And View name will be known at run time only.
    Thanks
    Yogesh Gupta

    > Let me tell you that I am a SAP certified ABAP consultant having experience of 4.5 years.
    I suspect that we will be hearing more comments about that.
    > Whatever question I asked can't be replied with the basic training (if yes please tell me even one).
    Debugging a macro?
    Another one => FM or BAPI to create the Activity Group in 4.0B No answer is possible? You have to be joking!
    And in How to get email ID fo a SAP user you obviously didn't even try Graham's answer!
    > I closed some of the answered questions since I didn't get the answers for them for a long time and SDN site doesn't allow to keep more than 10 questions open.
    The "comment field" is not mandatory. You don't need to flood the forum with your questions again.
    > I do respect your  concerns but I have no intention to abuse this site as it has been very helpful for me.
    That is the most important part. Thank you. But you seem to be unaware of the "search" functionality.
    If you can imagine that you are not the first person to ask a certain question, then you can be sure that someone else already has and you can find the answers on your own. If you still have doubts, then ask a specific question providing the details.
    Based on your other questions, you are on release 4.0B. Is that still correct?
    Cheers and thanks for responding,
    Julius
    Edited by: Julius Bussche on Jan 23, 2009 12:06 AM

  • It's is possible to make a select from a view?

    I don't know if it's possible to make a select of a table-view like V_T5F99FW if it's possible does anybody tell me how can I do?
    Thanks a lot,
    Regards,
    Rebeca

    Hi Rebeca,
    You can surely do a selection from a projection and database view but not from a maintenance view.
    The selection from a view works like a normal selection only.
    watch this link
    http://sap.ionelburlacu.ro/abap/ABAPperformance.html#Select_with_view
    Regards,
    Manish
    Edited by: MANISH GUPTA on Aug 31, 2008 1:38 PM

  • Error while selecting from a view ORA-01031: Insufficient privileges

    As DBA I have granted select privileges on a view to a user, but whenever I login as that user and try to select from the view I get the message 'ORA-01031'. When I run the query in the view as the user I do not have problem and can see the results. This view joins tables from more than one schema and does a distinct on the resultset. I am new to Oracle and would appreciate any help I can get.
    Thanks

    Back on this problem when I created another user with select permission on the same view and a default role that has reference on all the objects on the other schemas, I end up with the same error message. Although this time the schema owner of the view has select privileges on all the tables from other schemas referenced in the view.
    Thanks

  • Can ResultSetMetaData() return the table name if it is selected from a view

    hi all
    can anyone tell me if ResultSetMetaData() can return the name of the table if it is selected from a view? thanks, i tried and it didn't return nothing. is it because the view is treated differently than table in ResultSetMetaData?

    hi all
    can anyone tell me if ResultSetMetaData() can return
    the name of the table if it is selected from a view?
    thanks, i tried and it didn't return nothing. is it
    because the view is treated differently than table in
    ResultSetMetaData?I would say "no". A view could be a multi-table join query, or maybe even a no-table query. The bigger picture I think though, is that you shouldn't need to know what the underlying table(s) were for this query - smells of a mis-design.

  • Is selecting from a view more efficient than selecting from multiple tables

    Hi heres the problem
    Lets say i created a view from 2 tables (person and info). both have a ID column
    create view table_view (age,name,status,id) as
    select a.age, a.name, b.status, b.id
    from person a, info.b
    where a.id=b.idif i want to select a given range of values from these 2 tables which of the following queries would be more effective.
    select a.age, a.name, b.status, b.id
    from person a, info.b
    where a.id=b.id
    and a.id <1000
    select age, name, status, id
    from table_view
    where  id <1000

    Bear in mind that this concept of views storing the SQL text is something relative to Oracle databases and not necessarily other RDBMS products. For example, Ingres databases create "views" as tables of data on the database and therefore there is a difference between selecting from the view and selecting from the base tables.
    Oracle also has "materialized views" which differ from normal "views" because they are actually created, effectively, as tables of data and will not use the indexes of the base tables.
    In Oracle, you cannot create indexes against "views" but you can create indexes against "materialized views".

  • Popup window for data selection in maintenance view

    Hi,
    How to create popup window for data selection in maintenance view. For example when you go to view v_t510 in se16, there you will see a popup window to enter values. after you enter the values in that window, then data related to those values that you entered in the popup window will displayed.
    How can we do that for the custom maintenance view?
    Thanks in advance for your help guys.
    Regards,
    Srinivas.

    In your custom maintainace view, if you select the Data browser / Table view maintainace under the tab "Maint Status" as "Dispaly maintanence allowed with restriction" than system will give you popup to restrict by selection.
    Regards,
    Naimesh Patel

  • Performance problem with select from _DIFF view

    Hi,
    we have a versioned table with more then one million records. We use the DBMS_WM.SetDiffVersions procedure and select from DIFF view to get data differences between two workspaces. The problem is that the select from the DIFF view is very slow. I takes more than 15 minutes. Has anybody an idea why it consumes so much time? Is there any way how to improve it?
    Thanks and regards
    Ondrej

    Hi,
    This can be due to any number of things, but is typically caused by an inefficient optimizer plan. Make sure that statistics on the _LT table have been recently analyzed.
    Also the following information would be useful:
    1. What is the relationship of the workspaces that you are trying to compare (parent/child, children of the same parent, etc) ?
    2. How many and of what type dml are being performed in the workspaces ?
    3. What version of Workspace Manager are you using and what is the version of the database ?
    4. What is the time needed to select from the _DIFF view based on the primary key ?
    Regards,
    Ben

  • ORA-00903 when selecting from a view

    Hi,
    I'm migrating our existing database on 8.1.7 to 9.2 and I keep getting an ORA-00903 error (on Oracle 9.2.0.1.0) when I try to select from a view with nested selects. Here's a very simple example - no rows are returned when I issue the query (its a dummy query, but it illustrates the problem). However, as soon as I turn it into a view, and do a select from the view, I get an Invalid Table Name error. Can anyone suggest why this is happening?
    So... This works on its own
    SELECT ID
    FROM (
    SELECT /*+ ORDERED */
    t.id
    FROM tblmsg t,
    tblevent e,
    e_workflowstate s,
    (SELECT e_taskstatus_id
    FROM e_taskstatus s,
    e_workflowplntasks ws
    WHERE s.e_taskstatus_id = ws.taskid
    UNION ALL
    SELECT e_taskstatus_id
    FROM e_taskstatus s,
    e_workflowmantasks ws
    WHERE s.e_taskstatus_id = ws.taskid
    UNION ALL
    SELECT e_taskstatus_id
    FROM e_taskstatus s,
    e_workflowtrgtasks ws
    WHERE s.e_taskstatus_id = ws.taskid) V
    WHERE t.id = e.id
    AND t.id = v.e_taskstatus_id
    AND V.e_taskstatus_id = e.id)
    But this doesn't
    CREATE OR REPLACE VIEW TESTVIEW AS
    SELECT ID
    FROM (
    SELECT /*+ ORDERED */
    t.id
    FROM tblmsg t,
    tblevent e,
    e_workflowstate s,
    (SELECT e_taskstatus_id
    FROM e_taskstatus s,
    e_workflowplntasks ws
    WHERE s.e_taskstatus_id = ws.taskid
    UNION ALL
    SELECT e_taskstatus_id
    FROM e_taskstatus s,
    e_workflowmantasks ws
    WHERE s.e_taskstatus_id = ws.taskid
    UNION ALL
    SELECT e_taskstatus_id
    FROM e_taskstatus s,
    e_workflowtrgtasks ws
    WHERE s.e_taskstatus_id = ws.taskid) V
    WHERE t.id = e.id
    AND t.id = v.e_taskstatus_id
    AND V.e_taskstatus_id = e.id);
    View created
    SELECT * FROM TESTVIEW;
    ERROR at line 1:
    ORA-00903: invalid table name
    This works fine on 8.1.7. I haven't tested it on 9.1 though.
    Any ideas?
    Thanks

    One thing to try would be to use SCHEMA.TABLENAME rather than just TABLENAME to refer to the tables.
    Its just a shot in the dark, but hopefully it may help.
    Martin.

  • ORA-01031 insufficient privileges  error when selecting from a view

    OK I think this might be a dumb question but I can't figure it out:
    User John has been granted SELECT privilege (directly, not through a database role) to schema FRED.table1;
    User John can issue select * from FRED.table1; and it works just fine.
    User John has then been granted SELECT privilege (directly, not via a database role) to schema
    MARK.view1;
    MARK.view1 only selects from FRED.table1. No other tables are in the view1.
    Schema MARK can successfully query the views. SELECT * FROM VIEW1 returns results.
    I also checked the MARK schema to ensure that it has been granted SELECT on FRED.table1 directly which it has.
    Now, when logged into schema John, I try SELECT * FROM MARK.VIEW1; and I get ORA-01031 insufficient privileges error.
    I'm not sure how to troubleshoot this. If John is granted SELECT ANY TABLE, it of course works but I don't want John to have that powerful priv.
    To recap, John has SELECT on both MARK.VIEW1 and the table which VIEW1 selects from (FRED.TABLE1).
    John can select from FRED.TABLE1 no problem but receives a privilege error even though John has SELECT on MARK.VIEW1.
    Any thoughts?
    Oh, Oracle EE 10.2.0.4

    JSebastian wrote:
    OK I think this might be a dumb question but I can't figure it out:
    User John has been granted SELECT privilege (directly, not through a database role) to schema FRED.table1;
    User John can issue select * from FRED.table1; and it works just fine.
    User John has then been granted SELECT privilege (directly, not via a database role) to schema
    MARK.view1;
    MARK.view1 only selects from FRED.table1. No other tables are in the view1.
    Schema MARK can successfully query the views. SELECT * FROM VIEW1 returns results.
    I also checked the MARK schema to ensure that it has been granted SELECT on FRED.table1 directly which it has.
    Now, when logged into schema John, I try SELECT * FROM MARK.VIEW1; and I get ORA-01031 insufficient privileges error.
    I'm not sure how to troubleshoot this. If John is granted SELECT ANY TABLE, it of course works but I don't want John to have that powerful priv.
    To recap, John has SELECT on both MARK.VIEW1 and the table which VIEW1 selects from (FRED.TABLE1).
    John can select from FRED.TABLE1 no problem but receives a privilege error even though John has SELECT on MARK.VIEW1.
    Any thoughts?
    Oh, Oracle EE 10.2.0.4Are you certain John has been granted select on Mark.view1 ? In order for that to work Mark would have to have been given select on Fred.table1 WITH GRANT OPTION ... otherwise the grant would fail and then John would not be able to select from the view because the grant was never successfully issued.
    Here's a basic test case (which i think conforms to what you've outlined) to get it working.
    drop user u1 cascade;
    drop user u2 cascade;
    drop user u3 cascade;
    create user u1 identified by u1;
    grant connect, resource to u1;
    create user u2 identified by u2;
    grant connect, resource, create view to u2;
    create user u3 identified by u3;
    grant connect, resource to u3;
    connect u1/u1@orcl
    create table test1 (col1 number);
    grant select on test1 to u2 with grant option; --> this is the important part
    grant select on test1 to u3;
    connect u2/u2@orcl
    create view test2 as select * from u1.test1;
    grant select on test2 to u3;
    connect u3/u3@orcl
    select * from u2.test2;

  • Getting Data from Maintenance view V001N into ABAP program

    Hello Experts,
    I have to fetch data from the maintenance view V001N in my ABAP program.  I have used select statement in my program but I am getting a syntax error  'V001N is not defined in the ABAP Dictionary as a table, projection view or database view. '.  V001N is a Maintenance view.
    Can anybody help me out how to get the data from that maintenance view into the internal table of my ABAP program.
    Regards.

    Sunil,
    check these threads
    https://forums.sdn.sap.com/click.jspa?searchID=18906946&messageID=6074746
    https://forums.sdn.sap.com/click.jspa?searchID=18906946&messageID=6088233
    so query on the tables which are used in the view
    Thanks
    Bala Duvvuri

  • Read data from maintenance view

    hi all,
    could anyone please tell me if there is any special way to read data from a maintenance view (if at all it is possible).
    i wrote a simple select on it but it gave me a syntax error that the view is not defined in the dictionary. (i am able to see the view definition by double clicking and it is active too).
    the following is my select.
    select single lgnum from v_t320 into (w_lgnum) where werks eq p_i_werks and lgort eq p_i_lgort.
    awaiting answers...
    regards,
    PJ

    Thanx Rich,
    but the documentation on maintenance views says that we can have read access to them. Does that mean the data can only be seen via the DDIC and not from a select written in a program??
    this is what i read...
    Maintenance Status
    The maintenance status of a view controls whether data records can also be changed or inserted in the tables contained in the view.
    The maintenance status can be defined as follows:
    Read only: Data can only be read through the view.
    Read, change, delete, insert: Data of the tables contained in the view can be changed, deleted, and inserted through the view.
    Only read access is permitted for database views that are defined through several tables. If a database view contains only one single table, data can be inserted in this table through the view (see Inserts Through Database Views).
    The following status definitions are also possible for maintenance views:
    Read and change: Existing view entries can be changed. However, records cannot be deleted or inserted.
    Read and change (time-dependent views): Only entries whose non-time-dependent part of the key is the same as that of existing entries may be inserted.
    you surely have earned some points here....just let me be clear of the concept behind this
    regards,
    PJ

  • Extracting from maintenance view

    Hello Experts,
    There is a maintenance view in R/3 which I have to extract. When I try to enter this view in the RSA2 for the creation of generic datasource I get an error "Only transparent tables and database views can be extracted"
    Do i have to create a Database view based on the same definetion?
    Is there any direct way to converting this maintenance view to database view?
    Is there any other alternative to create datasource for a maintenance view?
    Any suggestions appreciated.
    Thanks a bunch,
    BWer

    Hi BWer,
    1st option: make a copy of the view to a z-view and change the view type to database view.
    2nd option: create a fm using the view as extract structure and select data from it in the fm.
    regards
    Siggi

  • Invalid Column Name on select from materialized view?

    Hey all, I have created this materialized view for my java to select from. For some reason when I try to select from it, I get invalid column name. Here is my mat view statement in its simplest form:
    create materialized view mv_pgridtcevcluster_property as
    select distinct clustername_ as "OBJECT_ID", CLUSTERNAME_, LICENSEMODE_
    from p_gridtcevcluster p
    order by clustername_;
    Now when I run my select statement from jdbc:
    SQL: select object_id from MV_PGRIDTCEVCLUSTER_PROPERTY
    java.sql.SQLException: Invalid column name
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:208)
         at oracle.jdbc.driver.OracleStatement.getColumnIndex(OracleStatement.java:3319)
         at oracle.jdbc.driver.OracleResultSetImpl.findColumn(OracleResultSetImpl.java:1926)
         at oracle.jdbc.driver.OracleResultSet.getString(OracleResultSet.java:1515)
         at com.mchange.v2.c3p0.impl.NewProxyResultSet.getString(NewProxyResultSet.java:3342)
         at historian.objects.mgmt.udrManagerTest.gatherObjects(udrManagerTest.java:73)
    Anyone have issues with this before? It seems to throw the error sporatically, any help would be much appreciated!
    Regards,
    TimS
    Edited by: TimS on Mar 30, 2009 1:54 PM
    Nevermind, figured it out. Was using wrong column name identifier when picking values from resultset.

    Since you have "OBJECT_ID" in quotes, Oracle stores the column name literally and case sensitively, and the column name must be capitalized when referenced.
    From a regular sql*plus window, try
    select object_id from mv_pgridtcevcluster_property;
    select OBJECT_ID from mv_pgridtcevcluster_property;
    select "OBJECT_ID" from mv_pgridtcevcluster_property;What is the result from each of them?

  • Selecting from a view when tables are in more than one schema problem

    I give up where am I missing it. Why is the ORA-01031 error being generated on the view u1.bv1. In testing even if I give object access to u3 I still get the same errors:
    SQL>
    SQL> drop user u1 cascade;
    drop user u1 cascade
    ERROR at line 1:
    ORA-01918: user 'U1' does not exist
    SQL> drop user u2 cascade;
    drop user u2 cascade
    ERROR at line 1:
    ORA-01918: user 'U2' does not exist
    SQL> drop user u3 cascade;
    drop user u3 cascade
    ERROR at line 1:
    ORA-01918: user 'U3' does not exist
    SQL> drop role aRole;
    drop role aRole
    ERROR at line 1:
    ORA-01919: role 'AROLE' does not exist
    SQL>
    SQL>
    SQL> select user from dual;
    USER
    SYS
    1 row selected.
    SQL>
    SQL> select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi
    PL/SQL Release 10.2.0.1.0 - Production
    CORE     10.2.0.1.0     Production
    TNS for Solaris: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    5 rows selected.
    SQL>
    SQL> create user u1 identified by u1 default tablespace users
    2 quota unlimited on users;
    User created.
    SQL>
    SQL> create user u2 identified by u2 default tablespace users
    2 quota unlimited on users;
    User created.
    SQL>
    SQL> create role aRole;
    Role created.
    SQL>
    SQL> create user u3 identified by u3 default tablespace users;
    User created.
    SQL>
    SQL> grant aRole to u3;
    Grant succeeded.
    SQL>
    SQL> alter user u3 default role all;
    User altered.
    SQL>
    SQL> grant create session to u3;
    Grant succeeded.
    SQL>
    SQL> create table u1.t1(c1 number);
    Table created.
    SQL>
    SQL> create table u2.t1(c1 number);
    Table created.
    SQL>
    SQL> grant select on u2.t1 to u1;
    Grant succeeded.
    SQL>
    SQL> create or replace view u1.bv1 as
    2 select u1.t1.c1 as c1 ,u2.t1.c1 as c2
    3 from u1.t1, u2.t1 where u1.t1.c1 = u2.t1.c1;
    View created.
    SQL>
    SQL> grant select on u1.bv1 to aRole;
    Grant succeeded.
    SQL>
    SQL> create or replace view u1.gv1 as select * from u1.t1;
    View created.
    SQL>
    SQL> grant select on u1.gv1 to aRole;
    Grant succeeded.
    SQL>
    SQL> connect u3/u3
    Connected.
    SQL>
    SQL> select * from u1.bv1;
    select * from u1.bv1
    ERROR at line 1:
    ORA-01031: insufficient privileges
    SQL>
    SQL> select * from u1.gv1;
    no rows selected
    SQL>
    SQL> spool off

    User u1 cannot do a grant on a view to other user if the view uses tables from other schemas unless you do a "with grant option" grant.
    You need to do the following to make it work:
    SQL> grant select on u2.t1 to u1 with grant option;
    Grant succeeded.
    SQL>

Maybe you are looking for