![]() In ABAP 7.4, if you want to use field symbols for the work area, then the syntax is shown below… READ TABLE lt_mara WITH KEY matnr = lv_matnr ASSIGNING FIELD-SYMBOL(). In the same way that you no longer need DATA declarations for table work areas, you also no longer need FIELD-SYMBOL declarations for the (common) situations in which you want to change the data in the work area while looping through an internal table. #INTERNAL NBTEXPLORER FOR ITEMS CODE#Take a gander at the code below… READ TABLE lt_mara WITH KEY matnr = lv_matnr INTO DATA(ls_mara). It is exactly the same for the work areas, which are of course structures. We learned that from 7.4 onward you no longer need to do a DATA declaration for elementary data types. In release ABAP 7.4, the syntax for reading into a work area and looping through a table can now leverage INLINE DECLARATIONS, we discussed these in a prior ABAP 7.4 blog. The code would look something like the below… READ TABLE it_mara INTO wa_mara WITH KEY sort_key COMPONENTS bismt = lv_bismt.Įven though IT_MARA is a HASHED table, it is also a SORTED table with the key BISMT, so when we go looking for the record using BISMT a BINARY SEARCH is automatically performed. #INTERNAL NBTEXPLORER FOR ITEMS FULL#Check out the help for a full list, but we will look at the READ TABLE statement here. The SAP Help states that statements that previously only accessed the primary key have been enhanced so that access to secondary keys is now possible. WITH NON-UNIQUE SORTED KEY sort_key COMPONENTS bismt. The internal table definition could be as shown below. But, on the other hand, secondary keys also incur additional administration costs due to memory consumption and run-time.įor example, lets create a secondary index into the internal table IT_MARA for the column BISMT, this is just like having a secondary Z- index on BISMT in the database table definition. The SAP Help states that using the secondary key could increases read access performance significantly. Well now as of ABAP 7.2 can declare secondary keys for internal tables. OK, back to internal tables, traditionally, if you wanted to read an internal table in two different ways (e.g.,looking for a material by Material Number or by Reference Number), then you either had to keep sorting the table just before a read, or have two identical tables sorted differently. Why do we create a custom index or z-index? For performance… we recognize that a table could be queried in more ways then just by the primary key, so we setup customer indexes that we believe will be used by the Database Optimizer when determining the access path and thus make the query performant. Using Secondary Keys to Access Internal Tables in ABAP 7.4Īll of us who have been developing in ABAP at one time or another have created a custom index on a database table. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |