It’s not possible use ‘SUM’ statement in a select query with ‘FOR ALL ENTRIES’ statement but it is possible in other way. Here is the solution.
You can loop in your internal table that you will use it in select query as for all entries statement. You can collect all ur entries in internal table to range table and you can use your range table as internal table. So you don’t need to use for all entries because you have your selection criteries in your range table. And ABAP editor led you to use range table with SUM statement. Check the example.