Application Development 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: 

Select query without distinct bugs, duplicate data removed

xiswanto
Active Participant
0 Kudos

Hello,

I was wondering If such case ever happened for others.

So in my Production server, I am using this syntax below, but it cause weird bugs, where there should be 5 lines of data ( where 3 lines have batch A, and 2 lines have batch B ), but somehow, it remove the duplicate row, so my data only consist of 2 row ( 1 line of batch A, 1 line of batch B ), as if there is hidden DISTINCT word.

Based on my debug analysis, all 5 rows are in same TANUM, same NLPLA, and also the VISTM or NISTM has value. When I tried on SE16N, it fetch 5 rows of data correctly.

Might there be some hidden query configuration or report configuration?

DATA : li_group TYPE TABLE OF gt_group.

SELECT a~matnr a~werks a~charg a~meins a~nistm
      a~lgnum a~tanum
      FROM ltap AS a
      INTO CORRESPONDING FIELDS OF TABLE li_group
      FOR ALL ENTRIES IN gi_ltak
      WHERE a~lgnum = gi_ltak-lgnum AND
            a~tanum = gi_ltak-tanum AND
            a~nltyp = '200' AND
            a~nlpla = p_sammg AND
            ( ( a~vistm <> 0 ) OR ( a~nistm <> 0 ) ).

But in my newest select query, it show the correct rows too.

SELECT lgnum tanum tapos matnr werks charg meins nistm
      FROM ltap
      INTO CORRESPONDING FIELDS OF TABLE li_group
      FOR ALL ENTRIES IN gi_ltak
      WHERE lgnum = gi_ltak-lgnum
        AND tanum = gi_ltak-tanum
        AND nltyp = '200'
        AND nlpla = p_sammg
        AND nistm GT 0.

Might it actually caused by the WHERE ( ( vistm <> 0 ) OR ( nistm <> 0 ) ) condition? I felt like the where condition should be true though.

1 ACCEPTED SOLUTION

raymond_giuseppi
Active Contributor

Basically FOR ALL ENTRIES will remove duplicates entries from the result set.

  • To keep every record you could add the primary keys to the SELECT clause (as you did in the second try, field TAPOS was added) so add TAPOS in your first SELECT
2 REPLIES 2

raymond_giuseppi
Active Contributor

Basically FOR ALL ENTRIES will remove duplicates entries from the result set.

  • To keep every record you could add the primary keys to the SELECT clause (as you did in the second try, field TAPOS was added) so add TAPOS in your first SELECT

0 Kudos

Huh, I never thought it would affect that way, since I don't use the TAPOS field, thats why. thanks anyway.