SELECT APPENDING


Using SELECT APPENDING Query to directly append records to existing internal table


  • SELECT APPENDING query is used to append SELECT query result directly to some other internal table.
  • Below is the syntax for SELECT APPENDING
SELECT <FIELD1> <FIELD2>
 from <DATABASE_TABLE> 
 APPENDING TABLE <ITAB>
 WHERE <FIELD> = <COND_VALUE>.
Note: Where condition is optional in SELECT Query

Below is the complete example program, in the below program, we will use select appending to append records to same internal table.

TYPES: BEGIN OF ty_mara,
         matnr TYPE mara-matnr,
         mtart TYPE mara-mtart,
       END OF ty_mara.
DATA: it_mara TYPE TABLE OF ty_mara.
DATA: wa_mara TYPE ty_mara.
**Get first 10 records from MARA where MTART = FERT
SELECT matnr mtart
  FROM mara
  INTO TABLE it_mara
  UP TO 10 ROWS
  WHERE mtart = 'FERT'
  .
**Get 10 reords from MARA where MTART = HALB append them to same internal table
SELECT matnr mtart
  FROM mara
  APPENDING TABLE it_mara
  UP TO 10 ROWS
  WHERE mtart = 'HALB'.

LOOP AT it_mara INTO wa_mara.
  WRITE:/ wa_mara-matnr, wa_mara-mtart.
ENDLOOP.

Learner Questions

No Questions by learners, be first one to ask ..!!

    Please Sign in to ask a question


    Was this lesson helpful to you? Yes No 3 People out of 3 think this lesson helpful

    Lesson Navigation

    ←Previous Chapter
    Next Lesson → Selection Screen Design using SAP ABAP