GoodleAds

VIEWS ( PROJECTION AND DATABASE VIEW ) IN DATA DICTIONARY

VIEWS IN DATA DICTIONARY:

Views : 

Each application has their own database tables. If you want to display the part of the data from each table then we fetch required data from each table and merge the data and display the data.

If is is a regular activity then it is better to create a View.
Views are logical databases.
View doesn't contains the data, at run time only view contains the data.

There are 4 types of Views;
       1. Projection View
       2. Database View
       3. Help View
       4. Maintenance View

Projection View: 

If you want to display the part of the data from a single table and if it is a regular activity then its better to create Projection view.

Steps to create Projection View:

1. Execute SE11.
2. Select the radio button "View".
3. Provide the Projection view name ( Eg: ZPV_KNB1 ) and click on Create.


4. Select the radio button "Projection view" and click on Copy.



5. Provide the short description (Eg: view for customer master data)
6. Provide basis table ( Eg: KNB1 ) and click on Table fields.


7. Select the required fields and click on Enter then the added fields are shown as below.



8. Save, Check and Activate.

View in Program:

*&---------------------------------------------------------------------*
*& Report  ZPV_IN_PROGRAM
*&
*&---------------------------------------------------------------------*

REPORT  ZPV_IN_PROGRAM.

* Declare the data
TYPES: BEGIN OF TY_KNB1,
              KUNNR TYPE KNB1-KUNNR,
              BUKRS TYPE KNB1-BUKRS,
              PERNR TYPE KNB1-PERNR,
              AKONT TYPE KNB1-AKONT,
              END OF TY_KNB1.

DATA : LS_KNB1 TYPE TY_KNB1,
             LT_KNB1 TYPE TABLE OF TY_KNB1.

* Fetch the data from view
SELECT KUNNR
       BUKRS
       PERNR
       AKONT
       FROM ZPV_KNB                                     " From view
       INTO TABLE LT_KNB1.

* Display the data
LOOP AT LT_KNB1 INTO LS_KNB1.

  WRITE :/ LS_KNB1-KUNNR,
                   LS_KNB1-BUKRS,
                   LS_KNB1-PERNR,
                   LS_KNB1-AKONT.

  ENDLOOP.

Output:






Database View:

If you want to display the part of data from more than one table then we fetch the data from each table and merge the data and display the data. If it is a regular activity then its better to create the database view.

Database view pick the data from both the tables if and only if there is one or more than one entry is available in right hand side table with corresponding left hand side table.

Steps to create Database View:

1. Execute SE11.
2. Select the radio button "View".
3. Provide the View name ( Eg: ZVS_DBV ) and click on Create.


4. Select radio button "Database view" and click on Copy.


5. Provide short description ( Eg: Database view for company and customer tables ).
6. Provide participated database tables in the left side. ( Eg: T001, KNB1 ).
7. Select all the tables and click on Relationships.


8. Select the Check box and click on Copy.


9. Click on View fields tab and click on Table fields button.



10. Select each table and click on choose.
11. Select the required fields from each table and click on Copy. Now the view contains the following fields.



12. Save, Check and Activate.

Database view in Program:

*&---------------------------------------------------------------------*
*& Report  ZDBV_IN_PROGRAM
*&
*&---------------------------------------------------------------------*

REPORT  ZDBV_IN_PROGRAM.

* Data Declaration
TYPES: BEGIN OF TY_FINAL,
              BUKRS TYPE T001-BUKRS,
              BUTXT TYPE T001-BUTXT,
              KUNNR TYPE KNB1-KUNNR,
              ERDAT TYPE KNB1-ERDAT,
              END OF TY_FINAL.

DATA : LS_FINAL TYPE TY_FINAL,
             LT_FINAL TYPE TABLE OF TY_FINAL.

* Fetch the data from view
SELECT BUKRS 
                BUTXT 
                KUNNR 
                ERDAT
    FROM ZVS_DBV                     " From Database view                 
    INTO TABLE LT_FINAL.

* Display the data
  LOOP AT LT_FINAL INTO LS_FINAL.

    WRITE: / LS_FINAL-BUKRS,
                     LS_FINAL-BUTXT,
                     LS_FINAL-KUNNR,
                     LS_FINAL-ERDAT.

    ENDLOOP.


Output:












No comments:

Post a Comment