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 grid

Former Member
0 Likes
512

hi friends,

can you please tell me how to hide the horizontal lines in the alv grid display using alv oops

hi friends,

can you please tell me how to hide the horizontal lines in the alv grid display using alv oops

2 REPLIES 2
Read only

uwe_schieferstein
Active Contributor
0 Likes
440

Hello Premraj

The ALV layout (structure <b>LVC_S_LAYO</b>) has the fields

NO_HGRIDLN	ALV control: Hide horizontal grid lines
NO_VGRIDLN	ALV control: Hide vertical grid lines

which allow you to hide horizontal or vertical lines for <b>entire </b>columns.

Regards

Uwe

Read only

0 Likes
440

Do it this way assuming you have a "display only" type grid.

Use the new simplified class cl_salv_table -- no field catalog or other complex stuff required.

If you want Interactive editable lists then you'll have to use the more complex class cl_gui_alv_grid but for simple lists and cell selections the new cl_salv_table class is the one to use.

I've only shown the relevant ALV coding stuff here

but build an internal table say t_vbak via standard abap. I've for example got some basic data about sales orders in an internal table t_vbak. (coding not shown --absolutely 100% bog standard Abap.)

Once you've built an internal table then the following code should work without much modification. Change the column names to those in your own internal table and set the name of your internal table in the CHANGING parameter when you call cl_salv_table=>factory as shown below.

The internal table also desn't have to consist of only DDIC entries. Any field names are allowed. Remember we aren't using the standard FCAT's in this cl_salv_table class.

Now display as grid or classic list hiding vertical and horizontal lines and colour some cells as well.

Also shown here is how to add your own names to columns.

**********************************

data: gr_table TYPE REF TO cl_salv_table.

data: gr_display TYPE REF to cl_salv_display_settings.

data: lr_functions type ref to cl_salv_functions_list.

constants: gc_true type sap_bool value 'X',

gc_false type sap_bool value space.

  • add for colour displays

data: ls_color type lvc_s_colo.

DATA : LV_SALV_COLUMNS_TABLE TYPE REF TO CL_SALV_COLUMNS_TABLE.

data: lr_columns type ref to cl_salv_columns_table,

lr_column type ref to cl_salv_column_table.

  • Instantiate our alv grid / list

TRY.

CALL METHOD cl_salv_table=>factory

EXPORTING

list_display = if_salv_c_bool_sap=>false "set to TRUE for classic list

IMPORTING

r_salv_table = gr_table

CHANGING

t_table = t_vbak. "Your internal table

CATCH cx_salv_msg.

ENDTRY.

  • Colour some columns

try.

LV_SALV_COLUMNS_TABLE = gr_table->get_columns( ).

lr_column ?= LV_SALV_COLUMNS_TABLE->get_column( 'NETWR' ).

ls_color-col = col_negative.

ls_color-int = 0.

ls_color-inv = 0.

lr_column->set_color( ls_color ).

catch cx_salv_not_found.

endtry.

try.

lr_column ?= LV_SALV_COLUMNS_TABLE->get_column( 'VBELN' ).

ls_color-col = col_negative.

ls_color-int = 1.

ls_color-inv = 1.

lr_column->set_color( ls_color ).

catch cx_salv_not_found.

endtry.

try.

  • Set your own titles

  • you can set your own column titles here

  • note column name is the FIELD NAME in your internal table

LV_SALV_COLUMNS_TABLE = gr_table->get_columns( ).

lr_column ?= LV_SALV_COLUMNS_TABLE->get_column( 'NETWR' ).

lr_column->set_short_text( 'Short' ).

lr_column->set_medium_text( 'Medium' ).

lr_column->set_long_text( 'Net Value' ).

catch cx_salv_not_found.

endtry.

gr_table->set_screen_status( pfstatus = 'SALV_STANDARD'

report = sy-repid

set_functions = gr_table->c_functions_all ).

  • above statement only needed if you are running as a dialog and want

  • the standard buttons / functions

  • switch off horizontal and vertical lines

gr_display = gr_table->get_display_settings( ).

gr_display->set_horizontal_lines( value = ' ' ).

gr_display->set_vertical_lines( value = ' ' ).

  • this statement actually does the display.

gr_table->display( ).

This should answer the question <b><REMOVED BY MODERATOR></b>

Cheers

Jimbo

Message was edited by:

Alvaro Tejada Galindo