2007 Jun 18 8:28 PM
Hi gurus!
I have the following code:
SELECT knumv kposn kschl lifnr kwert
FROM konv
INTO TABLE l_i_konv
FOR ALL ENTRIES IN l_i_dv_knumv
WHERE knumv = l_i_dv_knumv-table_line
AND kappl = 'M'.
The internal table l_i_konv was defined as following:
TYPES:
BEGIN OF ty_konv,
knumv TYPE knumv,
kposn TYPE kposn,
kschl TYPE kscha,
lifnr TYPE lifnr,
kwert TYPE kwert,
END OF ty_konv.
DATA: l_i_konv TYPE TABLE OF ty_konv.
When I execute this code 20 occurs is filled in my internal table. However if I select data by TC SE16 I obtain 21 records.
I have noticed the lost data is duplicated if I see by SE16, as following:
knumv kposn kschl lifnr kwert
1003450881 00010 YMFX 0100128136 318,18
1003450881 00010 YMFX 0100128136 318,18
My question is When I use the clause INTO TABLE does the system delete this kind of data like DELETE ADJACENT DUPLICATES FROM itab?
Thanks and regards,
Silvio Messias.
2007 Jun 18 8:36 PM
Hi Silvio,
It does delete duplicates when you use the "FOR ALL ENTRIES" clause, not "INTO TABLE" - this is your problem.
2007 Jun 18 8:36 PM
Check whether there are any duplicates in the table l_i_dv_knumv.
INTO TABLE does NOT do any delete adjacent duplicates.
For more perfect answer paste your code here.
Rds,
Naren
2007 Jun 18 8:36 PM
Hi Silvio,
It does delete duplicates when you use the "FOR ALL ENTRIES" clause, not "INTO TABLE" - this is your problem.
2007 Jun 18 8:38 PM
Hi,
loop at l_i_dv_knumv.
SELECT knumv kposn kschl lifnr kwert
FROM konv
appending table TABLE l_i_konv
WHERE knumv = l_i_dv_knumv-table_line
AND kappl = 'M'.
endloop.
If your l_i_dv_knumv < 500 use select inside loop. otherwise please don't use this. it has performance impact.
aRs
Message was edited by:
aRs
2007 Jun 18 8:45 PM
> Hi,
>
>
> loop at l_i_dv_knumv.
> SELECT knumv kposn kschl lifnr kwert
> FROM konv
> appending table TABLE l_i_konv
> WHERE knumv = l_i_dv_knumv-table_line
> AND kappl = 'M'.
> endloop.
>
> >
> aRs
This is not a good pratice because you will do lots of acces to the database server, and your programa performance will get worse.
You should avoid using select statements inside loops.
Regards
2007 Jun 18 8:40 PM
Hi Silvio,
"My question is When I use the clause INTO TABLE does the system delete this kind of data like DELETE ADJACENT DUPLICATES FROM itab?"
No it doesn't. If you are using a normal select statement it will select all data found.
The system will delete duplicate data when you use the clause "SELECT DISTINCT" or the adition "FOR ALL ENTRIES"
Reward points if helpful please.
Regards
2007 Jun 18 8:47 PM
Silvio,
Have you ever used a range?
You can set a range with your internal table values and declare your where clause as
WHERE <FIELD> IN <RANGE> .
I think this would solve your problem.
2007 Jun 18 10:52 PM
Hi Silvio,
I also faced the same problem long back, But I dont know the reson why its behaving like this.
Some times it will not fetch all the records, you can resolve this by specify all the key fields in select query and the target internal table.
2007 Jun 18 10:56 PM
Hi Silvo,
The reason for this is that you are not selecting all the key fields of the table KONV.
YOu should select all the Keu fields of the table KONV when you are using a for all entries statement.
SELECT knumv
kposn
<b>STUNR
ZAEHK</b>
kschl lifnr kwert
FROM konv
INTO TABLE l_i_konv
FOR ALL ENTRIES IN l_i_dv_knumv
WHERE knumv = l_i_dv_knumv-table_line
AND kappl = 'M'.
Change the declaration of your in tab like this:
TYPES:
BEGIN OF ty_konv,
knumv TYPE knumv,
kposn TYPE kposn,
<b>STUNR type STUNR,
ZAEHK type ZAEHK,</b>
kschl TYPE kscha,
lifnr TYPE lifnr,
kwert TYPE kwert,
END OF ty_konv.
DATA: l_i_konv TYPE TABLE OF ty_konv.
Regards,
Ravi
2007 Jun 19 12:26 PM
Hi Naren, DanielY, aRs, Felipe Gelme, Mugnthan Kasipa, Ravi Kanth Tala!
Thanks for your answers!
Really the problem was happened because the clause "FOR ALL ENTRIES". I change the code and now is perfect!
Regards,
Silvio Messias