‎2006 Apr 28 6:04 AM
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
‎2006 Apr 28 6:08 AM
I guess the reason is BSEG is a cluster table, because of which its throwing the error.
Regards,
Ravi
‎2006 Apr 28 6:13 AM
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.
‎2006 Apr 28 6:16 AM
HI Prashanth,
create a structure with the fields you want in se11 and then use it in your program..
regards
satesh
‎2006 Apr 28 6:19 AM
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
‎2006 Apr 28 6:34 AM
‎2006 Apr 28 7:10 AM
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
‎2006 Apr 28 6:10 AM
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