Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

ALV with Classes and methods

Former Member
0 Likes
687

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

7 REPLIES 7
Read only

Former Member
0 Likes
649

I guess the reason is BSEG is a cluster table, because of which its throwing the error.

Regards,

Ravi

Read only

0 Likes
649

Hi Ravi

It is working when i take

DATA: gi_bseg TYPE STANDARD TABLE OF BSEG.

But when i select some fields like

data : begin of gi_bseg occurs 0,

budat like bseg-budat,

wrbtr like bseg-wrbtr,

end of gi_bseg.

it is giving the error.

Read only

0 Likes
649

HI Prashanth,

create a structure with the fields you want in se11 and then use it in your program..

regards

satesh

Read only

0 Likes
649

Hi Prashanth,

If it raises an error when you try to select only a few fields, you could use a crude apporach wherein you collect all data into an internal table. Then transfer all the fileds that you require into a second internal table. Use this table for ALV.

Reagrds,

Aniket

Read only

0 Likes
649

Hi Satish

I tried with ur suggestion but it is not working

Read only

0 Likes
649

Hi Prashanth,

Try to Build your fieldcat manually and pass it , instead of doing that...

then you can able to see the ALV grid Output.

try manually fieldcat for the fields which you want.

Regards

vijay

Read only

Former Member
0 Likes
649

Hi prashanth,

build your fieldcatalogue using LVC_FIELDCATALOG_MERGE

and use the fieldcat to display the table when you call the display method..

regards

satesh