![]() ![]() If a table line is not found, the exception CX_SY_ITAB_LINE_NOT_FOUND is raised. The result of a table expression is a single table line. What if I told you that you would never have to use the statement READ TABLE again to get a line out of an internal table? LOOP AT lt_mara ASSIGNING FIELD-SYMBOL(). 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. 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. 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. I am open to discussion if there is any point which you find misinterpreted.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. Now should we completey ignore this statement? I believe, this statement comes in handy when we are dealing Non-standard internal tables where updating of table keys happens everytime internal table is appended. Which is why this statement takes longer processing time. Lastly, table keys and table indexes are updated.įirst three steps have no additional cost however updating table keys and indexes is costly operation.Content of each row is assigned to corresponding field.Data from source table is extracted sequentially, similar to Loop.According to the SAP, processing for this statement happens in these steps: Now, let’s see how is it that new feature is taking as double as processing time. WRITE : / 'Loop with Field assignments: ', lv_9. " Individual Field Assignment using Loop. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |