0% found this document useful (0 votes)
76 views2 pages

Select Into Corresponding Fields - Select Statements Types - Sapnuts

This document discusses the SELECT FOR ALL ENTRIES statement in ABAP for reading data from multiple database tables. It allows selecting data from a second table for all entries in a first table, reducing database load compared to a JOIN. The parent internal table must not be empty and should have duplicate entries removed. An example demonstrates using SELECT FOR ALL ENTRIES to get material descriptions from the MAKT table for all materials in a filtered MARA table.

Uploaded by

Deepak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
76 views2 pages

Select Into Corresponding Fields - Select Statements Types - Sapnuts

This document discusses the SELECT FOR ALL ENTRIES statement in ABAP for reading data from multiple database tables. It allows selecting data from a second table for all entries in a first table, reducing database load compared to a JOIN. The parent internal table must not be empty and should have duplicate entries removed. An example demonstrates using SELECT FOR ALL ENTRIES to get material descriptions from the MAKT table for all materials in a filtered MARA table.

Uploaded by

Deepak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Select for all entries in SAP ABAP - Select Statements types | Sapnuts.com about:reader?url=https://www.sapnuts.com/courses/core-abap/select-sta...

sapnuts.com

Select for all entries in SAP ABAP -


Select Statements types | Sapnuts.com
Ashok Kumar Reddy

SELECT FOR ALL ENTRIES is the best alternative for SELECT


WITH JOINS, this statement is very helpful for reading data from
more than 2 tables.The load on database will be very less.
Syntax :

SELECT <FIELDS> FROM <DBTABLE1> INTO TABLE <ITAB1>


WHERE <CONDITION>.
SELECT <FIELDS> FROM <DBTABLE2> INTO <ITAB2> FOR
ALL ENTRIES IN <ITAB1>
WHERE <FIELD1> = <ITAB1>-FIELD1.
**HERE WE ARE READING DATA 2 DATABASE TABLES, SEE
WHERE CONDITIONS OF SECOND SELECT STATEMENT

Ensure before using SELECT FOR ALL ENTRIES

Parent internal table must not be empty ( If it is empty, where


condition fails and it will get all records from database).

Remove all duplicate entries in parent internal table.

Here is the example of using SELECT FOR ALL ENTRIES in


real-time applications

**DATA DECLERATIONS

DATA : IT_MARA TYPE TABLE OF MARA.

DATA : IT_MAKT TYPE TABLE OF MAKT .

**GET DATA FROM MARA TABLE

SELECT * FROM MARA INTO TABLE IT_MARA

WHERE MATNR = '0001'.

**SORT MARA TABLE, TO DELETE ADJACENT DUPLICATES THE TABLE MUST BE SORTED IN ASCENDI

SORT IT_MARA ASCENDING .

**DELETE ADJACENT DUPLICATES FROM IT_MARA COMPARING ALL FIELDS

DELETE ADJACENT DUPLICATES FROM IT_MARA COMPARING ALL FIELDS.

1 of 2 8/24/2016 2:59 AM
Select for all entries in SAP ABAP - Select Statements types | Sapnuts.com about:reader?url=https://www.sapnuts.com/courses/core-abap/select-sta...

**TO USE SELECT FOR ALL ENTRIES, THE PARENT INTERNAL TABLE MUST NOT BE EMPTY SO CHEC

IF IT_MARA IS NOT INITIAL. "CHECK PARENT INTERNAL TABLE

**SECOND SELECT STATEMENT TO GET DATA FROM MAKT (MATERIAL DESCRIPTIONS), HERE WE ARE

**FROM MAKT FOR ALL THE RECORDS IN IT_MARA, SEE WHERE CONDITION SHOULD BE PARENT INT

SELECT * FROM MAKT INTO TABLE IT_MAKT

FOR ALL ENTRIES IN IT_MARA

WHERE MATNR = IT_MARA-MATNR.

ENDIF.

Related Lessons

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


this lesson helpful

2 of 2 8/24/2016 2:59 AM

You might also like