Scrol

SAP Trainings contact sap.sreeram@gmail.com or 091-9916083157, 001-210-399-8414

Reasons To create Logical data Base


SAP comes loaded with all the extras. Among the extras that are most helpful to IT managers are all the access routines needed to pull any business object that managers can think of out of SAP databases. However, SAP has not thought of everything where your particular applications are concerned. SAP organizes its standard database tables to service business units based on conventional business applications. It’s likely your business requires something new, perhaps even something exotic. In that case, you will need to create a new database, using information from different places. Basically, you need a logical database. You need to create a virtual business data object repository consisting of a new kind of record or table that suits your purposes. In addition, the repository should be composed of information that is actually stored in a number of different locations, none of them necessarily logically associated with one another. Let’s take a closer look at creating logical databases.

A case for a logical database
Suppose my company manufactures widgets of the most obscure variety, and they are components of other widgets. I sell my widgets as raw material for the more sophisticated widgets built by others, but in some cases I actually partner with other manufacturers in creating yet another class of widget. Now, in my world, I consequently have customers who are also partners. I sell to them and I partner with them in manufacturing and distribution. Also, I need an application that uses both of these dual-use relationships.

Essentially, I have a customer database and a partner database. Neither contains records that are structured to contain the identifying particulars of the other. Thus, I need a hybrid database that gives me tables detailing these hybrid relationships. What can I do? I can go the long way around and write a new database, pulling information from both and creating new objects with a customized program that I write by hand. However, this process is cumbersome and contains maintenance issues. On the other hand, I can use SAP’s logical database facility, create my logical database in a couple of minutes, and have no maintenance issues at all.

Logical database structures
There are three defining entities in an SAP logical database. You must be clear on all three in order to create and use one.
  • Table structure: Your logical database includes data from specified tables in SAP. There is a hierarchy among these tables defined by their foreign keys (all known to SAP), and you are going to define a customized relationship between select tables. This structure is unique and must be defined and saved.
  • Data selection: You may not want or need every item in the referenced tables that contributes to your customized database. There is a selection screen that permits you to pick and choose.
  • Database access programming: Once you’ve defined your logical database, SAP will generate the access subroutines needed to pull the data in the way you want it pulled.

Creating your own logical database
ABAP/4 (Advanced Business Application Programming language, version 4) is the language created by SAP for implementation and customization of its R/3 system. ABAP/4 comes loaded with many predefined logical databases that can construct and table just about any conventional business objects you might need in any canned SAP application. However, you can also create your own logical databases to construct any custom objects you care to define, as your application requires in ABAP/4. Here’s a step-by-step guide:
  1. Call up transaction SLDB (or transaction SE36). The path you want is Tools | ABAP Workbench | Development | Programming Environment | Logical Databases. This screen is called Logical Database Builder.
  2. Enter an appropriate name in the logical database name field. You have three options on this screen: Create, Display, and Change. Choose Create.
  3. You’ll be prompted for a short text description of your new logical database. Enter one. You’ll then be prompted to specify a development class.
  4. Now comes the fun part! You must specify a root node, or a parent table, as the basis of your logical database structure. You can now place subsequent tables under the root table as needed to assemble the data object you want. You can access this tree from this point forward, to add additional tables, by selecting that root node and following the path Edit | Node | Create. Once you’ve saved the structure you define in this step, the system will generate the programming necessary to access your logical database. The best part is you don’t have to write a single line of code.

Watch out!
The use of very large tables will degrade the performance of a logical database, so be aware of that trade-off. Remember that some tables in SAP are very complex, so they will be problematic in any user-defined logical database.


Declaring a logical database
Here’s another surprising feature of logical databases: You do not assign them in your ABAP/4 Code. Instead, the system requires that you specify logical databases as attributes. So when you are creating a report, have your logical database identifier (the name you gave it) on hand when you are defining its attributes on the Program Attributes screen. The Attributes section of the screen (the lower half) will include a Logical database field, where you can declare your logical database.

Logical databases for increasing efficiency
Why else would you want to create a logical database? Consider that the logical databases already available to you begin with a root node and proceed downward from there. If the data object you wish to construct consists of items that are all below the root node, you can use an existing logical database program to extract the data, then trim away what you don’t want using SELECT statements—or you can increase the speed of the logical database program considerably by redefining the logical database for your object and starting with a table down in the chain. Either way, you’ll eliminate a great deal of overhead.

SAP ABAP LOGICAL DATABASE (LDB) Step to step Creation


Creating a Logical Database Locate the document in its SAP Library structure

To create a new logical database, you should follow the procedure below. The Logical Database Builder then saves you work by using components that you have already defined to generate proposals for other components. Some of the most important attributes of a logical database are set when you define its structure. When you have defined the structure, the Logical Database Builder automatically generates a proposal for the selection include. The system then generates an input mask for the database program, based on the structure of the logical database and the selections.
These generated proposals allow you to create a working logical database quickly. However, you must program refinements such as authorization checks and performance optimization yourself.

Procedure for Creating a Logical Database

...
       1.      Enter a name on the initial screen of the Logical Database Builder and choose Create.
       2.      A dialog box appears. Enter a short text. You can change this later by choosing Extras ® Short text or Administration info.
       3.      Once you have entered the short text, you must define the root node of the logical database. Enter the node name and its attributes. There are three different types of nodes:
§         Database tables. The table must be active in the ABAP Dictionary. Tables always have a flat structure. The name of the node must correspond with the name of the table.
§         Data types from the ABAP Dictionary: The node may refer to any data type in the ABAP Dictionary. The node name and the name of the data type do not have to be the same. You can use deep data types as nodes.
§         Data types from type groups: The node can also refer to a data type from a type group in the ABAP Dictionary. Enter the name of the type group in the corresponding field. You must choose Other types before specifying this type. Data types in type groups were the forerunners of real data types in the ABAP Dictionary. Wherever possible, you should use ABAP Dictionary data types. They have all of the semantic properties of their underlying data elements. This is useful, for example, when you use a logical database to create ABAP Queries.
You can use the Text from Dictionary function to adopt the text stored in the ABAP Dictionary for the relevant table or data type.
       4.      The structure editor of the Logical Database Builder appears. On the left is the name of the root node, followed by a code for the node type: T for a database table, S for a ABAP Dictionary type, and C for a type from a type group. The new logical database now has a structure with a single node.
       5.      You can now extend the structure as described in Editing the Structure.
       6.      If you choose Next screen (right arrow in the application toolbar), a screen appears on which you can enter a search help for the logical database as described under Editing Search Helps.
       7.      If you choose Next screen (right arrow in the application toolbar), a dialog box appears, asking you whether the system should generate the selections for the logical database. When you have confirmed the dialog box, a list appears, on which you can select all of the nodes that you want to use for field selections or dynamic selections. The fields that you select are included in the source code generated by the system for the selection include.
       8.      The generated selection include is displayed in the ABAP Editor. You can change it as described in Editing Selections.
       9.      If you choose Next screen (right arrow in the application toolbar), a dialog box appears, asking you whether the system should generate the database program for the logical database. The database program is generated from the structure and the selection include. It has a modular structure, consisting of several include programs and all of the necessary subroutines, with proposals for the statements that will read the data.
   10.      The generated database program is displayed in the ABAP Editor. You can change it as described in Editing the Database Program.
   11.      If you repeatedly choose Previous screen (left arrow in the application toolbar), you can display and change the general attributes of the logical database.
   12.      Finally, you can maintain optional selection texts and documentation.

SAP ABAP LOGICAL DATABASE (LDB)


What are logical databases?  What are the advantages/disadvantages of logical databases?
Ans: - A Logical Database is a hierarchical structure of tables. Use the GET statement to process Logical Databases.
·         LDB consists of logically related tables grouped together – used for reading and processing data.
·         Advantages = 1. No need of programming for retrieval, meaning for data selection
·                                2. Easy to use standard user interface, have check completeness of user input.

Disadvantages = 1. Fast in case of lesser no. of tables But if the table is in the lowest level of hierarchy, all upper level tables should be read so performance is slower.

Preparation of the data records by the L.D.B and reading of the data records in the actual report are accomplished with the command pair.
-     Put and Get.

The three main elements of LDB are 
-           Structure, Selections, Database Program.
What sort of tables one can use in designing the hierarchy of  a  LDB ?
-     Tables, which are having Foreign, key relations.
The structure of Logical Databases reflects the ________________ dependencies of hierarchical tables in the SAP System.
-     Foreign key
If you want to improve the response time (time to access data) Logical Databases permits you to achieve this using  ______________
-     VIEWS.
What are the advantages of Logical Databases?
-     It offers an easy-to-use selection screen.  You can modify the pre-generated selection screen to your needs.            It offers check functions to check whether user input is complete, correct, and plausible.  It offers reasonable data selections.  It contains central authorization checks for database accesses.  Enhancements such as improved performance immediately apply to all report programs that use the logical database.

SAP ABAP DATA DICTIONARY


Type of a table or structure                                               
                                                                            
    The table type determines how the logical table description defined in 
    the ABAP/4 Dictionary is reproduced on the database.                   
                                                                            
    There are the following table types:                                   
    o  transparent table                                                   
    o  structure                                                            
    o  append structure                                                    
                                                                           
    For internal purposes, such as storing control data or update texts,   
    there are in addition the following table types:                       
    o  pooled table                                                        
    o  cluster table                                                       
    o  generated view structure                                            
                                                                           
 Transparent table                                                            
                                                                               
     There is a physical table on the database for each transparent table. The
     names of the physical tables and the logical table definition in the     
     ABAP/4 Dictionary correspond.                                             
     All business data and application data are stored in transparent tables. 
                                                                              
 Structure                                                                       
                                                                                
     No data records exist in the database for a structure. Structures are      
     used for the interface definition between programs or between screens and  
     programs.                                                                  
                                                                                
 Append structure                                                              
                                                                                
     An append structure defines a set of fields which belong to another table 
     or structure but which are treated in the correction administration as    
     its own object.                                                           
     Append structures are used to support modifications.                      



                                                                              
 Pooled table                                                                
                                                                             
     Pooled tables can be used to store control data (e.g. screen sequences, 
    program parameters or temporary data). Several pooled tables can be     
     combined to form a table pool. The table pool corresponds to a physical 
     table on the database in which all the records of the allocated pooled  
     tables are stored.                                                       
                                                                             
 Cluster table                                                                  
                                                                                 
     Cluster tables contain continuous text, for example, documentation.        
     Several cluster tables can be combined to form a table cluster. Several    
     logical lines of different tables are combined to form a physical record   
     in this table type. This permits object-by-object storage or               
     object-by-object access. In order to combine tables in clusters, at least  
     parts of the keys must agree. Several cluster tables are stored in one      
     corresponding table on the database.                                       
                                                                               
 Generated view structure                                                       
                                                                                
     In activation a structure is generated for a view. This structure serves  
     as interface for the runtime environment. It does not generally appear in 
     the ABAP/4 Dictionary.                                      

What is a Data Class?
    The Data class determines in which tablespace the table is stored when it
    is created in the database.

What is a Size Category?
    The Size category describes the probable space requirement of the table
    in the database.

How Many types of size categories and data classes are there?
    There are five size categories (0-4) and 11 data classes, only three of
    which  are appropriate for application tables:

            - APPL0 - Master data (data frequently accessed but rarely updated)
            - APPL1 - Transaction data (data that is changed frequnetly)
            - APPL2 - Organisational data (customizing data that is entered when system is
                                                            configured and then rarely changed)


 What are control tables?
    The values specified for the size category and data class are mapped to
    database-specific values via control tables.

 What is the function of the transport system and workbench organiser?
    The function of the transport system and the Workbench Organizer is to
    manage any changes made to objects of the ABAP/4 Development Workbench
    and to transport these changes between different SAP systems.

 What is a table pool?
    A table pool (or pool) is used to combine several logical tables in the
    ABAP/4 Dictionary. The definition of a pool consists of at least two key
    fields and a long argument field (VARDATA).

 What are pooled tables?
    These are logical tables which must be assigned to a table pool when they
    are defined. Pooled tables can be used to store control data (such as
    screen sequences or program parameters).

  What is a table cluster?
     A table cluster combines several logical tables in the ABAP/4 Dictionary.
     Several logical rows from different cluster tables are brought together
     in a single physical record. The records from the cluster tables
     assigned to a cluster are thus stored in a single common table in the
     database.


 Which objects are independent transport objects?
      Domains, Data elements, Tables, Technical settings for tables,
      Secondary indexes for transparent tables,           Structures, Views,
      Matchcode objects, Matchcode IDs, Lock objects.

What are the Data types of the external layer?
ACCP, CHAR, CLNT, CUKY,CURR, DATS, DEC, FLTP, INT1,INT2, INT4, LANG, LCHR,LRAW, NUMC, PREC, QUAN,RAW ,TIMS, UNIT, VARC.

 What are the Data types of the ABAP/4 layer?
      Possible ABAP/4 data types:
      C: Character.
      D: Date, format YYYYMMDD.
      F: Floating-point number in DOUBLE PRECISION (8 bytes).
      I: Integer.
      N: Numerical character string of arbitrary length.
      P: Amount or counter field (packed; implementation depends on hardware
          platform).
      S: Time stamp YYYYMMDDHHMMSS.
      T: Time of day HHMMSS.
      V: Character string of variable length, length is given in the first
         two bytes.
      X: Hexadecimal (binary) storage.

How can we set the tablespaces and extent sizes ?
You can specify the extent sizes and the tablespace (physical storage
        area in the database) in which a transparent table is to be stored by
        setting the size category and data class.

What is a data dictionary ?
Data dictionary is a central source of data in a data management system. Its main function is to support the .It has details about
            - What data is contained ?
            - What are the attributes of the data ?
            - What is the relationship existing between the various data elements ?

What functions does a data dictionary perform ?
       In a  data management system, the principal functions performed by the  data dictionary are
            - Management of data definitions
            - Provision of information for evaluation
            - Support for software development
            - Support for documentation
            - Ensuring that the data definitions are flexible and up-to-date.

A field containing currency amounts (data type CURR)  must be assigned to a reference table and a reference field. Explain.
As a reference table, a system table containing all the valid currencies is assigned or any other table which contains a field with the currency key format. This field is called as reference field.
The assignment of the field containing currency amounts to the reference field is made at runtime.  The value in the reference field determines the currency of the amount.

What is the significance of Technical settings (specified while creating a table in the data dictionary) ?
By specifying technical settings we can control how database tables are created in the database.
The technical settings allows us to
            - optimize storage space requiremnets
            - table access behaviour
            - buffering required
            - changes to entries logged

What is the significance of Delivery Class ?
- The delivery class controls the degree to which the SAP or the customer is    responsible  for table maintenance
            - whether SAP provides the table with or without contents.
            - determines the table type.
-  determines how the table behaves when it is first installed, at upgrade, when it is transported, and when a client copy is performed.


What is the maximum number of structures that can be included in a table or structure
            - Nine (9).


What are the two methods of modifying Sap standard tables?
            - Append Structures and
            - Customizing Includes.

What is the difference between a Substructure and an Append Structure?
- In case of a substructure, the reference originates in the table itself, in the forma of a statement. Include....
·         In case of an append structure, the table itself remains unchanged and the reference originates in the append structure.

What are the two ways for restricting the value range for a domain?
            - By specifying fixed values.
            - By stipulating a value table.

What is a Match Code?
 Match Code is a tool to help us to search for data records in the system. Match codes are an efficient and user-friendly search aid where key of a record is unknown.

What are the two levels in defining a Match Code?
            - Match Code object
            - Match Code Id.

What is the maximum number of match code Id's that can be defined for one Match code object?
            - 36. A match code Id is a one character ID that can be a letter or a number.

Can we define our own Match Code ID's for SAP Match codes?
Yes, the numbers 0 to 9 are reserved for us to create our own Match Code IDs for a SAP defined Match code object.

What is an Update type with reference to a Match code ID?
If the data in one of the base tables of a match code ID changes, the match code data has to be updated. The update type stipulates when the match code is to be updated and how it is to be done. The update type also specifies which method is to be used for Building match codes. You must specify the update type when you define a match code ID.

What are conversion routines?
·         Non-standard conversions from display format to sap internal format and vice-versa are implemented with so called conversion routines.

Aggregated Objects
Views, match codes, and lock objects are also called aggregate objects because they are formed from several related tables.

What is a View?
- A view is a logical view on one or more tables. A view on one or more tables i.e., the data from a view is not actually physically stored instead being derived from one or more tables. A view can be used to summarize data, which is distributed among several tables.

How many types of Views are there?
·         Database View   (SE11)

Database views are implement an inner join, that is, only records of the primary table (selected via the join operation) for which the corresponding records of the secondary tables also exist are fetched. Inconsistencies between primary and secondary table could, therefore, lead to a reduced selection set.
In database views, the join conditions can be formulated using equality relationships between any base fields. In the other types of view, they must be taken from existing foreign keys. That is, tables can only be collected in a maintenance or help view if they are linked to one another via foreign keys.

·         Help View    (SE54)

Help views are used to output additional information when the online help system is called.
When the F4 button is pressed for a screen field, a check is first made on whether a match code is defined for this field. If this is not the case, the help view is displayed in which the check table of the field is the primary table. Thus, for each table no more than one help view can be created, that is, a table can only be primary table in at most one help view.

·         Projection View

Projection views are used to suppress or mask certain fields in a table (projection), thus minimizing the number of interfaces. This means that only the data that is actually required is exchanged when the database is accessed.
A projection view can draw upon only one table. Selection conditions cannot be specified for projection views.

·         Maintenance View   (SE54)

      Maintenance views enable a business-oriented approach to looking at data, while at   
      The same time, making it possible to maintain the data involved. Data from several 
      Tables can be summarized in a maintenance view and maintained collectively via this
      View. That is, the data is entered via the view and then distributed to the underlying
      Tables by the system.

What is Locking?
·         When two users simultaneously attempt to access the same data record, this is synchronized by a lock mechanism.

When dialog transactions are programmed, locks are set and released by calling certain function modules. These function modules are generated automatically from the definition of so-called lock objects in the ABAP/4 Dictionary.
To synchronize the access to a table by setting and removing locks, a Lock object has to be defined in the ABAP/4 Dictionary. Activating the lock object automatically creates function modules for setting and removing locks. These function modules must be included when programming interactive transactions.

Lock Mechanism :

To set locks, a lock object must be defined in the ABAP/4 Dictionary. In this lock object, those tables in which data records are to be locked by calling a lock are determined. All tables included in a lock object must be connected to each other via foreign keys. The key fields of the tables in a lock object form the Lock arguments for the tables. The lock arguments are the basis for formulating the logical condition for identifying the records to be locked.

When activating this lock object, two function modulesB with the names ENQUEUE_<Object_name> and DEQUEUE_<Object_name> are generated.

Example:

Problem:

You wish to prevent a user from being able to change the name of a course or the name of the professor with responsibility for the course at a time when another user is editing the course description (which contains this information).




Solution:

The problem described above can be solved by defining a lock object E_UKURS. This is done by defining primary and secondary tables in the lock object. Table UKURS is check table of table UKRSB, so UKURS should be selected as primary table and UKRSB as secondary table of the lock object.
The Lock argument in this case is the field combination FABNR, KRSNR, and SPRAS (i.e Primary Key Combination).
The Lock mode Shared is to be selected here. This allows several users to access the        data simultaneously in display mode.
The lock mode in the generated function modules for setting (ENQUEUE_E_UKURS) and releasing (DEQUEUE_E_UKURS) locks is therefore set to shared as default, but can be overridden by calling the function modules.

If the function module ENQUEUE_E_UKURS is called with FABNR = '1' and KRSNR = '3', the record for course 3 in faculty 1 is locked in table UKURS. Furthermore, all the course descriptions for this course are locked in table UKRSB since field SPRAS was not specified when the function module was called. In such cases, the lock is made generically for a field which is not defined.
If the function module DEQUEUE_E_UKURS is now called with FABNR = '1', KRSNR = '3' and SPRAS = 'D', the German course description is unlocked. All other course descriptions remain locked.


What is database utility ?
·         Database utility is the interface between the ABAP/4 Dictionary and the underlying the SAP system.

The database utility is the interface between the ABAP/4 Dictionary and the relational database underlying the SAP system. You can call the database utility from the initial screen of the ABAP/4 Dictionary with Utilities ® Database utility.
The database utility allows you to create, delete and convert objects from the ABAP/4 Dictionary in the database.