2008 Jul 22 3:23 AM
Hello, everyone.
I'd like to ask question about using at new during looping with where condition.
I used at new with loop ~ where, but it doesn's work properly.
Read next. please.
I have an internal table like this.
itab.
(index) PCTGP GPM PRCTR DEXIM VRGAR~~~~
0 A0 B0 BBB 0 0
1 AA BB BBC 0 1
2 AA BB BBC 0 1
........................
3 AA BB BBC 1 0
4 AA BB BBC 1 0
And I used following sentences.
loop at itab where vrgar <> '1'.
at new prctr.
sum.
......
endat.
at new dexim.
sum
endat.
endloop.
I expected to read index 3 to sum data but at new prctr sentence was passed.
And on next at new dexim was worked well.
I thought that at new prctr work well because index 1 and 2 records wasn't read during looping , and index 3 record's prctr was different from index 0's prctr.
But at result, at new prctr was passed.
Why was this happened?
Does at new work with whole itab although the looping has where condition?
If I revise this code, what should I do for summation at prctr level?
Please answer for this question.
I really glad to see good answers.
Thanks.
P.S Sorry for poor English and Thank you read this.
2008 Jul 22 4:34 AM
Hi Hwan Kim,
Generally the control break statements dont work with WHERE conditions in LOOP statements.
We use the control break statements without using WHERE condition.
Best regards,
raam
Hello, everyone.
I'd like to ask question about using at new during looping with where condition.
I used at new with loop ~ where, but it doesn's work properly.
Read next. please.
I have an internal table like this.
itab.
(index) PCTGP GPM PRCTR DEXIM VRGAR~~~~
0 A0 B0 BBB 0 0
1 AA BB BBC 0 1
2 AA BB BBC 0 1
........................
3 AA BB BBC 1 0
4 AA BB BBC 1 0
And I used following sentences.
loop at itab where vrgar <> '1'.
at new prctr.
sum.
......
endat.
at new dexim.
sum
endat.
endloop.
I expected to read index 3 to sum data but at new prctr sentence was passed.
And on next at new dexim was worked well.
I thought that at new prctr work well because index 1 and 2 records wasn't read during looping , and index 3 record's prctr was different from index 0's prctr.
But at result, at new prctr was passed.
Why was this happened?
Does at new work with whole itab although the looping has where condition?
If I revise this code, what should I do for summation at prctr level?
Please answer for this question.
I really glad to see good answers.
Thanks.
P.S Sorry for poor English and Thank you read this.
2008 Jul 22 3:45 AM
Please refer the "Control level processing" section in the link given below, it clearly states the following
You should not use control level statements in loops where the line selection is
restricted by WHERE or FROM and TO. Neither should the table be modified
during the loop.
http://help.sap.com/saphelp_47x200/helpdata/en/fc/eb381a358411d1829f0000e829fbfe/content.htm
2008 Jul 22 4:22 AM
Hi,
if u use at new PRCTR it should be first field in itab.
(index) PRCTR PCTGP GPM DEXIM VRGAR~~~~
0 A0 B0 BBB 0 0
1 AA BB BBC 0 1
2 AA BB BBC 0 1
........................
3 AA BB BBC 1 0
4 AA BB BBC 1 0
And I used following sentences.
loop at itab where vrgar '1'.
at new prctr.
sum.
......
endat.
at new dexim.
sum
endat.
endloop.
hope it will help.
2008 Jul 22 4:34 AM
Hi Hwan Kim,
Generally the control break statements dont work with WHERE conditions in LOOP statements.
We use the control break statements without using WHERE condition.
Best regards,
raam