Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

SELECT option question....

Former Member
0 Likes
556

Hi all,

What is the meaning of FOR ALL ENTRIES IN.. as in the code below: where can I find the documentation of FOR ALL?

Code:

SELECT * INTO CORRESPONDING FIELDS OF TABLE L_SPETAB

FROM VBAK

FOR ALL ENTRIES IN LVBUK

WHERE VBELN = LVBUK-VBELN

AND LIFSK IN LIFSPE

AND VKORG = VKORG

AND VTWEG IN VTWEG

AND SPART IN SPART.

What is the meaning of IN (as in the last line of code above)?

Thanks,

Charles.

1 ACCEPTED SOLUTION
Read only

ferry_lianto
Active Contributor
0 Likes
538

Hi,

From online help ...

http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3a1f358411d1829f0000e829fbfe/content.htm

Tabular Conditions:

The WHERE clause of the SELECT statement has a special variant that allows you to derive conditions from the lines and columns of an internal table:

SELECT ... FOR ALL ENTRIES IN <itab> WHERE <cond> ...

<cond> may be formulated as described above. If you specify a field of the internal table <itab> as an operand in a condition, you address all lines of the internal table. The comparison is then performed for each line of the internal table. For each line, the system selects the lines from the database table that satisfy the condition. The result set of the SELECT statement is the union of the individual selections for each line of the internal table. Duplicate lines are automatically eliminated from the result set. If <itab> is empty, the addition FOR ALL ENTRIES is disregarded, and all entries are read.

The internal table <itab> must have a structured line type, and each field that occurs in the condition <cond> must be compatible with the column of the database with which it is compared. Do not use the operators LIKE, BETWEEN, and IN in comparisons using internal table fields. You may not use the ORDER BY clause in the same SELECT statement.

You can use the option FOR ALL ENTRIES to replace nested select loops by operations on internal tables. This can significantly improve the performance for large sets of selected data.

Regards,

Ferry Lianto

4 REPLIES 4
Read only

naimesh_patel
Active Contributor
0 Likes
538

Hello...

FOR ALL ENTRIES IN LVBUK

... Query will select the records for all the VBELN in the table LVBUK...

IN ... for select-options

When you want to use the select options you have to use the IN operator to check against your select-options.

Regards,

Naimesh Patel

Read only

Former Member
0 Likes
538

Just put your cursor on WHERE in a SELECT statement and press F1. It will answer both questions.

Rob

Read only

ferry_lianto
Active Contributor
0 Likes
539

Hi,

From online help ...

http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3a1f358411d1829f0000e829fbfe/content.htm

Tabular Conditions:

The WHERE clause of the SELECT statement has a special variant that allows you to derive conditions from the lines and columns of an internal table:

SELECT ... FOR ALL ENTRIES IN <itab> WHERE <cond> ...

<cond> may be formulated as described above. If you specify a field of the internal table <itab> as an operand in a condition, you address all lines of the internal table. The comparison is then performed for each line of the internal table. For each line, the system selects the lines from the database table that satisfy the condition. The result set of the SELECT statement is the union of the individual selections for each line of the internal table. Duplicate lines are automatically eliminated from the result set. If <itab> is empty, the addition FOR ALL ENTRIES is disregarded, and all entries are read.

The internal table <itab> must have a structured line type, and each field that occurs in the condition <cond> must be compatible with the column of the database with which it is compared. Do not use the operators LIKE, BETWEEN, and IN in comparisons using internal table fields. You may not use the ORDER BY clause in the same SELECT statement.

You can use the option FOR ALL ENTRIES to replace nested select loops by operations on internal tables. This can significantly improve the performance for large sets of selected data.

Regards,

Ferry Lianto