‎2007 Oct 24 4:06 PM
Hi SDN,
I need to fetch just one field from a table into an internal table except that I only need unique values, not every occurance in the source table. So if the table has 100 records but the field has only four unique values, internal table would have only four records/rows.
Please help with declarations and Select code snippet.
Thanks.
Saf.
‎2007 Oct 24 4:17 PM
Hi,
Use distinct in select
DATA: wa TYPE spfli,
ftab TYPE TABLE OF STRING.
APPEND 'CITYFROM' TO ftab.
APPEND 'CITYTO' TO ftab.
SELECT DISTINCT (ftab)
FROM spfli
INTO CORRESPONDING FIELDS OF wa
WHERE
carrid = 'LH'.
WRITE: / wa-cityfrom, wa-cityto.
ENDSELECT.
a®
‎2007 Oct 24 4:17 PM
Hi,
Use distinct in select
DATA: wa TYPE spfli,
ftab TYPE TABLE OF STRING.
APPEND 'CITYFROM' TO ftab.
APPEND 'CITYTO' TO ftab.
SELECT DISTINCT (ftab)
FROM spfli
INTO CORRESPONDING FIELDS OF wa
WHERE
carrid = 'LH'.
WRITE: / wa-cityfrom, wa-cityto.
ENDSELECT.
a®
‎2007 Oct 24 4:20 PM
‎2007 Oct 24 4:38 PM
Thanks. Here is my problem with distinct.
data: begin of i_entity occurs 0,
entity like /bic/pzk_entity-/bic/zk_entity,
end of i_entity.
The following code generates a syntex error saying that /bic/zk_entity is unknown column and cannot determine this until run time.
select distinct(/bic/zk_entity)
from /bic/azpd_o6100
into corresponding fields of table i_entity
where /bic/ztimeper in r_period.
endselect.
‎2007 Oct 24 4:40 PM
Change select distinct(/bic/zk_entity) to
select distinct /bic/zk_entity
This should help.
ashish
‎2007 Oct 24 4:41 PM
Change select distinct(/bic/zk_entity) to
select distinct /bic/zk_entity
from /bic/azpd_o6100
into corresponding fields of table i_entity
where /bic/ztimeper in r_period.
Also as you are doing into table, you do not need ENDSELECT.
This should help.
ashish