FETCH is a keyword used in SAP ABAP programming.
This tutorial covers its introduction & syntax details.
FETCH NEXT CURSOR c target.
Uses the cursor c to read
the next line or lines from the dataset of a database table determined by OPEN
CURSOR . The cursor must be a variable of the type CURSOR and must be explicitly
opened with OPEN CURSOR . To specify the target area into which you read the
selected data, use INTO clause target .
FETCH belongs to the Open SQL
After each execution of the FETCH statement, the system
field SY-DBCNT contains the number of lines read so far.
The return code
value is set as follows:
SY-SUBRC = 0 At least one line was
SY_SUBRC = 4 No line was read.
Output the passenger
list for the Lufthansa flight 0400 on 28-02.1995:
DATA C TYPE CURSOR,
WA LIKE SBOOK.
OPEN CURSOR C FOR SELECT *
CARRID = ‘LH ‘ AND
CONNID = ‘0400’ AND
ORDER BY PRIMARY KEY.
FETCH NEXT CURSOR C INTO
IF SY-SUBRC <> 0.
CLOSE CURSOR C. EXIT.
WA-BOOKID, WA-CUSTOMID, WA-CUSTTYPE,