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

Before FOR ALL ENTRIES remove duplicate values.

Former Member
0 Likes
3,807

Hi In code inspector i am getting messgae that before for all entries remove duplicate values.

How can I do the same for following code?


 SELECT prctr FROM marc INTO TABLE gt_marc
          FOR ALL ENTRIES IN gt_ekpo
          WHERE werks EQ gt_ekpo-werks
          AND matnr EQ gt_ekpo-matnr
          AND prctr IN s_prctr.

    SELECT pspnr FROM prps
           INTO TABLE gt_prps
           FOR ALL ENTRIES IN gt_ekpo
           WHERE werks EQ gt_ekpo-werks
           AND matnr EQ gt_ekpo-matnr
           AND pspnr IN s_pspnr.

    SELECT pstrm
           eetrm
           FROM prte INTO TABLE gt_prte
           FOR ALL ENTRIES IN gt_prps
           WHERE posnr EQ gt_prps-pspnr
           AND pstrm IN s_pstrm
           AND eetrm IN s_eetrm.

6 REPLIES 6
Read only

Former Member
0 Likes
1,733

Hi oorvi,

Before using the table gt_ekpo, (For all entries in gt_ekpo), you can use the statement "DELETE ADJACENT DUPLICATES" on the table gt_ekpo, BY COMPARING the key fields. This will delete the duplicate entries of table gt_ekpo. This will improve the performance of the corresponding select statements.

Best Regards,

Ram.

Read only

former_member404244
Active Contributor
0 Likes
1,733

Hi,

Try like this ,


sort gt_ekpo by matnr 
delete adjacent duplicates from table gt_ekpo.

sort gt_prps by  pspnr
delete adjacent duplicates from table gt_prps.

Now use for all entries

Regards,

Nagaraj

Read only

Former Member
0 Likes
1,733

{

{color:blue}

hi friend


sort gt_ekpo by matnr werks ascending.
delete adjacent duplicates from gt_ekpo comparing matnr werks.

after that following ur code.

regards

surender

Read only

venkat_o
Active Contributor
0 Likes
1,733

Before you use FOR ALL ENTRIES statement, you must two things. <li>Check whether FOR ALL ENTRIES table has values or not . If you do not check, and it does not have values, it gives dump. <li>Sort the internal tables before use <li>You need to check Whether it has duplicate entries. <li>Try the below way to use .

DELETE ADJACENT DUPLICATES FROM gt_ekpo.
IF gt_ekpo[] IS NOT INITIAL.
  SELECT prctr FROM marc INTO TABLE gt_marc
           FOR ALL ENTRIES IN gt_ekpo
           WHERE werks EQ gt_ekpo-werks
           AND matnr EQ gt_ekpo-matnr
           AND prctr IN s_prctr.
ENDIF.
DELETE ADJACENT DUPLICATES FROM gt_ekpo.
IF gt_ekpo[] IS NOT INITIAL.
  SELECT pspnr FROM prps
         INTO TABLE gt_prps
         FOR ALL ENTRIES IN gt_ekpo
         WHERE werks EQ gt_ekpo-werks
         AND matnr EQ gt_ekpo-matnr
         AND pspnr IN s_pspnr.
ENDIF.
IF gt_prps[] IS NOT INITIAL.
  SELECT pstrm
         eetrm
         FROM prte INTO TABLE gt_prte
         FOR ALL ENTRIES IN gt_prps
         WHERE posnr EQ gt_prps-pspnr
         AND pstrm IN s_pstrm
         AND eetrm IN s_eetrm.
ENDIF.
Thanks Venkat.O

Read only

Former Member
0 Likes
1,733

Hi Friend ,

given below is the important point that we need to take care before using for all entries

1. Sort the table using the key field


SORT LT_BSIS BY BUKRS GJAHR BELNR. all are key field 

2. delete the dublicate entries


 DELETE ADJACENT DUPLICATES FROM LT_KUNNR COMPARING KUNNR. kunnr is the key field

3. Before using internal table with the table inwhich you have a data

check is initial or not

if initial that false

else true


IF NOT LT_BSIS IS INITIAL.

4. try to use all tha key field in for all entries if not using than pass all the key field is initial



C_AUGDT       LIKE BSIS-AUGDT  VALUE IS INITIAL,
pass in code
BSIS GE C_AUGDT

Thanks

Arun

Read only

Former Member
0 Likes
1,733

Hi,

This is very simple before using any table as for all enteries,sort the same and use delete adjacenbt duplicate comparing the key fields.

eg:

sort gt_ekpo by werks matnr.
delete adjacent duplicate comparing werks.

same for gt_prps as well.

This will definetly solve your problem.

Pooja