![]() ![]() Karl Kessler's contributions to this subject, e.g. Here people with more knowledge come into play. Nowadays the namings and environments have become more and more complex and I (as the ABAP language documentation writer) am far from having a synoptic view of this. ![]() Standalone SAP Basis systems (R/3 without application programs so to say) were more or less rare. In former times this was the so called SAP Basis as part of an R/3 System and you normally had to have access to such a system in order to work with ABAP. You need an AS ABAP and an underlying database to work in ABAP. ABAP is the programming language of the ABAP Application Server (AS ABAP) of SAP Netweaver. I just install a new JDK and I have all the new featuresĪBAP is not like Java. Itab TYPE SORTED TABLE OF line WITH UNIQUE KEY id.ĭATA(def) = VALUE line( id = 0 value = `not found` ).ĭATA(result) = VALUE #( itab DEFAULT def ). If a line is not found, the OPTIONAL addition returns an initiial line while the DEFAULT addition returns a given value, that can be specified as an expression, especially another table expression. Not everybody liked this behavior.Īs a workaround, you can place a table expression inside a VALUE or REF expression, that contains a OPTIONAL or DEFAULT addition. Up to now, an exception was raised anytime if a table line specified in the square brackets could not be found. Table expressions itab cannot support sy-subrc. Here, the filter table – that can be specified also as a functional method call – must have a sorted or a hashed key (primary or secondary) that is evaluated. WHERE cityfrom = cityfrom AND cityto = cityto ). In this variant, you compare the lines of one table with the contents of another table, the filter table, and you extract those lines, where at least one match is found (say hello to FOR ALL ENTRIES). Of course, you can achieve the same result by using a FOR inside a VALUE ror a REDUCE expression but FILTER allows you to write it shorter and it should be faster. You can also extract the lines that do not fulfill the WHERE condition by using an EXCEPT addition. ![]() WHERE carrid = CONV #( to_upper( carrid ) ) ANDĬityfrom = CONV #( to_upper( cityfrom ) ) ).Īs a prerequisite, the filtered table must have a sorted or a hash key (primary or secondary), that is evaluated behind WHERE. In this variant, you simply extrract the lines from an internal table into a tabular result, that fulfill a simple value condition. ![]() The new FILTER operator enables two kinds of filtering an internal table. and the grouping of internal tables, there are some other ABAP enhancements for internal tables in 7.40, SP08: FILTER expressions Since you make no write access that shouldn't be reflected in the original data source, there's no reason to copy every line in every loop step.Besides the already mentioned REDUCE operator, the conditional FOR and LINES OF inside VALUE & Co. ASSIGNING/REFERENCE INTO is likely to be faster than LOOP AT. It's of course slower, but probably you don't need to gain a few microseconds, and so I think it's the best solution (still my opinion). Moreover, there is no gain in performance compared to your classic loop.īack to your snippet with two FOR iterations, we can see that the goal is very clear compared to the classic loop (my opinion). You can immediately see that the code is much less legible than any of your two snippets. (you will use ranges-t_augru and ranges-t_vkorg instead of t_augru and t_vkorg in your code) Ranges2-t_vkorg = COND #( WHEN -name = c_vkorg NEXT ranges2-t_augru = COND #( WHEN -name = c_augru I agree with your observation about doubling the iterations, and to make it faster, I think the only solution is to use only one loop, considering that the internal table is not already sorted, which limits the possible solutions a lot, and I come to this solution: TYPES: tt_tvarvc TYPE STANDARD TABLE OF tvarvc WITH EMPTY KEY,ĬONSTANTS: c_augru TYPE tvarvc-name VALUE 'AUGRU',ĭATA(t_tvarvc) = VALUE tt_tvarvc( for i = 1 while i IN t_tvarvC My observation is that, by using LOOP AT and CASE statement combo, the number of iterations will be same as the number of entries in T_TVARVC.īut when using a FOR loop for each range table, T_TVARVC has to be traversed more times to reach the desired entry thus causing multiple iterations more than the first scenario.Ĭan this be written in a more efficient way? This is what I have come up with: DATA(t_augru) = VALUE tt_tvarvc( FOR s_tvarvc IN t_tvarvcĭATA(t_vkorg) = VALUE tt_tvarvc( FOR s_tvarvc IN t_tvarvc S_tvarvc_range = CORRESPONDING #( s_tvarvc ). I have used a select to get multiple tvarvc entries data into T_TVARVC. I am trying to write a for-loop statement for the following scenario: ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |