SELECT statement is used to get the data from database table. The simple and basic format of writing a select query is below
SELECT * FROM <table name>.
**statement**
ENDSELECT.
This statement retrieves all columns and all rows from the specified table. In ABAP, the data is placed into an internal table after retrieving from table, which will hold the data in run time.
This select statement will work like a loop statement. This will fetch 1 by 1 record and execute the statement. Check out a very simple example below:
Data : lwa_kna1 type kna1.
SELECT *
FROM KNA1 into lwa_kna1.
WRITE: / lwa_KNA1-KUNNR, lwa_KNA1-NAME1.
ENDSELECT.
So, here first the work area is declared with the same type of KNA1 table. Next in the SELECT statement, after retrieving every record, it is writing the output values from that work area and then proceeds further for the next data.
This way a SELECT....ENDSELECT works, similar to a LOOP ... ENDLOOP statement only.
0 comments:
Post a Comment