Open all | Close all


SELECT for all entries command


The select command is the most fundamental function of writing ABAP programs allowing the retrieval of
data from SAP database tables. Below is an examples of how to select data using the FOR ALL ENTRIES command. 

REPORT  ZSELECTCOMMAND.
*Select FOR ALL ENTRIES 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 *
  UP TO 100 ROWS  "only return first 100 hits
  FROM ekko
  INTO TABLE it_ekko
 where ebeln = '0000154421'.
loop at it_ekko into wa_ekko.
  write:/ wa_ekko-ebeln.
endloop.

IF sy-subrc EQ 0.
* The FOR ALL ENTRIES comand only retrieves data which matches
* entries within a particular internal table.
  SELECT *
    FROM ekpo
    INTO TABLE it_ekpo
    FOR ALL ENTRIES IN it_ekko
    WHERE ebeln EQ it_ekko-ebeln.
  write:/ 'FOR ALL ENTRIES comand '.
  loop at it_ekpo into wa_ekpo.
    write:/ wa_ekpo-ebeln, wa_ekpo-ebelp.
  endloop.
ENDIF.




 

 

Number of SAP Development Users currently online hit counters