02-06-2008 9:15 PM
Hi Everyone,
I get the data in my internal for all the fiscyear 2000 to 2005. and for thats its comp_code values etc.
I just want to display only distinct values for fiscyear 2000 to 2005 and also distinct comp_code values which belongs to these fiscyears.
How do I select from the internal table which get this data.
Please respond with some code samples.
Thanks,
Prashant.
02-06-2008 9:18 PM
you can use
SELECT DISTINCT
or
SELECT * from table ORDER BY
and then
DELETE ADJACENT DUPLICATES
02-06-2008 9:18 PM
you can use
SELECT DISTINCT
or
SELECT * from table ORDER BY
and then
DELETE ADJACENT DUPLICATES
02-06-2008 9:21 PM
Will select work for an internal table itab.
I tried but did not work.
02-06-2008 9:23 PM
For DELETE ADJACENT DUPLICATES you have to sort first..
SORT ITAB BY fiscal_year comp_code..
DELETE ADJACENT DUPLICATES FROM ITAB COMPARING fiscal_year comp_code.
02-06-2008 9:40 PM
It worked
itab_temp[] = g_t_data[].
delete adjacent duplicates from itab_temp comparing fiscyear comp_code.
But then now how do I display it, willthis work.
LOOP AT g_t_data INTO g_s_data.
WRITE: /(10) g_s_data-fiscyear,
(12) g_s_data-comp_code,
02-06-2008 9:51 PM
send the data back after deleteing..
itab_temp[ ] = g_t_data[ ].
delete adjacent duplicates from itab_temp comparing fiscyear comp_code.
g_t_data[ ] = itab_temp []
LOOP AT g_t_data INTO g_s_data.
WRITE: /(10) g_s_data-fiscyear,
(12) g_s_data-comp_code..
award points if helpful
02-06-2008 10:00 PM
08-12-2019 9:29 AM
I know this is quiet old, but my two cents nontheless:
How can this work for a internal table? Using SELECT works on real tables AFAIK.
08-12-2019 10:06 AM
IF cl_abap_dbfeatures=>use_features( EXPORTING requested_features = VALUE #(
( cl_abap_dbfeatures=>ITABS_IN_FROM_CLAUSE ) ) ).
SELECT ... FROM @itab ...
ENDIF.
02-06-2008 9:21 PM
itab_temp[ ] = itab [ ].
delete adjacent duplicates from itab_temp.
or
delete adjacent duplicates from itab_temp comparing fscyr comp_code.
02-06-2008 9:36 PM
itab_temp[ ] = g_t_data[ ].
delete adjacent duplicates from itab_temp comparing fiscyear comp_code.
For my internal table it throws up the erro saying :
Statement "ITAB_TEMP[" is not defined. Check your spelling.
In the beginning i have defined it as itab_temp LIKE g_t_data, but still the same error comes up.
02-06-2008 9:21 PM
Use ..
SELECT DISTINCT <cols> ... WHERE ...
If you do not use DISTINCT (<lines> is then empty), the system reads all of the lines that satisfy the WHERE condition. If you use DISTINCT, the system excludes duplicate entries
Duplicate entries in the result set are automatically deleted.
Eg..
TABLES SPFLI.
DATA TARGET LIKE SPFLI-CITYTO.
SELECT DISTINCT CITYTO
INTO TARGET FROM SPFLI
WHERE
CARRID = 'LH ' AND
CITYFROM = 'FRANKFURT'.
WRITE: / TARGET.
ENDSELECT.
.
Also check this link.
http://help.sap.com/saphelp_nw2004s/helpdata/en/fc/eb3990358411d1829f0000e829fbfe/content.htm