Showing posts with label projection views. Show all posts
SAP ABAP Views

SAP ABAP Views

Sanjo Thomas•07:46:00

VIEWS
·         A View is collection of  fields from multiple Tables.
·         Views doesn't store any data.
·         Whenever a view is executed, it displays the data by selecting from multiple Tables.
·         To create a view , we must join the tables.
·         To join the tables there must be at least one common key field.

JOIN:
·         It  is a concept  to link  two (or) multiple tables  for displaying  the data.
·         There are two types  joins. 
                  1.  Inner Join.
                  2.  Outer Join (or) Left Outer Join.


INNER JOIN:
·         In  this  type of join, only the matching record b/w two (or) multiple tables will be selected.
·         The unmatched records will not be selected.
OUTER JOIN:
·         In this type of join , all the records from left table(1st table) will be displayed.
·         If there is a matching record in the 2nd (or) 3rd table the data will be displayed.
·         If there is no matching  record, the data will be displayed as blank values.
Types of Views:
·         There are 4 types views.

1. DATABASE View
2. PROJECTION  View.
3. HELP View.
4. MAINTENANCE View.
1. DATABASE VIEW:
·         A  view created on  two (or) more tables by clubbing the fields using inner join is called " DATABASE VIEW".
·         In this View, we can only read the data.
·         we cannot do any maintenance operation.
·         Since , database view uses inner join , it selects only the matching records b/w the tables.
Steps to create DB View:
Business Req:  Develop a DB View on  MARA , MAKT  tables to displays MATNR, MTART,
MBRSH , MEINS , SPRAS , MAKTX.
Steps:
·         Go to SE11.
·         Select   View and give the name as:  ZDBVIEW1
·         Click on Create button.
·         Select  the DATABASE  VIEW as below and click copy button.


·         Go to Tables/Joins Conditions.
·         Provide Table names along with JOIN condition as below.

·         Now Click on View Flds Tab.
·         Now Click on Table Fields Button.
·         Now Double Click On MARA table, select the fields MATNR, MTART, MBRSH, MEINS and click on  COPY Button.
·         Similarly, Double Click on  MAKT table, select the fields  SPRAS, MAKTX.
·         Now Go to Selection Condition Tab, provide the condition as below.
·         Save , Check and Activate.
·         Now Click on Content icon.
·         Now Click on Execute button.





2. PROJECTION VIEW:
·         A view is created on single table is called "PROECTION VIEW".
·         The main advantage of using Projection View is, we can project only required (or) limited fields by filtering the unwanted fields.
·         We can read and maintain the data , since the view is created on single table.
·         From  database point of view, Projection views improves the system performance. Bcoz  we have minimize the fields.
Business Req:  Develop a Projection View on MARA table to display only  MATNR, MTART, MBRSH, MEINS.
Steps:
·         Go to SE11.
·         Select View and give the name as ZPROJVIEW1 and click on CREATE button.
·         Select the PROJECTION VIEW and click on copy button as below.
·         Provide the short Description.
·         Give the table names as below and click on Table Fields Button , select the fields as below.
·         Click on Maintenance Status Tab.
·         Select  "Read and Change " Radio Button.
·         Save , Check and Activate.
·         Click on Contents Icon
·         Click on Execute , data will be displayed.








3. HELP  VIEW:
·         A view created on two (or) more tables for "Search-helps" is called "Help-View".
·         Help View uses outer Join Concept.
·         Here also , we can only read the data, but we can't maintain the data.
·         we can not execute Help views directly, bcoz they are designed  specially for "Search-Helps".
STEPS:
·         Go to SE11.
·         Select View and give the name as ZHELPVIEW1 and click on CREATE button.
·         Select the HELP VIEW and click on copy button as below.

·         Provide the short description.
·         Give the Table as MARA and Press enter.
·         Now, Click on Relationship Button and select as below screen and click on copy button.
·         Join Condition automatically proposed by system as below.
·         Go to  ViewFlds Tab.
·         Now, Click on Table Fields button and select MARA ,click on Choose button and select the Fields and click on copy button.
·         Similarly, select MAKT Table and select required fields as below.
·         Go to Selection Conditions Tab.
·         Now, Give the condition as below.
·         Click on Save, Check and Activate.










3. MAINTENANCE  VIEW:
·         A View created on two (or) More tables using inner join is called as "Maintenance View".
·         In this view, we can read the data and maintain the data.
·         Maintenance View should not be created on standard tables. Bcoz, the data inconsistency problem will come when we change the records.
·          Maintenance View should be created on custom tables (Z/Y tables).
STEPS:
·         Go to SE11.
·         Select View and give the name as ZMAINVIEW1 and click on CREATE button.
·         Select the MAINTENACE VIEW and click on copy button as below.
MAIN.jpg
·         Provide the short description.
·         Give the Table as MARA and Press enter.
·         Now, Click on Relationship Button and select as below screen and click on copy button.
·         Join Condition automatically proposed by system as below.
·         Go to ViewFlds Tab.
·         Now, Click on Table Fields button and select MARA ,click on Choose button and select the Fields and click on copy button.
·         Similarly, select MAKT Table and select required fields as below.
·         Go to Selection Conditions Tab and provide the condition as below.
·         Go to Maint.Status Tab and select as showned below.
·         Click on Save , Check and Activate.
·         Click on Utilities--> Table Maintenance Generator.
·         Provide details as below.
Note:  Provide Active function Group Name.
·         Click on Create button.
·         Click on Save.
·         Go to SM30.
·         Provide the view name.
·         click on maintain button.
·          
Read more