Skip to Content
-2
May 22, 2020 at 04:48 AM

how to use modify inside a loop at group block?

718 Views Last edit May 22, 2020 at 04:50 AM 2 rev

I have internal table like below.

Month number Index

-----------------------------------

1 5

1 6

2 3

---------------------------------------

Now I want to add index based on month. The result will like below

Month number Index

-----------------------------------

1 5 1

1 6 2

2 3 1

---------------------------------------

I want to use loop group to implement.

The code is like below.

loop at itab into data(wa)
    location = sy-tabix.
    loop at group wa into data(wa1)
       wa1-index = sy-tabix - location.
       modify itab from wa1.
    endloop.
end loop.

But the modify line has error like

"DELETE itab." 和 "MODIFY itab FROM wa." can't use in  "LOOP AT itab ... USING KEY keyname ..." <br>

Then what's the correct syntax to write back to the itab? Thx.