‎2009 Feb 06 8:46 AM
Hi,
i am using below code
code no 1.
sort t_lae_cr by allocation_id event status procmode.
delete t_lae_cr where event = 'NEWL' and status eq '9' and procmode eq '5' .
after executing above commands i get 284 records,
but when i used below code,
code no 2.
LOOP AT t_lae_cr WHERE event = 'NEWL' AND status EQ '9' AND procmode EQ '5'
DELETE t_lae_cr WHERE allocation_id = t_lae_cr-allocation_id.
CLEAR t_lae_cr.
ENDLOOP.
after executing above command i get 283 records.
So i just want to know why record count is not coming same in both the codes when they are doing the same tasks. is there any sorting issue in code 1 ?
Please help.
‎2009 Feb 06 8:55 AM
Hi,
In first code you havenot checked for allocation_id ,but in the second one while deleting you are checking it.
This might be the reason.
‎2009 Feb 06 8:55 AM
Hi,
In first code you havenot checked for allocation_id ,but in the second one while deleting you are checking it.
This might be the reason.
‎2009 Feb 06 8:56 AM
hi,
according to me , in 2 code : the delete statement in loop is deleting the 1 record corresponding to that allocation id, on basis of which you are deleting in loop.
so 283 records are left.
regards
rahul
‎2009 Feb 06 8:59 AM
Hi,
Tell me before deleting, the original no of records is 285 or anything else !!!
Delete adjacent duplicates deletes duplicates and one original remains in the table .
But here in second DELETE condition you are deleting all the duplicate and original records of the for which there are duplicates in the table .
As far my guess there is only one record that have duplicate records .
Regards
Pinaki
‎2009 Feb 06 9:00 AM
Hi,
you're checking the value of the row on code 2 before deleting. Try to remove the WHERE clause.
Regards,
Mon Magallanes
‎2009 Feb 06 9:00 AM
Hi,
Do a small change in ur code 2 and see
code no 1.
sort t_lae_cr by allocation_id event status procmode.
delete t_lae_cr where event = 'NEWL' and status eq '9' and procmode eq '5' .
after executing above commands i get 284 records,
but when i used below code,
code no 2.
LOOP AT t_lae_cr WHERE event = 'NEWL' AND status EQ '9' AND procmode EQ '5'
DELETE t_lae_cr .
CLEAR t_lae_cr.
ENDLOOP.
Regards,
Nagaraj
‎2009 Feb 06 9:04 AM
Hi,
DELETE t_lae_cr WHERE event = 'NEWL' AND status EQ '9' AND procmode EQ '5' .To acheive this using loop you shud write,
LOOP AT t_lae_cr WHERE event = 'NEWL' AND status EQ '9' AND procmode EQ '5'
DELETE t_lae_cr. "You have added one more condition here
CLEAR t_lae_cr.
ENDLOOP.Regards,
Manoj Kumar P
‎2009 Feb 06 9:04 AM
Hi,
Check if the Allocation have one duplicate entry.
Beacues for second code:
DELETE t_lae_cr WHERE allocation_id = t_lae_cr-allocation_id.
The delet is happenig when allocation_id matches..
Alternate Code for 2:
LOOP AT t_lae_cr WHERE event = 'NEWL' AND status EQ '9' AND procmode EQ '5'
DELETE t_lae_cr index sy-tabix.
CLEAR t_lae_cr.
ENDLOOP.
For 1st code:Allocation Id is not considered.
Hope it resolves your query.
Regards,
Gurpreet
‎2009 Feb 06 9:07 AM
Hi,
it is very simple,
Check this eg,
allocation_id event status procmode
100 NEWL 9 5
100 NEWL 8 5
101 NEWL 9 5
102 NEWL 9 5
102 NEWL 7 5
103 ABCD 5 3
According code 1.
U'll get like this
allocation_id event status procmode
100 NEWL 8 5
102 NEWL 7 5
103 ABCD 5 3
Accoding code 2.
allocation_id event status procmode
103 ABCD 5 3
In the second code u r using allocation Id to delete the records.
when allocation Id is 100 , u have to delete only one record which satisfies. But when u delete in the second code both the records are deleted because allocation Id is same for next record also.
‎2009 Feb 06 9:17 AM
Hi Santosh,
Their might be a possibility that while loop into your internal table the header record is getting deleted.
Bcoz's your internal table is a table with header line.
That's why u r getting one record less.
Do like this:
Create an internal table with a workarea. like
data: t_lae_cr like standard table of <WA>.
and then proceed with your code.
also try removing the CLEAR Statement from your code.
Hope it's clear.
Thanks
Ravi Aswani