Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Control break(At new) problem in loop ~ where

Former Member
0 Likes
824

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.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
769

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.

3 REPLIES 3
Read only

Former Member
0 Likes
769

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

Read only

Former Member
0 Likes
769

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.

Read only

Former Member
0 Likes
770

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