2007 May 18 6:29 AM
Hi friends,
In ABAP/4 , we heard so many times words like KEY and INDEX.
I want know exact difference Bt them while using ,
i expect answer with example ,
Regards,
Bhaskar
2007 May 18 6:38 AM
Hi,
Key is nothing but Primary key (primary index) /secondary key(secondary index) .
primary key in the table remains unique thruout the data base table.
wenevr u check primary key while creating a dbtable , the system internaly will create aprimary index for that primary key. i.e Pkey and Pindex are one and same.
secondary key is craeted to improve teh performance of select statements.
suppose if there is a situation where we r writing select statement in which in where condition we are considering non primary key, then secondarindex(key will be craeted ) to that field in the db table and this will improve performance.
Revert back if nay issues.
reward with points if helpful.
Regards ,
Naveen
Hi friends,
In ABAP/4 , we heard so many times words like KEY and INDEX.
I want know exact difference Bt them while using ,
i expect answer with example ,
Regards,
Bhaskar
2007 May 18 6:35 AM
Hi
In every programming Language there will be some Key words like them
we can't use them in our general coding as they are reserved.
There is a table in SAP for all these key words,
Check the table <b>TRESE</b>
You can't declare a field in the table with this key word. try and see using them you will get some error.
Reward points if useful
Regards
Anji
2007 May 18 6:37 AM
Hi bhaskar,
1. IN DB terminology,
KEY - key fields of a DB table. lets say table t001 which has key bukrs, that means only one entry will be present of each bukrs.
INDEX - it is the nothing but the index on DB which SAP internally uses to retrive the data from table when a query is fired on that table. Generally all tables have default index on there key fields.
You can check any DB table and click on indexes button to see index assigned to it.
Regards,
Atish
2007 May 18 6:39 AM
And the other diffence is in the programming,
KEY is nothing but the key fields of the internal table which you are using while reading that table. you can see the help on key word READ.
INDEX is nothing but the index of the entry during loop, do statements.
Regards,
Atish
2007 May 18 6:38 AM
Hi,
Key is nothing but Primary key (primary index) /secondary key(secondary index) .
primary key in the table remains unique thruout the data base table.
wenevr u check primary key while creating a dbtable , the system internaly will create aprimary index for that primary key. i.e Pkey and Pindex are one and same.
secondary key is craeted to improve teh performance of select statements.
suppose if there is a situation where we r writing select statement in which in where condition we are considering non primary key, then secondarindex(key will be craeted ) to that field in the db table and this will improve performance.
Revert back if nay issues.
reward with points if helpful.
Regards ,
Naveen
2007 May 18 6:39 AM
Hi,
The Key Field function cannot be used for the Field string table object, since the field string only consists of one entry (for example, the Personal Features (PERM) field string in cluster object Rx (for example, RD, RU)).
The system distinguishes between secondary, account-based and document-based indexes:
Secondary indexes contain information on G/L, customer and vendor accounts that is used when displaying line items.
Account type archive indexes contain similar data as found in secondary indexes, though less comprehensive. They contain the information you need to be able to access documents by account.
Document type archive indexes are a direct link between a given document and its data stored in the archive. They enable you to access the archive directly, for example to display the document. This function also applies to displaying G/L, customer and vendor account line items.
The secondary index life and the archive index life determine whether and for how long an index for a document (based on the posting date and index removal program key date) should remain in the system following archiving. If the index life is longer than the account or document life, a document can be archived and deleted from the database while the information stored in the secondary index remains in the system.
****do reward if usefull
vijay
2007 May 18 6:40 AM
hi
good
1-Primary key
Each SAP DB table has a primary key. The primary key is either defined by the database user or generated internally. A user-defined primary key can consist of multiple columns.
2-Index
You can create an index (also called a secondary key) to make it quicker to find data records in a table. An index is a database object that can be defined for an individual column or a series of columns in a database table. An index consists of one or more inversion lists.
An index name must be unique when combined with the table name. When defining an index, you determine whether the column values of different rows in the indexed columns have to be unique or not.
thanks
mrutyun^
2007 May 18 6:40 AM
Hi,
Using KEY
Key is to specify the exact record in the internal table like where condition in select statement.
e.g.
CLEAR wa_iflot.
READ TABLE git_iflot
INTO wa_iflot
WITH KEY tplnr = <Value want to compare>
BINARY SEARCH.
Here line of internal table git_iflot read based on the value of tplnr.
Using INDEX
Index is to directly aceess that line of the internal table.
e.g.
CLEAR wa_iflot.
READ TABLE git_iflot
INTO wa_iflot
WITH INDEX 2.
in above example it will directly read the line at index 2 in internal table
Regards,
Ranjit Thakur.
<b>Please Mark The Helpful Answer.</b>
2007 May 18 6:52 AM
Hi Bhskar,
There is no difference between key and index. Both are same. We call primary index or primary key and secondary index or secondary key..
Regards,
Kumar.
2007 May 18 7:00 AM
hi,
key always refer to key field which ha unique value..Primary key.
index : it points to a perticular row..and it helps in fetching data fastly...
Reward with points if helpful.