Skip to Content

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

ALV with Classes and methods

Hi All,

Please give the solution for ALV with classes.

Here this code is used for total fields.

Bu ti need only for a group of fields.

Let assume 5 fields.

Please give the solution how to do this i.e for 5 required fields display.

Here i tried by taking gi_bseg with my selected fields.

But it is giving error that i_structure name is not mapping.

TABLES: BSEG.

**----


  • * G L O B A L I N T E R N A L T A B L E S

*

**----


DATA: gi_bseg TYPE STANDARD TABLE OF BSEG.

**----


  • * G L O B A L D A T A

*

**----


DATA: ok_code LIKE sy-ucomm,

g_wa_bseg LIKE GI_bseg.

  • Declare reference variables to the ALV grid and the container

DATA:

go_grid TYPE REF TO cl_gui_alv_grid,

go_custom_container TYPE REF TO cl_gui_custom_container.

*

**----


  • * S T A R T - O F - S E L E C T I O N.

*

**----


START-OF-SELECTION.

SET SCREEN '10'.

&----


  • *& Module USER_COMMAND_0100 INPUT

&----


MODULE user_command_0010 INPUT.

CASE ok_code.

WHEN 'EXIT'.

LEAVE TO SCREEN 0.

ENDCASE.

ENDMODULE. " USER_COMMAND_0100 INPUT

&----


  • *& Module STATUS_0100 OUTPUT

&----


MODULE status_0010 OUTPUT.

  • * Create objects

IF go_custom_container IS INITIAL.

CREATE OBJECT go_custom_container

EXPORTING container_name = 'ALV_CONTAINER'.

CREATE OBJECT go_grid

EXPORTING

i_parent = go_custom_container.

PERFORM load_data_into_grid.

ENDIF.

ENDMODULE. " STATUS_0100 OUTPUT

&----


  • *& Form load_data_into_grid

&----


FORM load_data_into_grid.

  • * Read data from table SFLIGHT

SELECT *

FROM BSEG

INTO TABLE gi_bseg.

  • * Load data into the grid and display them

CALL METHOD go_grid->set_table_for_first_display

EXPORTING i_structure_name = 'BSEG'

CHANGING it_outtab = GI_bseg.

ENDFORM. " load_data_into_grid

Tags:
Not what you were looking for? View more on this topic or Ask a question