sapdev logo background
sapdev logo sapdev logo
Comments

SELECT directly into an internal table when field order is different




The select command is the most fundamental function of writing ABAP programs allowing the retrieval of data from SAP database tables. The most efficient use of the select statement is to retrieve data directly into an internal table, Below is an example of how this would be performed.


REPORT  ZSELECTCOMMAND.
*Code to demonstrate select into internal table command
data: it_ekko type STANDARD TABLE OF ekko,
      wa_ekko like line of it_ekko,
      it_ekpo type standard table of ekpo,
      wa_ekpo like line of it_ekpo.

*Select directly into an internal table
* Please note the order of these field are not different but you can still see the code
* that would perform this functionality if they were!
SELECT *  "all fields
  FROM ekko
  INTO TABLE it_ekko.
write:/ 'SELECT directly into an internal table'.
loop at it_ekko into wa_ekko.
  write:/ wa_ekko-ebeln.
endloop.







comments powered by Disqus