Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Generic object-orientated ALV with

Hello everyone!

I've got to solve a little problem and hope, to finde some help here.

My goal is a global ALV-class, that can be used by programms to easily create ALV's.

I want to use a generate_output method within this class, that takes any internal table as a parameter and generates an ALV out of it. So when you got an internal table, you just have to create an instance of the global alv class and run the output method with your table as parameter to get a basic alv (later I'm planning to use sub-classes of this basic, global alv class, for more specified and program-related alv's.).

But for now, that's all I need to do.

So it should look and work like this:

DATA: lo_alv TYPE REF TO zcl_alv_report. "our global class instance
DATA: it_tab TYPE TABLE OF zzm_ehsanl.  "a random internal table
SELECT * FROM zzm_ehsanl INTO TABLE it_tab. "fill it with some data
CREATE OBJECT lo_alv. "let's create an instance of the global alv class
lo_alv->generate_output( it_tab ). "This line is supposed to be all we need for the alv


Now, let's take a look at the generate_output method within the global class.

methods GENERATE_OUTPUT importing alv_table type any table.

So we can use any internal table as a parameter.

Let's get to the implementation part:

METHOD generate_output.
  DATA: lx_msg TYPE REF TO cx_salv_msg.
  ASSIGN alv_table TO <fs_itab>. "assign the parameter to the field-symbol
    cl_salv_table=>factory("<=== that's the point where the dump occurs 
        IMPORTING            r_salv_table = o_alv
        CHANGING             t_table      = <fs_itab> ).
    CATCH cx_salv_msg INTO lx_msg.

The further code shouldn't be relevant for my problem..


Edited and split up into 2 posts..


Try changing the method parameter as the CHANGING.

methods GENERATE_OUTPUT CHANGING alv_table type any table

SALV object model interally try to change the table e.g for Sorting or Filtering, and that's why it is as the CHANGING parameter in the FACTORY method of the CL_SALV_TABLE.

        IMPORTING            r_salv_table = o_alv
        CHANGING             t_table      = <fs_itab> ).    " << CHANGING


Naimesh Patel

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question