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

Problem with SELECT using FOR ALL ENTRIES

VijayaKrishnaG
Active Contributor
0 Likes
4,554

Hello Experts, Good Day.

I am facing problem with SELECT statement when I am using FOR ALL ENTRIES.

When I am using FOR ALL ENTRIES IN <tab> WHERE <field> = <tab-field> some entries are not getting fetched from the database. That time if I am using Select-Option like appending required conditions into Select option and using normal SELECT statement with WHERE <field> IN <s_option> then all the required entries are getting captured.

SELECT VBELN MBDAT MATNR WERKS LFIMG VRKME VGBEL FROM LIPS

     INTO CORRESPONDING FIELDS OF TABLE IT_LIPS

     FOR ALL ENTRIES IN IT_LIKP

     WHERE VBELN = IT_LIKP-VBELN

          AND WERKS EQ P_WERKS.

The above select query missing some entries from database. But if am using as below, I am getting all the entries.

LOOP AT IT_LIKP INTO WA_LIKP.

     S_VBELN-SIGN = 'I'.

     S_VBELN-OPTION = 'EQ'.

     S_VBELN-LOW = WA_LIKP-VBELN.

     APPEND S_VBELN.

     CLEAR S_VBELN.

   ENDLOOP.

   SELECT VBELN MBDAT MATNR WERKS LFIMG VRKME VGBEL

                  FROM LIPS

                  INTO CORRESPONDING FIELDS OF TABLE IT_LIPS

*                 FOR ALL ENTRIES IN IT_LIKP

                  WHERE VBELN IN S_VBELN

*                 WHERE VBELN = IT_LIKP-VBELN

                  AND   WERKS EQ WERKS.

1 ACCEPTED SOLUTION
Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,718

The FOR ALL ENTRIES will remove duplicate results, if you do not provide the full primary key, some identical records may (and will) be removed. So add POSNR in the result of the SELECT statement.

NB: You could also get back to the LIKP select and try a JOIN with LIPS in case of performance problem : Remenber FOR ALL ENTRIES get bad performance for big set of data when IN RANGE option often get dumps in the same case...

Regards,

Raymond

4 REPLIES 4
Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,719

The FOR ALL ENTRIES will remove duplicate results, if you do not provide the full primary key, some identical records may (and will) be removed. So add POSNR in the result of the SELECT statement.

NB: You could also get back to the LIKP select and try a JOIN with LIPS in case of performance problem : Remenber FOR ALL ENTRIES get bad performance for big set of data when IN RANGE option often get dumps in the same case...

Regards,

Raymond

Read only

1,718

Hi Raymond,

Thanks for the explanation and additional information provided.

Vijay

Read only

Mohamed_Mukhtar
Active Contributor
0 Likes
1,718

Hello Vijay,

Add POSNR in your select query and check.


SELECT VBELN

             POSNR " Add posnr

MBDAT MATNR WERKS LFIMG VRKME VGBEL FROM LIPS

     INTO CORRESPONDING FIELDS OF TABLE IT_LIPS

     FOR ALL ENTRIES IN IT_LIKP

     WHERE VBELN = IT_LIKP-VBELN

          AND WERKS EQ P_WERKS.

Thanks

Read only

Former Member
0 Likes
1,718

Hi,

You are trying to fetch delivery items(LIPS) but you havent included item no(POSNR).

Please pass POSNR then let us know.

Regards,

Vadamalai A