Friday, 13 March 2015

                                                  ABAP Dictionary

ABAP Dictionary: is a central repository where we can create the objects. And manage data definitions (metadata). The objects are
1. Database Tables.
2. Views.
3. Data Type [data element, structure, Table type].
4. Type Group.
5. Domains.
6. Search help.

7. Lock Objects.





1. Database Tables:
It is an object which stores the data in the form of rows & columns. Each row is called record.  Each column is called as field.
Key field:
A field which is used to identify the records uniquely is called a key field. We can create number of key fields. In table there should be at least one key field.
Primary key rules:
Each table should have primary key. It should be a data type char.
It should appear as the first field.
Foreign key table:
A table which is linked with check table for validating its own data is called foreign key table.
Foreign key relationship:
The relationship between the two tables for validating the data is called foreign key relation.
Check table:
A table which stores master data is called check table.
Field level.
Foreign key is not automatic, that means we must enter check table name.
Value table:
All the table fields will referring to the domain wiil be checked with single table called as value table.
Domain level.
Foreign key is automatic, once we maintain the value table FK relation will be automatically displayed.
Components in a table:
Delivery class:
The type of data that stored in a table.
A – Application table.
C- Customizing table.
L- Delivery table.
G, E, S, W – system data.
Display maintaince allowed:
1. Display maintaince allowed.
2. Display maintaince not allowed.
3. Display maintaince allowed with restrictions.
Data class:
Physical area of inside the database.
Size category:
It specifies maximum number of records that can be stored.
Table components:
a.       Delivery class & Display maintance
b.      Fields [field domain & key].
c.       Technical settings [data class & size category].
Buffer / Cache memory:
Used to increase the system performance.
System program table->cache buffer->database.
Buffering Options:
1. Buffering not allowed.
2. Buffering allowed but not switched off [SAP]
3. Buffering switched on [data stored in buffer].
 By default: Buffering not allowed.
Buffering types:
Single record buffer
Fully buffered.
Generic area.
Client dependent table:
If the first field is MANDT then it is called as client dependent table. This table stores the data in specific clients only.
Client independent table:
If the first field is not MANDT then it is called as client independent table. This table stores the data  in all clients without security.
Structures in abap:
Include structure:
Used only with custom tables.
Reusability.
Just give field as .include.
Maximum 9 structures that can be included in table or structure.
Append structure:
Used only with standard  tables.
Not Reusability.
Click on Append structure to create structure & add to table.
Composite primary key:
More than one key field.
RDMS: Relational Database management system to link the database tables & fields.
Transparent tables:
Physical table where we can store the data physically.
Pool & clustered tables:
Logical tables, they can be created more than one transparent tables.
POOL – linear search.   E.g. Bseg table.
CLUSTER – binary search E.g. Vseg table.

Transparent                                       Pool                                    Cluster
Contains single table             large number of tables                large number of tables
it has a one-to-one relation   many-to-one                                many-to-one
secondary index can be created  can't                                      can't                               

SAP data can be divided into three types
1.      Customizing data.
2.      Master data
3.      Transaction data.

APPLO [master data] data which is seldomly changed.
APPL1 [transactional data] data which is frequently changed.
APPL2 [organizational data] Customizing data defined & seldomly changed.

Permanent data is called master data.
Day to day business data is called transaction data.

Table Maintaince generator [SM30]:

It is a standard SAP program created in the form of function module to maintain bulk amount of data for every record.
The main purpose of the table maintenance generator is to Create/Change/Delete the table entries without writing any code. Whenever we create table maintenance generator it will generate a standard program.Another important thing is whenever u change Ur table structure (Include/delete fields) don't forget to delete and recreate the table maintenance. Because the structure of the table was changed. If u try access Table maintenance generator (SM30) after changing the structure then it will through u a dump.

Creating & Display records:
Utilities-->Table contents-->Create or display

Adding deleting the fields in a table:
SE14-->tablename-->clickedit-->click on activate&adjust database.


Single step: Only overview screen is created

Two step: Two screens namely the overview screen and Single screen are created.
Some times we want to validate the data by using writing programming logic. In such case we use events in TMG & validate the data.
39 events are available.
EVENTS:

Open the table-> click on utilities->select TMG-> click on environment -> modifications->events->click on new entries->click help->39 events will be displayed. 

Primary Index:            
1. Contains only key fields of the table.                     
2. Automatically created when
The table is created in the database.

  Secondary Index:
1. Also contains non-key fields.     
2. Created by the user.
Secondary Index is also helpful in reducing the load on the Database.

An index can be used to speed up the selection of data records from a table.  Performance is also increased.

Log data changes: DBTALOG

SELECT: It retrive the data from database table.


2. Views:A view is a logical view on one or more tables.
To place master data and transactional data at one place we need to crate a view(Views are created with required fields from different tables).
a. Projection view: Just retrieves some fields from a single table.
b. Help view: This is used for search help.
c. Database view: This is inner join view of one or more tables.
d. Maintaince view: We can maintain the data. Maintaince view are used by SAP for internal purpose only.

3. Data Type:

a. Data element:
It is a user defined elementary data type which specifies semantic information such as field description, documentation [F1], Search help [F4]. In dictionary: Table fields, structure fields.
In programetically using as structure, internal table.

b. Structure:
It is user defined structure data type. It can be used for following purpose. In dictionary .include.
Programetically using as structure, internal table.

c. Table type:
It is equal to user defined structure data type which can be used to declare the internal table without header line.

4. Type groups
Type groups are used for creating customer-defined data types. The main purpose is efficiency of coding time. They are defined with the keyword TYPE-POOL followed by the name of the type group. Type-group or Type pool is a collection of Data types and Constants which can be called globally from any program. If you want to define global constants, you have to use a type group.

E.G. There are several type groups available in SAP. For example ‘ABAP’ and ’SLIS’ etc. To use them in program we use key word ‘TYPE-POOLS’.

5. Domain:
Which specifies technical information such as data type & length. It also specify sign, lower case, fixed values, value table. Two ways for restricting the value range for a domain.
By specifying fixed values.

By stipulating a value table.

Two ways for restricting the value range for domain.
BY Specifing fixed values.
by stipulating a value table.

Conversion routines/exits:
Conversions from display format to sap internal format.
Conversion_Exit_Alpha   :input-->external->internal.
Conversion_Exit_Alpha   :output-->internal->external.



6.Search Help - It helps to define the standard input help process. There are two types of search help - Elementary search help and Collective search help. Creating a basic search help which allows you to provide the user with a selection help to select specific fields from a table or view is very straight forward.

1. Elementary search helps create a single search path for providing the possible entries (F4).
2. Collective search helps combines several elementary search helps. Hence, it provides more than one alternative search paths for possible entries. 


   Q. What is hot key for search help?
    A. The hot key permits the user to select elementary search help from the collective
          search help directly in the input field with the short notation using either letters or digits.

Using transaction code SE11 you can create search help. This search help has to be assigned to the field for which this input help is required. There are four ways you can assign the search help -

     1. By attaching the search help to a data element
     2. By attaching the search help to a check table
     3. By attaching the search help to a table field
     4. By attaching the search help to a screen field

Scenario-1: In case if more than one search help is assigned to the field the conflicts in calling the search help is resolved by the hierarchy of search help. So when a input help is called for the field, first it checks if the search help is attached on the screen field or not. Here it also a case if there is a program help written with PROCESS ON VALUE-REQUEST or not else it looks for the search help attached to the screen field. If no serach help available here then it looks for the input help attahed using FIELD SELECT or FIELD VALUES.

Scenario-2: If the above first level if the field could not able to find the input help then it further looks for the search help defined to the tabel field.

Scenario-3: If no search help define here, it tries to call the search help define at a check table. If at check table it finds the search help then it displays else it displays the key values of the check tables.

Scenario-4: Still there is no search help is define at the above level the system looks for the search help define at the data element. If still the search help is not define at data element, the fixed values of domain are displayed.

7. Lock objects
Lock objects are use in SAP to avoid the inconsistency at the time of data is being insert/change into database.
SAP Provide three type of Lock objects. 
- Read Lock (Shared Locked) E
   protects read access to an object. The read lock allows other transactions read access but not write access to the locked area of the table
- Write Lock (exclusive lock) S
   protects write access to an object. The write lock allows other transactions neither read nor write access to the locked area of the table.
- Enhanced write lock (exclusive lock without cumulating) X
  works like a write lock except that the enhanced write lock also protects from further accesses from the same transaction.
Use: 
You can see in almost all transaction when you are open an object in Change mode SAP could not allow to any other user to open the same object in change mode.
Example: in HR when we are enter a personal number in master data maintenance screen SAP can't allow to any other user to use same personal number for changes.
Technically:


When you create a lock object System automatically create two function module.
1. ENQUEUE_. To insert the object in a queue.
2. DEQUEUE_. To remove the object is being queued through above FM.






TECHNICALLY


Creating Lock Object and Using Lock in Program


Step 1. Go to TCODE-SE11, Provide the lock object name and Click on Create Button.

Step 2. Provide the Short text and click on the Tables Tab.


Step 3. Provide the table name and Select the Lock mode as Write Lock and Click on the Lock Parameter Tab.



Step 4. All the primary key fields of the given table are added under the Lock parameter section.
Activate the Lock Object.


Step 5. When the lock object is activated it creates two function modules 'Enqueue & Dequeue'.
Navigate along the below shown path to get the generated function modules.


Step 6. 



Step 7. Let's use the generated function module in a program .
Go to TCODE- SE38, provide a report program name and click on create button.


Step 8. Call the Enqueue Function Module to lock the Single record.

Step 9. In the program PF Status Create the Application tool bar button as shown below.

Step 10. Activate the report. Open two different session at a time and run the same report.

Step 11. Provide the CARRID as 'AA' in both sessions.

Step 12. Run the first session and we have the out put. Execute the same report in second session,
 now we have the error message given below as the same record is locked in first session.

Step 13. Now again run the same report in two different sessions and provide different inputs and execute it.

Step 14. Now no error message is there.

Step 15. Now again run the same report in two different session and provide the same input.
Run the program in first session.

Step 16. Now the record is locked. Now Unlock the Record By clicking on the Application toolbar button that is created in the program PF Status. Now run the Report in the Second session.



Step 17. The same record is shown in the second session without error.

Creating a Basic SAP Search Help and explanation as what each option is for

Step1 - Create Search help
Execute transaction SE11 and create a new search help called 'ZSHELP'.

Step2 - Enter basic details 
Enter a short description and PA0002 into the selection method field, this is basically the table the search help gets it data from


Step3 - Enter search help parameters
the next step is to add the fields that are going to be used by this search help as parameters.

Step6 - Add selection options
Now enter 1 and 2 against parameters NCHMC and VNAME within the SPos column.
Now if you save, activate and test the search help again you will see that you have the 2 parameters available on the search help to further restrict the value list. You may need to expand the view using the little arrow to see this additional options. 

Step7 - Change Dialog behaviour
Just to demonstrate what this option does, ensuring you still have values within the SPos column change the dialog behaviour from 'Display values immediately' to 'Dialog with value restriction' 




Now when you test it you should notice that the parameter restriction fields are display before you see the value results list. You could also add defaults to these fields using the default column. This option may be usful if the search help returns lots of values as it gives the user an option to restrict further before the data is retrieved and displayed. 
Step 8 - Assign matchcode to report parameter
If you have created your search help to be matchcode compatible (i.e. less than 5 chars long) you can add the following line of ABAP code into your program:

PARAMETER p_prog LIKE trdir-name MATCHCODE OBJECT zsh. 





Important tables to store the definations of DDIC:
Table                               SHORT TEXT
DDO2L                           SAP TABLES
DDO2T                           SAP TABLES TEXTS
DDO1L                           DOMAINS
DDO1T                           DOMAIN TEXTS
DDO3L                           TABLE FIELDS
DDO3T                           TABLE FIELDS TEXTS
DDO4L                           DATA ELEMENTS
DDO4T                           DATA ELEMENTS  TEXTS
DDO5S                            FORIEGN KEY FIELDS
TADIR                            PROGRAMS
TDVEC                           DEVELOPMENT CLASS



Can we use all views in the abap program?
No, We can use only projection view, database view.


Lock objects are used to set the locks on the same data when multiple users acess the same data at the same time.

There are 3 types
1. Exclusive locks: the data can be read or processed locked by one user only.
2. Shared lock: several users can read the same data at the same time.
3. Exclusive but not cumulative: can only requested once by a given transaction or user.
Whenever we create lock object, there are 2 types of functions will be generated. There are ENQUEUE, DEQUEUE.


LUW: Logical unit of work
The span of time during which any database updates must be performed.
Types of LUW:
1.       Database LUW: SAP system triggers database commits automatically at every screen change which is called as database LUW.


2.       SAP LUW: is a group of several database LUW.






No comments:

Post a Comment