SAP LOOP STEP EXAMPLES ABEXA



Get Example source ABAP code based on a different SAP table
  



ABAP_ITAB - STEP Examples
The example demonstrates different usages of the addition STEP.

ABAP_SOURCE_CODE
DEMO CL_DEMO_STEP_EXAMPLES

ABAP_DESCRIPTION
The table customer_purchases stores customer data and purchased item data. There are four methods which show the use of STEP in different contexts.
Method purchase_order Looping across the lines of the internal table customer_purchases with LOOP and with STEP -1, indicating a backward loop, to get all purchase orders of a specific customer from the newest to the oldest date.
Method quarterly_order Looping across the lines of the internal table customer_purchases with FOR and STEP -1, indicating a backward loop, within a specific time period from the newest to the oldest date.
Method discount Looping across the lines of the internal table customer_purchases with FOR and STEP -1 as for method quarterly_order . Inserting lines of the internal table orders when constructing the internal table discount_candidates with the additions FROM 3 and STEP 3 to get every third line starting from the third line.
Method tombola Looping across the lines of the internal table customer_purchases with STEP 2 to get every second line and grouping the lines with the group key cust_id. Inserting the lines of the internal table win_candidates into the internal table customer_benefit with STEP 2 to get every second table line.