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

SALV

Former Member
0 Likes
939

Hi,

please provide me with some good documents on SALV??

Some demo code and other Staff??

what are the different options avlb. with SALV???

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
829

Go to SE 38...Put salv* and press f4..u will get list of sample salv program....

regards:

Prabu

7 REPLIES 7
Read only

Former Member
0 Likes
830

Go to SE 38...Put salv* and press f4..u will get list of sample salv program....

regards:

Prabu

Read only

Former Member
0 Likes
829

Go to SE 38...Put salv* and press f4..u will get list of sample salv program....

regards:

Prabu

Read only

Former Member
0 Likes
829

Hi Shashi,

Check out this thread(with sample code):

Regards,

Chandra Sekhar

Read only

Former Member
0 Likes
829

Check out the below related threads ...

Sample Code :::

&----


*& Report ZGAURAV_TEST

*&

&----


*&

*&

&----


report ZGAURAV_TEST message-id z_zzz_ca_messages.

  • constants for icons

type-pools: icon,

  • constants for colors

col.

  • type for internal table

types: begin of t_sflight.

include structure sflight.

types: seatsfree type sflight-seatsocc,

  • exception

usage type n,

  • icon for future / past

icon_future type icon-id,

  • line counter

line_counter type i,

  • internal table for cell color information

it_colors type lvc_t_scol,

end of t_sflight.

  • Internal table

data: it_sflight type table of t_sflight.

  • Workarea for data fetch

data: wa_sflight like line of it_sflight.

  • Workarea for cell color information

data: wa_colors like line of wa_sflight-it_colors.

  • Switch for list display yes / no

data: list_display type sap_bool.

  • Reference for container control

data: gr_cont type ref to cl_gui_custom_container.

  • Reference for ALV instance

data: gr_alv type ref to cl_salv_table.

  • Reference for error situations

data: gr_error type ref to cx_salv_error.

  • user-command from dynpro

data: ok_code like sy-ucomm.

select-options:

so_car for wa_sflight-carrid memory id car,

so_con for wa_sflight-connid.

selection-screen skip 1.

selection-screen

begin of block alv with frame title text-alv.

parameters: pa_full radiobutton group alvd default 'X',

pa_cont radiobutton group alvd,

pa_list radiobutton group alvd.

selection-screen end of block alv.

parameters: p_layout type slis_vari.

start-of-selection.

  • retrieve data into internal table

select * from sflight

into corresponding fields of table it_sflight

where carrid in so_car

and connid in so_con.

  • fill additional data fields

loop at it_sflight into wa_sflight.

  • seats free

wa_sflight-seatsfree =

wa_sflight-seatsmax + wa_sflight-seatsmax_b

+ wa_sflight-seatsmax_f

- wa_sflight-seatsocc - wa_sflight-seatsocc_b

- wa_sflight-seatsocc_f.

  • usage (exception light)

if wa_sflight-seatsfree = 0.

wa_sflight-usage = '1'.

elseif wa_sflight-seatsfree <= 20.

wa_sflight-usage = '2'.

else.

wa_sflight-usage = '3'.

endif.

  • icon "in the future/not in the future"

if wa_sflight-fldate > sy-datum.

wa_sflight-icon_future = icon_positive.

else.

wa_sflight-icon_future = icon_negative.

endif.

  • cell colors

  • single cell if planetype is 747-400

if wa_sflight-planetype = '747-400'.

clear wa_colors.

wa_colors-fname = 'PLANETYPE'.

wa_colors-color-col = col_positive.

wa_colors-color-int = 1.

append wa_colors to wa_sflight-it_colors.

endif.

  • whole line if seatsfree gt 200

if wa_sflight-seatsfree >= 200.

clear wa_colors.

wa_colors-color-col = col_heading.

wa_colors-color-int = 1.

append wa_colors to wa_sflight-it_colors.

endif.

modify it_sflight

from wa_sflight

transporting

seatsfree

usage

icon_future

it_colors.

endloop.

call method cl_salv_table=>factory

exporting

list_display = if_salv_c_bool_sap=>false

importing

r_salv_table = gr_alv

changing

t_table = it_sflight.

  • define settings

perform define_settings using gr_alv.

  • display ALV

gr_alv->display( ).

&----


*& Form define_settings

&----


  • text

----


  • -->P_ALV ALV object

----


form define_settings using p_alv type ref to cl_salv_table.

perform:

set_display using p_alv,

set_columns using p_alv,

set_sorts using p_alv,

set_aggregs using p_alv,

set_selections using p_alv,

set_layout using p_alv.

endform. " define_settings

*&----


*& Form set_display

*&----


  • set general display attributs

*----


  • -->P_ALV ALV object

*----


form set_display using p_alv type ref to cl_salv_table.

data: lr_display type ref to cl_salv_display_settings,

l_title type lvc_title.

  • get display settings object

lr_display = p_alv->get_display_settings( ).

  • set header

l_title = text-ttl.

lr_display->set_list_header( value = text-ttl ).

  • set horizontal lines off

lr_display->set_horizontal_lines( value = ' ' ).

  • set striped pattern

lr_display->set_striped_pattern( value = 'X' ).

endform. " set_display

&----


*& Form set_columns

&----


  • text

----


  • -->P_ALV text

----


form set_columns

using p_alv type ref to cl_salv_table.

data: lr_columns

type ref to cl_salv_columns_table.

data: lr_column

type ref to cl_salv_column_table.

  • help fields for title text

data: l_scrtext_s type scrtext_s,

l_scrtext_m type scrtext_m,

l_scrtext_l type scrtext_l.

  • help field for tooltip

data: l_lvc_tip type lvc_tip.

  • help field for column position

data: l_pos type i.

  • help field for column color

data: l_lvc_s_colo type lvc_s_colo.

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

  • general columnsu2019 settings

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

  • get columns object

lr_columns = p_alv->get_columns( ).

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

  • columns for special purposes

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

  • set exception column

lr_columns->set_exception_column(

value = 'USAGE'

  • GROUP = SPACE

  • CONDENSED = IF_SALV_C_BOOL_SAP=>FALSE

).

  • set count column

lr_columns->set_count_column(

value = 'LINE_COUNTER' ).

  • set cell colors / line colors column

lr_columns->set_color_column(

value = 'IT_COLORS' ).

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

  • single columnsu2019 settings

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

  • column ICON_FUTURE

lr_column ?= lr_columns->get_column(

columnname = 'ICON_FUTURE' ).

lr_column->set_icon( ).

l_scrtext_s = text-fut.

lr_column->set_short_text( value = l_scrtext_s ).

lr_column->set_row( value = 2 ).

  • Column SEATSFREE

lr_column ?= lr_columns->get_column(

columnname = 'SEATSFREE' ).

  • set color to COL_GROUP

l_lvc_s_colo-col = col_group.

l_lvc_s_colo-int = 1.

lr_column->set_color( value = l_lvc_s_colo ).

endform. "set_columns

*&----


*& Form set_sorts

*&----


  • -->P_ALV text

*&----


form set_sorts using p_alv type ref to cl_salv_table.

data: lr_sorts type ref to cl_salv_sorts.

  • get the SORTS object

lr_sorts = p_alv->get_sorts( ).

  • add sorts

lr_sorts->add_sort( columnname = 'CARRID'

position = 1 ).

lr_sorts->add_sort( columnname = 'CONNID'

position = 2

subtotal = if_salv_c_bool_sap=>true ).

lr_sorts->add_sort( columnname = 'FLDATE'

position = 3 ).

endform. " set_sorts

*&----


*& Form set_aggregs

*&----


  • -->P_ALV text

*&----


form set_aggregs using p_alv type ref to cl_salv_table.

data: lr_aggregs

type ref to cl_salv_aggregations.

lr_aggregs = p_alv->get_aggregations( ).

lr_aggregs->add_aggregation(

columnname = 'SEATSFREE'

aggregation = if_salv_c_aggregation=>total

).

endform. " set_aggregs

*&----


*& Form set_selections

*&----


  • -->P_ALV text

*&----


form set_selections using p_alv type ref to cl_salv_table.

data: lr_selections type ref to cl_salv_selections.

  • get the SELECTIONS object

lr_selections = p_alv->get_selections( ).

  • set the selection mode

lr_selections->set_selection_mode(

value = if_salv_c_selection_mode=>cell ).

endform. " set_selections

*&----


*& Form set_layout

*&----


  • -->P_ALV text

*&----


form set_layout using p_alv type ref to cl_salv_table.

data: lr_layout type ref to cl_salv_layout,

ls_key type salv_s_layout_key.

  • get the LAYOUT object

lr_layout = p_alv->get_layout( ).

  • set the layout key

ls_key-report = sy-cprog.

lr_layout->set_key( value = ls_key ).

  • set save restriction

  • (restriction "none" is intended,

  • so we may use the default)

lr_layout->set_save_restriction(

  • VALUE = IF_SALV_C_LAYOUT=>RESTRICT_NONE

).

  • allow setting a default layout

lr_layout->set_default( value = 'X' ).

  • set initial layout

lr_layout->set_initial_layout( value = p_layout ).

endform. " set_layout

Read only

0 Likes
829

Let me guess?

Read only

0 Likes
829

Sry again..