ABAP Obsolete statements - REFRESH

Its time for another bite-sized post, This time with an obsolete statement.

You have used it and I have used it, we all have used it whenever we wanted to clear the content of an internal table. Yes, I am talking about the REFRESH statement.

Its almost second nature to use a CLEAR statement for clearing variables and Structures and REFRESH statements for Internal tables.

To all the lovers of REFRESH statements, I have got bad news. It's Obsolete. 

SO whats the replacement? its good old CLEAR statement,


You might be wondering, why? It was a harmless statement. The way I see it, It became redundant with an Object-oriented setup.

You see the statement REFRESH itab acts for internal tables like CLEAR itab[]. 
If the internal table itab has a header line, then the table body and not the header line is initialized.
If the internal table itab has no header line, REFRESH itab acts like CLEAR itab.
Now, Since the use of tables with header lines is obsolete and forbidden in classes, the use of REFRESH instead of CLEAR is also obsolete.

To delete rows in internal tables, CLEAR or FREE can always be used.

Bottom line, Stop Using REFRESH, Start using CLEAR or FREE when relevant..


Popular posts from this blog

ABAP convert internal table to excel (.xlsx) format and Send email or download

ABAP read excel(.XLSX) file to internal table in ABAP using CL_FDT_XL_SPREADSHEET

Application Logging in ABAP