Building An SAP Query Using ABAP Code
Building An SAP Query Using ABAP Code
There are 4 different ways to write SAP queries – depending on the approach of data retrieval strategy:
Here in this document, we’ll demonstrate building SAP query using 2 nd method (Direct read of table).
Press enter.
Press enter.
3. Press ‘Code’.
TYPE-POOLS: slis.
TABLES: scarr.
* Type for taking data from tables SFLIGHT and SCARR
TYPES: BEGIN OF ty_flight,
carrid TYPE s_carr_id,
connid TYPE s_conn_id,
fldate TYPE s_date,
seatsmax TYPE s_seatsmax,
seatsocc TYPE s_seatsocc,
carrname TYPE s_carrname,
currcode TYPE s_currcode,
END OF ty_flight.
* Internal table and work area declaration
DATA: wa_flight TYPE ty_flight,
i_flight TYPE STANDARD TABLE OF ty_flight INITIAL SIZE 0,
i_fldcat TYPE slis_t_fieldcat_alv,
wa_fldcat TYPE slis_fieldcat_alv.
Save it.
The following selection screen will appear where we need to put the flight date.
Enter the flight date as 11.06.2008 and execute the query; we’ll get the following ALV grid display report.