0% found this document useful (0 votes)
145 views

SAP ABAP Creating A Function Module in ABAP To Take Any Table and Write It To The Screen

The document discusses two methods for creating an ABAP function module to display any internal table on the screen. The first uses the SAP List Viewer (ALV) component to provide a flexible display with options like sorting and filtering. The second uses field symbols to dynamically access and write out components of a work area without knowing the table structure in advance.

Uploaded by

Leandro Tentoni
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
145 views

SAP ABAP Creating A Function Module in ABAP To Take Any Table and Write It To The Screen

The document discusses two methods for creating an ABAP function module to display any internal table on the screen. The first uses the SAP List Viewer (ALV) component to provide a flexible display with options like sorting and filtering. The second uses field symbols to dynamically access and write out components of a work area without knowing the table structure in advance.

Uploaded by

Leandro Tentoni
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

17/06/2021 Creating a Function module in ABAP to take any table and write it to the screen

Creating a Function module in ABAP to take any table and write it to


the screen

SAP List Viewer is used to add an ALV component and provides a flexible environment to display
lists and tabular structure. A standard output consists of header, toolbar, and an output table. The
user can adjust the settings to add column display, aggregations, and sorting options using
additional dialog boxes.

You can use following code to display any table:

DATA: go_alv TYPE REF TO cl_salv_table.

   CALL METHODcl_salv_table=>factory

   IMPORTING

      r_salv_table = go_alv

   CHANGING

      t_table     = itab.

 go_alv->display( ).

Another Dynamic Way to Output Any Internal Table is by using field-symbol, this is a particular
field type in ABAP. Without going into the details of it, you must know that a field symbol works
like a pointer without pointer arithmetic, but has a value semantics.

FIELD-SYMBOLS:<row> TYPE ANY.

FIELD-SYMBOLS:<comp> TYPE ANY.

The typing ANY is necessary because the field symbol should be able to refer to data of any
type. And this is what our loop looks like now using a dynamic assignment to the various
components of the work area:

LOOP ATitab_flight INTO row.

   DO.

      ASSIGN COMPONENTsy-index OF STRUCTURE <row> TO <wa_comp>.

      IF sy-subrc <>0.

         SKIP.

      EXIT.

      ENDIF.

         WRITE <wa_comp>.

   ENDDO.

ENDLOOP

https://www.tutorialspoint.com/Creating-a-Function-module-in-ABAP-to-take-any-table-and-write-it-to-the-screen 1/1

You might also like