2008 May 16 5:02 AM
hi
can any one tell me how to delete duplicate raw from alv report program .
Regards
rakesh
hi
can any one tell me how to delete duplicate raw from alv report program .
Regards
rakesh
2008 May 16 5:04 AM
Sort using the key fields.
and delete adjacent duplicates comparing the required fields
2008 May 16 5:05 AM
2008 May 16 5:11 AM
hi rakesh!!!
For proper flow and syntax check wid the example given in the below link:
http://sap.niraj.tripod.com/id64.html
hope it helps.
kindly rewrd.
2008 May 16 5:17 AM
Hi
First you have to sort you ITAB.
Sort itab by <Field name)
DELETE ADJACENT DUPLICATES FROM ITAB.
Thanks and Regards
Arun Joseph
2008 May 16 5:05 AM
Hi
Use the Statement
Delete adjacent duplicates
Sample Code.
DATA: BEGIN OF connection,
cityfrom TYPE spfli-cityfrom,
cityto TYPE spfli-cityto,
distid TYPE spfli-distid,
distance TYPE spfli-distance,
END OF connection.
DATA connection_tab LIKE SORTED TABLE OF connection
WITH NON-UNIQUE KEY cityfrom cityto
distid distance.
SELECT cityfrom cityto distid distance
FROM spfli
INTO TABLE connection_tab.
DELETE ADJACENT DUPLICATES FROM connection_tab.
Reward If Helpfull,
Naresh.
2008 May 16 5:16 AM
hi
the code is very helpful . I am attaching the code plz
tell me where to change the code .
&----
*& Report ZTAX_REPORT
*&
&----
*&
*&
&----
REPORT ZTAX_REPORT.
tables: bseg,rbkp.
type-pools: slis.
types: begin of ty_tab,
belnr type bseg-belnr,
gjahr type bseg-gjahr,
mwskz type bseg-mwskz,
buzid type bseg-buzid,
text1 type t007s-text1,
dmbtr type bseg-dmbtr,
hkont type bseg-hkont,
ebeln type bseg-ebeln,
ebelp type bseg-ebelp,
matnr type bseg-matnr,
maktx type makt-maktx,
name1 type lfa1-name1,
lifnr type lfa1-lifnr,
noninvat type bseg-dmbtr,
werks type mseg-werks,
awkey type bkpf-awkey,
budat type bkpf-budat,
totamt type bseg-dmbtr,
invamt type bseg-dmbtr,
taxamt type bseg-dmbtr,
end of ty_tab.
data: begin of it_tab1 occurs 0,
belnr type bkpf-belnr,
gjahr type bkpf-gjahr,
end of it_tab1.
data: begin of it_invoice occurs 0,
belnr type rbkp-belnr,
gjahr type rbkp-gjahr,
budat type rbkp-budat,
awkey type bkpf-awkey,
end of it_invoice.
data: it_tab type table of ty_tab with header line,
it_final type table of ty_tab with header line,
wa_tab type ty_tab.
data: fieldcatalog type slis_t_fieldcat_alv with header line,
gd_layout type slis_layout_alv,
gd_repid like sy-repid.
data: tmp_dmbtr type bseg-dmbtr.
select-options: s_mwskz for bseg-mwskz obligatory no intervals,
s_werks for bseg-werks,
s_budat for rbkp-budat obligatory.
select belnr gjahr budat into corresponding fields of table it_invoice
from rbkp where budat in s_budat.
loop at it_invoice.
concatenate it_invoice-belnr it_invoice-gjahr into it_invoice-awkey.
modify it_invoice.
clear it_invoice.
endloop.
select belnr gjahr into corresponding fields of table it_tab1 from bkpf
for all entries in it_invoice where awkey eq it_invoice-awkey.
select belnr gjahr mwskz buzid dmbtr matnr werks ebeln ebelp into corresponding
fields of it_tab from bseg for all entries in it_tab1
where belnr = it_tab1-belnr and
gjahr = it_tab1-gjahr and
mwskz in s_mwskz and
werks in s_werks.
collect it_tab.
endselect.
sort it_tab by belnr gjahr.
*loop at it_tab.
wa_tab = it_tab.
collect it_tab.
*endloop.
loop at it_tab.
if it_tab-buzid = 'W'.
select * from bseg where belnr = it_tab-belnr and
gjahr = it_tab-gjahr and
mwskz in s_mwskz and
hkont in ('0020800514','0020800515' ,'0020800516') and
werks in s_werks.
tmp_dmbtr = tmp_dmbtr + bseg-dmbtr.
clear bseg.
endselect.
it_tab-noninvat = tmp_dmbtr.
clear tmp_dmbtr.
endif.
if it_tab-buzid = 'W'.
it_tab-invamt = it_tab-dmbtr.
elseif it_tab-buzid = 'T'.
it_tab-taxamt = it_tab-dmbtr.
endif.
select single budat awkey from bkpf into (it_tab-budat, it_tab-awkey) where belnr = it_tab-belnr and gjahr = it_tab-gjahr.
it_tab-belnr = it_tab-awkey.
select single lifnr from ekko into it_tab-lifnr where ebeln = it_tab-ebeln.
select single text1 from t007s into it_tab-text1 where spras = sy-langu and
kalsm = 'TAXINN' and
mwskz = it_tab-mwskz.
select single maktx from makt into it_tab-maktx where matnr = it_tab-matnr.
select single name1 from lfa1 into it_tab-name1 where lifnr = it_tab-lifnr.
if it_tab-hkont = '0020800514' or it_tab-hkont = '0020800515' or it_tab-hkont = '0020800516'.
it_tab-noninvat = it_tab-noninvat + it_tab-dmbtr.
endif.
modify it_tab.
clear it_tab.
endloop.
loop at it_tab.
if ( it_tab-buzid eq 'W' ). " changes on 15/05/2008 " or it_tab-buzid eq 'P'
read table it_tab with key belnr = it_tab-belnr gjahr = it_tab-gjahr mwskz = it_tab-mwskz buzid = 'T' into wa_tab.
it_tab-totamt = it_tab-dmbtr + wa_tab-dmbtr.
it_tab-taxamt = wa_tab-taxamt.
delete it_tab where belnr = wa_tab-belnr and gjahr = wa_tab-gjahr and mwskz = wa_tab-mwskz and buzid = 'T'.
clear wa_tab.
endif.
modify it_tab.
endloop.
fieldcatalog-fieldname = 'MWSKZ'.
fieldcatalog-seltext_m = 'Tax Code'.
fieldcatalog-col_pos = 1.
fieldcatalog-emphasize = 'C100'.
fieldcatalog-fix_column = 'X'.
append fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'TEXT1'.
fieldcatalog-seltext_m = 'Desc. of Tax Code'.
fieldcatalog-col_pos = 2.
fieldcatalog-emphasize = 'C100'.
fieldcatalog-fix_column = 'X'.
append fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'BELNR'.
fieldcatalog-seltext_m = 'Invoice Number'.
fieldcatalog-col_pos = 3.
fieldcatalog-emphasize = 'C100'.
fieldcatalog-fix_column = 'X'.
append fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'GJAHR'.
fieldcatalog-seltext_m = 'Invoice Year'.
fieldcatalog-col_pos = 4.
append fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'BUDAT'.
fieldcatalog-seltext_m = 'Invoice Posting Date'.
fieldcatalog-col_pos = 4.
append fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'WERKS'.
fieldcatalog-seltext_m = 'Plant'.
fieldcatalog-col_pos = 4.
append fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'LIFNR'.
fieldcatalog-seltext_m = 'Vendor No.'.
fieldcatalog-col_pos = 4.
append fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'NAME1'.
fieldcatalog-seltext_m = 'Vendor Name'.
fieldcatalog-col_pos = 4.
append fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MATNR'.
fieldcatalog-seltext_m = 'Material No.'.
fieldcatalog-col_pos = 4.
append fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MAKTX'.
fieldcatalog-seltext_m = 'Material Desc.'.
fieldcatalog-col_pos = 4.
append fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'TOTAMT'.
fieldcatalog-seltext_m = 'Total Amount'.
fieldcatalog-col_pos = 4.
append fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'INVAMT'.
fieldcatalog-seltext_m = 'Inventorized Amount'.
fieldcatalog-col_pos = 4.
append fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'TAXAMT'.
fieldcatalog-seltext_m = 'Total non inventorized tax'.
fieldcatalog-col_pos = 4.
append fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'NONINVAT'.
fieldcatalog-seltext_m = 'Non inventorized VAT'.
fieldcatalog-col_pos = 4.
append fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'EBELN'.
fieldcatalog-seltext_m = 'PO Number'.
fieldcatalog-col_pos = 4.
append fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'EBELP'.
fieldcatalog-seltext_m = 'PO Item No'.
fieldcatalog-col_pos = 4.
append fieldcatalog.
clear fieldcatalog.
gd_layout-zebra = 'X'.
gd_layout-colwidth_optimize = 'X'.
gd_layout-info_fieldname = 'COLOR'.
gd_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = gd_repid
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
I_CALLBACK_TOP_OF_PAGE = ' '
i_callback_top_of_page = 'TOP-OF-PAGE'
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE =
I_GRID_SETTINGS =
IS_LAYOUT = gd_layout
IT_FIELDCAT = fieldcatalog[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'A'
I_SAVE = 'A'
IS_VARIANT =
IT_EVENTS =
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
I_HTML_HEIGHT_TOP = 0
I_HTML_HEIGHT_END = 0
IT_ALV_GRAPHICS =
IT_HYPERLINK =
IT_ADD_FIELDCAT =
IT_EXCEPT_QINFO =
IR_SALV_FULLSCREEN_ADAPTER =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = it_tab
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
2008 May 16 5:05 AM
2008 May 16 5:06 AM
Hi,
Passing internal table to ALV function module before that sort that internal table and delete adjecent duplicates from that internal table.
Regards,
Narasimh
2008 May 16 5:16 AM
Hi,
SORT i_tab BY key_field.
DELETE ADJACENT DUPLICATES FROM i_tab.
Reward if helpful,
Regards,
Esha Raj