‎2007 Mar 29 9:22 AM
Hi friends,
We all know that view provides access for more than one table. Then what is
the main use of view, ie where we are actually using views and please tell me
about how to create views.
with regards,
Nanjunda sharma
‎2007 Mar 29 9:33 AM
Hi,
Say you repeatedly need a few fields from different tables.
e.g. MARA-MATNR, MARA-MTART, MARA-MATKL, MARC-WERKS, MARC-PSTAT and 10 more fields.
Now, every time either you have to put a join on all the tables from which the data is required and taht will take a lot of time.
Instead of that, we create a view which contains only the required fields. In this case we simply write our select query on the view and fetch the data instead of taking it from different tables.
This simplifies ur programming efforts.
Views can be created using transaction SE11.4 types of views are there.
Regards,
Himanshu
‎2007 Mar 29 10:28 AM
Do we need to declare the VIEW before using it in the table.
like TABLES : mara, etc...n VIEW.
like this.
Regards,Ram
‎2007 Mar 29 9:34 AM
Originally, in database theory, a view is a read only virtual or logical table composed of the result set of a query. Unlike ordinary tables in a relational database, a view is not part of the physical schema: it is a dynamic, virtual table computed or collated from data in the database. Changing the data in a table alters the data shown in the view.
Views can provide advantages over tables;
. They can subset the data contained in a table
. They can join and simplify multiple tables into a single virtual view
. Views can act as aggregated tables, where aggregated data (sum, average etc.) are calculated and presented as part of the data
. Views can hide the complexity of data, for example a view could appear as Sales2000 or Sales2001, transparently partitioning the actual underlying table
. Views do not incur any extra storage overhead
Depending on the SQL engine used, views can provide extra security.
reward if u find answer suitable
regards
navjot
‎2007 Mar 29 9:37 AM
The procedure for creating a view depends on the view type.
Procedure
Select object class View in the initial screen of the ABAP Dictionary, enter the view name and choose Create.
A dialog box appears in which you must select the view type.
You go to the maintenance screen of the selected view type tick
the rest of procedure depends on the type of view u want to make
<b>Creating a Database View</b>
Procedure
Enter an explanatory short text in the field Short text.
You can for example find the view at a later time using this short text.
Define the tables to be included in the view in the Tables field of the Tables/Join conditions tab page.
Keep in mind that you can only include transparent tables in a database view.
Link the tables with join conditions.
If there are suitable foreign keys between the tables, you should copy the join conditions from these foreign keys (see Foreign Key Relationships and Join Conditions).
Place the cursor on a table name and choose Relationships. All foreign keys to other tables defined for this table are displayed. Select the foreign keys and choose Copy. The join condition is now derived from the definitions in the foreign key.
If you only want to see the foreign key relationship existing between two tables, you must first select these two tables (click on the first column of the input area Tables) and then choose Relationships.
On the View fields tab page, select the fields that you want to copy to the view.
Choose Table fields. All the tables contained in the view are displayed in a dialog box. Select a table. All the fields contained in this table are displayed. You can copy fields by selecting them in the first column and choosing Copy.
You can also include an entire table in the view (see Includes in Database Views).
On the Selection conditions tab page, you can (optionally) formulate restrictions for the data records to be displayed with the view (see Maintaining Selection Conditions for Views).
The selection conditions define the data records that can be selected with the view.
With Goto ® Technical settings, you can (optionally) maintain the technical settings of the database view.
You can define whether and how the database view should be buffered here. Proceed as for the technical settings of a table (see Maintaining Technical Settings). Note that only the settings for buffering can be maintained for database views.
On the Maintenance status tab page, select the maintenance status of the database view.
If the view contains more than one table, the maintenance status read only cannot be altered.
Save your entries. You are asked to assign the view a development class.
You can change this development class later with Goto ® Object directory entry.
<b>Creating Maintenance Views</b></u>
Procedure
Enter an explanatory short text in the field Short text.
You can for example find the view at a later time using this short text.
Enter the primary table of the view under Tables in the Tables/Join conditions tab page.
Only those tables that are linked with the primary table (indirectly) with a foreign key can be included in the maintenance view.
If required, include more tables in the view. In a maintenance view you can only insert tables that are linked to one another with foreign keys.
Place the cursor on the primary table and choose Relationships. All existing foreign key relationships of the primary table are displayed. Select the required foreign key and choose Copy. The secondary table used in such a foreign key is included in the view. The join conditions derived from the foreign keys (see Foreign Key Relationship and Join Condition) are displayed.
You can also insert tables that are linked by foreign key with one of the secondary tables that was already inserted. To do this, place the cursor on the secondary table and choose Relationships. Then proceed as described above.
For maintenance and help views, there are certain restrictions on the foreign keys with which the tables can be included in the view (see Restrictions for Maintenance and Help Views). The foreign keys violating these conditions are displayed at the end of the list under the header Relationships with unsuitable cardinality.
On the View fields tab page, select the fields that you want to copy to the view.
Choose Table fields. All the tables contained in the view are displayed in a dialog box. Select a table. The fields of the table are now displayed in a dialog box. You can copy fields by selecting them in the first column and choosing Copy.
All key fields of the primary table must be included in a maintenance view. In addition, all key fields of secondary tables that are not involved in the foreign key (that is, which are not linked via a join condition to a key field already included in the view) must be included in the view.
This ensures that the records inserted with a maintenance view can be written correctly in the tables contained in the view.
On the Selection conditions tab page, you can (optionally) formulate restrictions for the data records that can be displayed with the view (see Maintaining Selection Conditions for Views).
The selection conditions define the data records that can be selected with the view.
In the Maintenance status tab page, define the maintenance status of the view.
The maintenance status defines how you can access the view data with the standard maintenance transaction (SM30).
Choose .
At activation, a log is written; it can be displayed with Utilities ® Activation log. If errors or warnings occurring when the view was activated, the activation log is automatically displayed.
Go to Transaction SE54 with Environment ® Tab.maint.generator.
regrads
navjot
award points if helpfull
Message was edited by:
navjot sharma
Message was edited by:
navjot sharma
‎2007 Mar 29 9:50 AM
Hi Nanjunda,
View is an data dictionary object which provides us excess to related data of two or more tables.
suppose we have two tables MARA and MAKT in MARA we have material, material type but we don't have material description but in MAKT we have material and material description but we dont have material type. So you can see we dont have a common table where we can fiond all three fields togather.
In such situations we create Views.
To ceate views:
Go to SE11.
Enter the name of view you want to create.
select 'Database View'
here you need to define table names and the join condition (In our case tables are MARA and MAKT and join condition will be MARA-MATNR = MAKT-MATNR)
Then you define View fields (in our case it will be MATNR, MAKTX and MTART)
you can also define a selection condition such as SPRAS = 'E' or whatever you want.
thats it.
Now u can see all ralated data (all fields u have in view) in that view.
You can also use it in select query of your program.
Reward points if helpful.
Thanks,
Pankaj Sharma
‎2007 Mar 29 10:30 AM
Views
Data about an application object is often distributed on several tables. By defining a view, you can define an application-dependent view that combines this data. The structure of such a view is defined by specifying the tables and fields used in the view. Fields that are not required can be hidden, thereby minimizing interfaces. A view can be used in ABAP programs for data selection.
There are 4 types views are avilable in SAP.
Database View - To club more than one table
Projection View - To hide fields in one table
Maintanance View - To maintain database records in table
Help View - To provide help for a fields (Same functionality as Search help. This is outdated)
View are improves perfromance in the following aspects
1. If you want to use more than two table in 'JOIN' condition better to use Views . It will improves performance of a program
2. If you want to use mutiple FOR ALL ENTRIES clause, better to club all SELECT statement in a view.
The data of a view is derived from one or more tables, but not stored physically. The simplest form of deriving data is to mask out one or more fields from a base table (projection) or to include only certain entries of a base table in the view (selection). More complicated views can comprise several base tables, the individual tables being linked with a relational join operation. See also Join, Projection and Selection.
The base tables of the view must be selected in the first step of a view definition. In the second step, these tables must be linked by defining the join conditions. It is also possible to use the join condition from a foreign key defined between the tables (see Foreign Key Relationship and Join Condition). In the third step, you must select the fields of the base tables to be used in the view. Selection conditions that restrict the records in the view can be formulated in the fourth step.
Four different view types are supported. These differ in the way in which the view is implemented and in the methods permitted for accessing the view data.
Database views are implemented with an equivalent view on the database.
Projection views are used to hide fields of a table (only projection).
Help views can be used as selection method in search helps.
Maintenance views permit you to maintain the data distributed on several tables for one application object at one time.
Database views implement an inner join. The other view types implement an outer join (see Inner and Outer Join).
The join conditions for database views can be formulated using equality relationships between any base fields. The join conditions for the other view types must be obtained from existing foreign keys. Tables therefore can only be combined in a maintenance view or help view if they are linked to one another with foreign keys.
The maintenance status defines whether you can only read data with the view or whether you can also insert and change data with it.
1.Views does not contain data in it. It fetches data from the database only depending on the condition ...
2.Views are part of data dictionary. They are a window to view the data in database
3.views can be used to give security to data. users can be allowed to view only basic data only
check this
https://forums.sdn.sap.com/click.jspa?searchID=234671&messageID=2590691
Message was edited by:
sunil kumar