Thursday 16 June 2016

Database View


  • DB views can be created on the database and are defined in the ABAP Dictionary once they are activated. They are provided for the user as virtual tables.
  • It is possible to access the data of a DB view in ABAP/4 programs both with OPEN SQL and with NATIVE SQL.
  • Since the Database View is implemented on a database, only transparent tables can be used to create them.
  • If a DB view is also to be used to insert new records in its (only) base table, the initialization flag should be set for the base table fields which are not view fields. In this case, these fields will automatically be filled with the initial value by the view when a new record is inserted.



Ex :

Steps :


  • Go to Transaction Code SE11.

  • Click the view radio button.

  • Enter the View name Start's with Y or Z<View name > and click on create.

  • Select the Database View from the pop up box. 

  • Enter short description.


  • Table  : ZSD_VBAK

  • And records are ,


  • Table  : ZSD_VBAP.


  • And records are ,

  • Both the tables are related using foreign key .
  • Enter the Table name,

  • Click on Relationships button.

  • Pop-up will appear , Click on check box and copy button.

  • Database implemented based on Inner Join.

  • To select the viewing fields , click on View Fields Tab.


  • Click on Table fields Button.


  • Select some fields from Table ZSD_VBAK and click on Choose Button.

  • Select the fields .

  • Click on Copy Button.

  • Now , Select some fields from ZSD_VBAP Table.
  • Click on Table Fields Button.

  • Select ZSD_VBAP table and click on Choose Button.

  • Select the fields and Click on Copy Button.

  • Click on Maintenance Status Tab.

  •  Save -> Check -> Activate.


  • Click on Utilities - > Contents.

  • Click on Execute.


Output




Note: We displayed the data without specifying conditions. In short, specifying conditions is optional.


Displaying data with specifying conditions :


  • Click on selection conditions.

  • Click on Table Fields  , based on which  Table field  you want specify the selection criteria.

  • Select the Table name and click on choose.

  • Select the field  name and click on copy button.


  • Click on operator F4 help.

  • Select the operator as per requirement.

  • Enter the Comparison value.

  • Save -> Check -> Activate.

  • Click on Utilities - > Contents.

  • Click on Execute.

Output




No comments:

Post a Comment