SAP ABAP Question:
Download Questions PDF

What is the difference between sum and collect?

Answer:

Sum: You can only use this statement within a LOOP. If you use SUM in an AT - ENDAT block, the system calculates totals for the numeric fields of all lines in the current line group and writes them to the corresponding fields in the work area. If you use the SUM statement outside an AT - ENDAT block (single entry processing), the system calculates totals for the numeric fields of all lines of the internal table in each loop pass and writes them to the corresponding fields of the work area. It therefore only makes sense to use the SUM statement in AT...ENDAT blocks.

If the table contains a nested table, you cannot use the SUM statement. Neither can you use it if you are using a field symbol instead of a work area in the LOOP statement.

Download SAP ABAP Interview Questions And Answers PDF

Previous QuestionNext Question
What are System Variable in ABAP?What is the typical structure of an ABAP program?