‎2006 Dec 14 2:56 PM
Hello,
I have only one entry in P0000 with aedtm = 11/01/2006 and iam writing this code.
loop at p0000 into p0000 where aedtm in s_aedtm.
IF SY-SUBRC EQ 0.
some code.
endif.
endloop.
but the thing is it is looping twice even though it has only one entry in p0000 and iam getting 2 entries. can yoe please explain why this is happening
Thanks
Viky
‎2006 Dec 14 2:57 PM
What is in s_aedtm?
You don't need the if sy-subrc inside the loop, as it will only go into the loop if it find an entry to match the where condition.
‎2006 Dec 14 2:59 PM
Yes ,
But why is it going into the loop twice if it has only one entry in that.
Thanks
Viky
‎2006 Dec 14 2:58 PM
Also why are you looping into a header line of the same name as the table? If the table has a header line you can use the syntax:
LOOP AT p0000 WHERE etc
without specifing the header line.
‎2006 Dec 14 3:00 PM
‎2006 Dec 14 3:00 PM
Remove the code you don't need and see if it's still doing the same time. Othewise we need to know whats in s_aedtm.
‎2006 Dec 14 3:04 PM
here is my code below
loop at p0000 where aedtm in s_aedtm.
MOVE P0000-PERNR TO IT_tab-PERNR.
MOVE P0000-AEDTM TO IT_tab-AEDTM.
MOVE P0000-BEGDA TO IT_tab-BEGDA.
MOVE P0000-UNAME TO IT_tab-UNAME.
endloop.
‎2006 Dec 14 3:07 PM
I dont think there would be a check for SY-SUBRC.
Please Write LOOP at i_tab into work_area.
You are not using work area explicitely. Please declare a work area of LINE TYPE of P000.
Regards,
Surya
‎2006 Dec 14 3:12 PM
Do you have GET PERNR above the loop?
it might be looping twice.
Regards
Sridhar
‎2006 Dec 14 3:16 PM
‎2006 Dec 14 3:21 PM
Put a break point at LOOP and execute, the program should stop at loop twice, that's the reason for 2 records even if P0000 contain only one.
Regards
Sridhar
‎2006 Dec 14 3:24 PM
‎2006 Dec 14 3:33 PM
GET PERNR event might be selecting 2 records depending on the user selection.
limit the selection to select only one record, or discard the records from itab after the selection is complete.
Regards
Sridhar
‎2006 Dec 14 3:37 PM
use CLEAR P000 before the loop , this should not be a problem but just a try
‎2006 Dec 14 3:09 PM
data: i_p0000 type table of pa0000 with header line.
loop at p0000 where aedtm in s_aedtm.
read table i_p0000 with key
aedtm = s_aedtm.
if sy-subrc ne 0.
move p0000 to i_p0000.
append i_p0000.
endif.
endloop.
this will read your internal table and only append to it if it does not find an entry with a duplicate changed on date (s_aedtm) from the selection screen.
This will read the internal table and only insert 1 value with that aedtm. If your s_aedtm is a select option and you have several single entries it will do the same, entering 1 record for each aedtm you specify.
Warren
‎2006 Dec 14 6:10 PM
Vicky,
You could do...
*********************
data: I_P0000 type table of PA0000 with header line.
start-of-selection.
get pernr.
provide single * from p0000 between pn-begda and pn-endda
where aedtm = s_aedtm.
move P0000 to I_P0000.
append I_P0000.
endprovide.
end-of-selection.