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: 

ALV showing repetitive lines despite line items the same

siongchao_ng
Contributor
0 Kudos

Hi all,

I am required to sort and show 2 lines if the customer no, sales order no the same.

I used the  REUSE_ALV_GRID_DISPLAY FM for my ALV and have done the sorting.

Problem is despite having do the sorting for all the fields to be displayed in the ALV, the quantity field and amount fields still displayed for every line items despite the figures are the same.  I need to be able to show 2 lines only since there are 2 different document no but it is showing 20 lines or more currently.

Required displayed

Doc 1         SO                     Quantity      Amount

Doc 2         SO                     Quantity     Amount

Currently display

Doc 1         SO                    Quantity     Amount

                                           Quantity     Amount

                                            Quantity     Amount

Doc 2         SO                      Quantity     Amount

                                            Quantity      Amount

Anyone knows what's wrong?

  fkimg TYPE vbrp-fkimg, " Invoice Qty

  wrbtr TYPE bsis-wrbtr, " Amount in doc curr
  dmbtr TYPE bsis-dmbtr, " Amount in loc curr

1 ACCEPTED SOLUTION

Former Member
0 Kudos

hi

You can do this by the following below code

LOOP AT IT_FINAL INTO WA_FINAL.
AT END OF CONNID.
SUM.
WA_FINAL2-CARRID    = WA_FINAL-CARRID.
WA_FINAL2-CONNID    = WA_FINAL-CONNID.
*WA_FINAL2-FLDATE    = WA_FINAL-FLDATE.
WA_FINAL2-PRICE     = WA_FINAL-PRICE.
*WA_FINAL2-CITYFROM  = WA_FINAL-CITYFROM.
APPEND WA_FINAL2 TO IT_FINAL2.
CLEAR WA_FINAL2.
ENDAT.
ENDLOOP.

Reward if you find w8

Thanks & Regards

RKarmakar


9 REPLIES 9

sachin_khedkar
Explorer
0 Kudos

hi ,

change your loop statment instead of that try to use read syntax it will solve u r problem .

like ...

loop at internal table     " this should be your main internal table where all records are coming

now try to use "read statment " inside the loop

endloop.

please, post the code if possible .

Former Member
0 Kudos

Hi Siong Chao Ng,

the internal table you r passing to the function module REUSE_ALV_GRID_DISPLAY contains the repeated records in it..... first correct there and you'll get the desired output... and you may get confused but there'll be two internal tables in the function module 1. the internal table with the field names and 2. internal table with the data of the fields.

Pls check there and post the progress with your issue.

Thanks,

ENOCH.

Former Member
0 Kudos

Hi,

The data is correct but something is wrong with the loop. Paste your code here. By the way, have you connected both the loops with key <doc>?

Regards

Purnand

VijayCR
Active Contributor
0 Kudos

Hi Siong ,

     The sorting logic has to be corrected You may not be deleting the Repeated Entires.Do Proper looping based on the Keyfields.

Thanks,

Vijay.

Former Member
0 Kudos

This message was moderated.

Former Member
0 Kudos

hi

You can do this by the following below code

LOOP AT IT_FINAL INTO WA_FINAL.
AT END OF CONNID.
SUM.
WA_FINAL2-CARRID    = WA_FINAL-CARRID.
WA_FINAL2-CONNID    = WA_FINAL-CONNID.
*WA_FINAL2-FLDATE    = WA_FINAL-FLDATE.
WA_FINAL2-PRICE     = WA_FINAL-PRICE.
*WA_FINAL2-CITYFROM  = WA_FINAL-CITYFROM.
APPEND WA_FINAL2 TO IT_FINAL2.
CLEAR WA_FINAL2.
ENDAT.
ENDLOOP.

Reward if you find w8

Thanks & Regards

RKarmakar


0 Kudos

Hey Raju,

The quantity field and amount field can be summed up. (10 lines reduced to 1 line per doc no)

But all my other data for instance document date, doc type, reference no, sales doc, item no, broker no, terms of pymt, document currency etc fields all showing ************. I need to be able to display all these fields correctly as well.

In addition, what about those field that I do not want to be summed like exchange rate? I need to exclude fields I do not want to be summed.

0 Kudos

Hello Siong Chao Ng,

Use another workarea and move those work area fields into another one before the at new or at end statement.

Thanks,

Vijay.

Former Member
0 Kudos

Hi,

Plz before use the itab inside the FM 'REUSE ALV GRID_DISPLAY ' you have to  sort the itab

then used delete the duplicate records by using the syntax....

syntax:

delete adjacent duplicates from itab   comparing  all fields .

whichever field u want to take u can take as ur reqirment .

thanks & regards

suraj singh