cancel
Showing results for 
Search instead for 
Did you mean: 

Select into specified fields

Former Member
0 Kudos
18,428

In the select statement, how can I specify fields of an internal table which I want to be filled from a database table? Is it possible to define in INTO clause that I want db_field1 to be copied into itab_field3?

View Entire Topic
Former Member
0 Kudos

... INTO (f1, ..., fn)

Places the result set in the target area (f1, ..., fn). The fields of the result set are transported to the target fields fi from left to right. INTO (f1, ..., fn) is allowed only if a list with n elements is also specified in the SELECT clause.

If the result of a selection is a table, the data is retrieved in a processing loop introduced by SELECT and concluded by ENDSELECT. The processing passes through the loop once for each line read. If the result is a single record, the closing ENDSELECT is omitted.

Example

Output a list of all airlines (with short description and name):

TABLES SCARR.

DATA: CARRID LIKE SCARR-CARRID,

CARRNAME LIKE SCARR-CARRNAME,

SELECT CARRID CARRNAME

INTO (CARRID, CARRNAME)

FROM SCARR.

WRITE: / CARRID, CARRNAME.

ENDSELECT

If u have defined an internal tabel and in select query u r retrieving a few fields then use INTO CORRESPONDING FIELDS OF..

DATA: Begin of tab occurs 0,

matnr like mara-matnr,

maktl like mara maktl,

end of tab.

select matnr from

mara <b>into corresponding fields of table tab</b>

where matnr IN s_matnr.

Try this one.

Message was edited by: Judith Jessie Selvi

Former Member
0 Kudos

The database table and internal table are not the same.

Select - Endselect is a fine solution. Thanks.