4. Select Multiple Report (Basic)

REPORT Z_SELECT_MULTIPLE
*** Lets Read data from SAP Database in less than 8 lines
*** Declare a internal table named lt_address
*** Internal table is more like a "Structured Array List"
 DATA :ls_address TYPE adrc, " We will still use this to hold each line/record
       lt_address TYPE TABLE OF adrc. "Data Declaration this time - TABLE
*** We are reading multiple entries now instead of SINGLE and hence
*** The keyword "INTO TABLE"
 SELECT * FROM ADRC INTO TABLE lt_address
   WHERE city1 = 'Hamburg'. " Read from DB
*** Write Data to list.
*** Since we have multiple entries in internal table lt_address
*** We have to loop and then write each record.
 LOOP AT lt_address INTO ls_address. "More like FOR EACH Loop in C# & JAVA
 WRITE : / 'Street :',ls_address-STREET, " Finally Write to list output
           'City   :',ls_address-CITY1,
           'Zip Code :',ls_address-POST_CODE1.
 ENDLOOP. 

Output :

%d bloggers like this: