How do I read and print a generic internal table?

abap, internal-tables

Solution

This is the exact reason SAP has developed ALV (ABAP List Viewer). One of the shortest way to display any (non-nested) table is the following.

  DATA: go_alv  TYPE REF TO cl_salv_table.

  CALL METHOD cl_salv_table=>factory
    IMPORTING
      r_salv_table = go_alv
    CHANGING
      t_table      = itab.

  go_alv->display( ).

Problem

I'm pretty new to this. I'm currently studying abap for my job and I have a problem that I can't seem to work out. How would I go about creating a Function Module that takes any kind of internal table and write it to the screen? I'm looking for a very generic solution that can work with any kind of internal table as input.

Original source