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: 

How To Clear Repeated Value from Final Internal Table and display data in ALV report.

lfumakiya
Explorer
0 Kudos
818

Dear Team

I need help clearing Plant, Product Code, Product Description, Base Qty, and UOM filed repeated value in the ALV report. required output in the following format in ALV.

I use the below logic to achieve this type of output in ALV.

  loop at itab into data(wa_tab).    " Final Table For ALV
CLEAR : w_flag , lv_matnr.
at new matnr.
w_flag = abap_true.
lv_matnr = wa_tab-matnr.
endat.
IF w_flag ne abap_true .
CLEAR : wa_tab-werks,wa_tab-matnr,wa_tab-maktx,wa_tab-bmeng,wa_tab-bmein.
MODIFY itab FROM wa_tab TRANSPORTING werks matnr maktx bmeng bmein.
ENDIF.
CLEAR : wa_tab.
endloop.
  try .
call method cl_salv_table=>factory
importing
r_salv_table = lr_alv
changing
t_table = itab.
catch cx_salv_msg .
endtry.
 lr_alv->display( ).

but I did not get the correct output as per requirement I get the output as per below.

7 REPLIES 7

raymond_giuseppi
Active Contributor
628

Don't clear the fields in the internal table, just define those fields as sort criteria and ALV will hide duplicates.

(Also in your code clearing the field will trigger at new on next record)

0 Kudos
628

Dear Raymond Giuseppi

Actually, initially, I did this it displayed okay in ALV, but when we exported this data into a Spreadsheet(.xlsx) file the data was exported as usual.

0 Kudos
628

Not sure that possible in ALV export to Excel, you may be required to code your own download with OLE2 or Abap2XLSX.

0 Kudos
628

lfumakiya Remember to provide all the important information in the initial question, instead of adding supplementary questions each time there is a good answer.

628

Qustion could have been 'How To Clear merged duplicate values when exporting from ALV report to Excel'

amirbarzegar
Explorer
0 Kudos
628

delete adjanced duplicates from itab comparing Plant, Product Code, Product Description, Base Qty and fields you need to delete duplicates

0 Kudos
628

Dear Amir Barzegar

I have performed the task you requested, but I only retrieved two records with different materials. This report comprises both header and item data. The fields mentioned above contain header data, while the remaining fields contain item-level data. For example, the first four columns represent Bill of Materials (BOM) materials header data, while the other columns represent their corresponding component data.