2008 Apr 02 9:48 AM
Hi all,
I am using cl_salv_table to get alv list.
but i want to limit the field columns in the final output, since we so not pass any fieldcat in this method ,
so please tell me how to limit the field in the output.
regards,
kushagra
yes with this columns can be limited,
But how to get header in my alv list.
please help me if you have any idea
2008 Apr 02 10:00 AM
Hi ,
see the Example coding,
REPORT sapmz_hf_alv_grid .
TABLES: zsflight.
*--------------------------------------------------------------------
* G L O B A L I N T E R N A L T A B L E S
*--------------------------------------------------------------------
DATA: gi_sflight TYPE STANDARD TABLE OF sflight.
*--------------------------------------------------------------------
* G L O B A L D A T A
*--------------------------------------------------------------------
DATA: ok_code LIKE sy-ucomm,
g_wa_sflight LIKE sflight.
* 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 '100'.
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
CASE ok_code.
WHEN 'EXIT'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
MODULE status_0100 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 zsflight
INTO TABLE gi_sflight.
* Load data into the grid and display them
CALL METHOD go_grid->set_table_for_first_display
EXPORTING i_structure_name = 'SFLIGHT'
CHANGING it_outtab = gi_sflight.
ENDFORM. " load_data_into_gridRegards,
Morris Bond.
Reward Points if Helpful.
2008 Apr 02 10:08 AM
hi
Actually I am doing
cl_salv_table=>factory(
EXPORTING
list_display = if_salv_c_bool_sap=>true
IMPORTING
r_salv_table = gr_table
CHANGING
t_table = it_final2 ).
gr_functions = gr_table->get_functions( ).
gr_functions->set_all( abap_true ).
gr_table->get_columns( 1 ).
gr_table->display( ).
please tell me how to get header in the output
regards ,
kushagra
2008 Apr 02 10:32 AM
Hi,
You can exclude a column from ALV display using the method SET_VISIBLE of the class CL_SALV_TABLE.
Try this source code.
**-Variable Declaration.
DATA: IT_SFLIGHT type table of SFLIGHT,
R_TABLE type ref to CL_SALV_TABLE,
R_FUNC type ref to CL_SALV_FUNCTIONS,
R_COLS type ref to CL_SALV_COLUMNS_TABLE,
R_COL type ref to CL_SALV_COLUMN_TABLE.
START-OF-SELECTION.
Select * from SFIGHT into table IT_SFLIGHT.
**Call the class method factory method in TRY ENDTRY block.
TRY.
CALL METHOD cl_salv_table=>factory
IMPORTING
r_salv_table = r_table
CHANGING
c_table = it_sfilght.
CATCH cx_salv_msg .
ENDTRY.
r_func = r_table->get_functions( ).
r_func->set_all( Abap_True ).
r_cols = r_table->get_columns( ).
r_col ?= r_cols->Get_Column( 'XXX' ).
***---'XXX' is the name of the column you want to exclude suppose 'SEATSMAX' in SFLIGHT table.
r_col->SET_VISIBLE( abap_false ).
r_table->display( ).
I believe that this can satisfy the requirement.
Please check.
Regards,
Khushboo.
2008 Apr 02 10:37 AM
yes with this columns can be limited,
But how to get header in my alv list.
please help me if you have any idea
2008 Apr 02 10:43 AM
Hi
Try to find out the parameter which takes the value as sel-text. It is similar to normal ALV.U will pass the value as heading there.
2008 Apr 02 10:46 AM
Hi ,
For the Header use
DATA: r_column_table TYPE REF TO cl_salv_column_table.
DATA: lr_grid TYPE REF TO cl_salv_form_layout_grid.
CREATE OBJECT lr_grid.
lr_grid->create_text(
row = 1
column = 1
text = 'Header Line 1' ).
lr_grid->create_text(
row = 2
column = 1
text = 'Header Line 2' ).
r_header = lr_grid.
With this u can define your own header names for the columns.
If you want to use table header names itself.
can use this,
DATA: r_display TYPE REF TO cl_salv_display_settings.
r_columns_table = r_table->get_columns( ).
r_columns_table->set_headers_visible( abap_true ).
where r_columns_table is ref variable of class cl_salv_columns_table.
Just check this one.
Regards,
Khushboo
2008 Apr 02 10:52 AM
HI khusbhu,
thanks for helping me out
one more question - How can we get Top-of-page in this alv list
2008 Apr 07 9:19 AM
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |