![]() Simulate Shipment Cost (VT02N) – Using Function Mo.Troubleshooting ABAP Dumps in relation to SAP HANA.FOR expression in ABAP 7.40 – Best case scenarios.Continuous Integration in ABAP using Jenkins.The performance of open SQL as in ABAP 7.52.ABAP Code Vulnerabilities, a call for real-time se.LET base = VALUE ty_struct2( field3 = 10 ) "display( lt_target3 ). *Populate any value or call custom method in the additional fields within the for loopĭATA(lt_target3) = VALUE gtt_struct2( FOR lwa_source IN lt_source IN ( CORRESPONDING #( BASE ( base ) lwa_source ) ) ). LET base = VALUE ty_struct2( field3 = index ) *Populate sy-tabix in the additional fields within the for loopĭATA(lt_target2) = VALUE gtt_struct2( FOR lwa_source IN lt_source * Initialize source table with some random valuesĭATA(lt_target1) = VALUE gtt_struct2( FOR lwa_source IN lt_source ( CORRESPONDING #( lwa_source ) ) ). ![]() Gtt_struct2 TYPE STANDARD TABLE OF ty_struct2 WITH DEFAULT KEY. TYPES: gtt_struct1 TYPE STANDARD TABLE OF ty_struct1 WITH DEFAULT KEY, Situation 1: To move values from a source internal table to a target internal table which has all the fields of source internal table + some additional fields ( say ). I feel this is one of the best addition among the new features. The main idea is to write code easily, keep it lean and compact as much as possible.īut there is no end of debate that if the old school abap code is good enough to achieve everything then why complicate life ?Well with all that being said let us discuss about some simple best case scenarios of FOR expression which can seriously reduce no of lines of code and make it more compact. For the new or the experienced abap-ers this is almost like fall in line or fall apart. Or you can do it in one statement: APPEND VALUE (. ![]() ![]() You can then use that field symbol to fill the table entry using the same VALUE construct you are using now. Read about more such ABAP expressions and exciting new syntaxes: ABAP Expressions (7.As we all know, the In-line declarations, operators and expressions available in 7.4 SP02 onward are taking the abap world by storm for last few years. The index logic is pretty ugly, you can easily use the ASSIGNING addition to the APPEND command to get a field symbol to the newly added line. WRITE: / booking_gr_2->customid, booking_gr_2->size. GROUP BY ( customid = booking_gr-customid And unlike AT – you don’t need the fields used in combinations to be the first in the table structure.įor example, below will also work. So, by using LOOP AT… GROUP BY you can get rid of the AT statements, make the code cleaner. WRITE: / booking_gr_2->index LEFT-JUSTIFIED, LOOP AT bookings INTO DATA(booking_gr)ĪSCENDING REFERENCE INTO DATA(booking_gr_2). Here, you can get the index for the group and size of the group i.e. Note that a explicit reference is used to get the data. WITHOUT MEMBERS REFERENCE INTO DATA(booking_gr_2). WITHOUT MEMBERS – Get unique values without requirement to loop on group members. To loop on this you need to use LOOP AT GROUP.ġ. This creates a deep structure booking_gr which has fields from the group by clause (carrid, connid, fldate) and the table entries which match this combination. LOOP AT GROUP booking_gr ASSIGNING FIELD-SYMBOL(). Total_weight = total_weight + -luggweight.įor simplicity – let us look at the code without the write statements. LOOP AT GROUP booking_gr ASSIGNING FIELD-SYMBOL(). WRITE: / booking_gr-carrid, 9 booking_gr-connid, Advertisements WRITE: 'Carrier', 9 'Connection', 21 'Flight Date'. The same output can be achieved in ABAP 7.4 using the LOOP AT. Total_weight = total_weight + booking-luggweight. WRITE: /35 booking-customid, 50 booking-luggweight. WRITE: / booking-carrid, 9 booking-connid, The control goes into the AT… ENDAT blocks as per below table.įor example, to print sum of total luggage weight per CARRID, CONNID, FLDATE combination using AT statements would look like below.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |