Professional Documents
Culture Documents
*&--------------------------------------------------------------------
-*
*& This code snippet will show how to use the CL_SALV_TABLE to
*& generate the ALV
*&--------------------------------------------------------------------
-*
REPORT ztest_oo_alv_main.
*
*---------------------------------------------------------------------
-*
* CLASS lcl_report DEFINITION
*---------------------------------------------------------------------
-*
CLASS lcl_report DEFINITION.
*
PUBLIC SECTION.
*
* Final output table
TYPES: BEGIN OF ty_vbak,
vbeln TYPE vbak-vbeln,
erdat TYPE erdat,
auart TYPE auart,
kunnr TYPE kunnr,
END OF ty_vbak.
*
DATA: t_vbak TYPE STANDARD TABLE OF ty_vbak.
*
* ALV reference
DATA: o_alv TYPE REF TO cl_salv_table.
*
METHODS:
* data selection
get_data,
*
* Generating output
generate_output.
*
*$*$*.....CODE_ADD_1 - Begin..................................1..*$*$*
*
* In this section we will define the private methods which can
* be implemented to set the properties of the ALV and can be
* called in the
*
PRIVATE SECTION.
METHODS:
set_pf_status
CHANGING
co_alv TYPE REF TO cl_salv_table.
* Set Layout
METHODS:
set_layout
CHANGING
co_alv TYPE REF TO cl_salv_table.
* Set Top of page
METHODS:
set_top_of_page
CHANGING
co_alv TYPE REF TO cl_salv_table.
*
* Set End of page
METHODS:
set_end_of_page
CHANGING
co_alv TYPE REF TO cl_salv_table.
* Set DISPLAY SETTINGS LIKE SET THE ZEBRA STYLE, TITLE OF THE ALV
METHODS:
set_display_setting
CHANGING
co_alv TYPE REF TO cl_salv_table.
* Set Up the Hotspot & Event Handler
* Set the various column properties
METHODS:
set_hotspot_vbeln
CHANGING
co_alv TYPE REF TO cl_salv_table
co_report TYPE REF TO lcl_report.
*
* Event Handler for HOTSPOT event
METHODS:
on_link_click
FOR EVENT link_click OF cl_salv_events_table
IMPORTING
row
column .
*$*$*.....CODE_ADD_1 - End....................................1..*$*$*
*
ENDCLASS. "lcl_report DEFINITION
*
*
START-OF-SELECTION.
DATA: lo_report TYPE REF TO lcl_report.
*
CREATE OBJECT lo_report.
*
lo_report->get_data( ).
*
lo_report->generate_output( ).
*
*---------------------------------------------------------------------
-*
* CLASS lcl_report IMPLEMENTATION
*---------------------------------------------------------------------
-*
CLASS lcl_report IMPLEMENTATION.
*
METHOD get_data.
* data selection
SELECT vbeln erdat auart kunnr
INTO TABLE t_vbak
FROM vbak
UP TO 20 ROWS.
*
ENDMETHOD. "get_data
*
*.....................................................................
..
METHOD generate_output.
* New ALV instance
* We are calling the static Factory method which will give back
* the ALV object reference.
*
* exception class
DATA: lx_msg TYPE REF TO cx_salv_msg.
TRY.
cl_salv_table=>factory(
IMPORTING
r_salv_table = o_alv
CHANGING
t_table = t_vbak ).
CATCH cx_salv_msg INTO lx_msg.
ENDTRY.
*
*$*$*.....CODE_ADD_2 - Begin..................................2..*$*$*
*
* In this area we will call the methods which will set the
* different properties to the ALV
*
CALL METHOD set_pf_status
CHANGING
co_alv = o_alv.
SETTING UP LAYOUT
* Setting up the Layout
CALL METHOD set_layout
CHANGING
co_alv = o_alv.
Set DISPLAY SETTINGS LIKE SET THE ZEBRA STYLE, TITLE OF THE ALV
CALL METHOD set_display_setting
CHANGING
co_alv = o_alv.
* Set Up the Hotspot & Event Handler
CALL METHOD set_hotspot_vbeln
CHANGING
co_alv = o_alv
co_report = lo_report.
*$*$*.....CODE_ADD_2 - End....................................2..*$*$*
*
*
* Displaying the ALV
* Here we will call the DISPLAY method to get the output on the scre
en
o_alv->display( ).
*
ENDMETHOD. "generate_output
*
*$*$*.....CODE_ADD_3 - Begin..................................3..*$*$*
*
* In this area we will implement the methods which are defined in
* the class definition
*
METHOD set_pf_status.
*
DATA: lo_functions TYPE REF TO cl_salv_functions_list.
*
lo_functions = co_alv->get_functions( ).
lo_functions->set_default( abap_true ).
*
ENDMETHOD. "set_pf_status
METHOD set_pf_status.
*
* Calling method to set the PF-Status
co_alv->set_screen_status(
pfstatus = 'SALV_STANDARD'
report = 'SALV_DEMO_TABLE_SELECTIONS'
set_functions = co_alv->c_functions_all ).
*
ENDMETHOD. "set_pf_status
*SETTING UP LAYOUT
* In this area we will implement the methods which are defined in
* the class definition
METHOD set_layout.
*
DATA: lo_layout TYPE REF TO cl_salv_layout,
lf_variant TYPE slis_vari,
ls_key TYPE salv_s_layout_key.
*
* get layout object
lo_layout = co_alv->get_layout( ).
*
* set Layout save restriction
* 1. Set Layout Key .. Unique key identifies the Differenet ALVs
ls_key-report = sy-repid.
lo_layout->set_key( ls_key ).
* 2. Remove Save layout the restriction.
lo_layout->set_save_restriction( if_salv_c_layout=>restrict_none ).
*
* set initial Layout
lf_variant = 'DEFAULT'.
lo_layout->set_initial_layout( lf_variant ).
*
ENDMETHOD. "set_layout
METHOD set_top_of_page.
*
DATA: lo_header TYPE REF TO cl_salv_form_layout_grid,
lo_h_label TYPE REF TO cl_salv_form_label,
lo_h_flow TYPE REF TO cl_salv_form_layout_flow.
*
* header object
CREATE OBJECT lo_header.
*
* To create a Lable or Flow we have to specify the target
* row and column number where we need to set up the output
* text.
*
* information in Bold
lo_h_label = lo_header->create_label( row = 1 column = 1 ).
lo_h_label->set_text( 'Header in Bold' ).
*
* information in tabular format
lo_h_flow = lo_header->create_flow( row = 2 column = 1 ).
lo_h_flow->create_text( text = 'This is text of flow' ).
*
lo_h_flow = lo_header->create_flow( row = 3 column = 1 ).
lo_h_flow->create_text( text = 'Number of Records in the output' ).
*
lo_h_flow = lo_header->create_flow( row = 3 column = 2 ).
lo_h_flow->create_text( text = 20 ).
*
* set the top of list using the header for Online.
co_alv->set_top_of_list( lo_header ).
*
* set the top of list using the header for Print.
co_alv->set_top_of_list_print( lo_header ).
*
ENDMETHOD. "set_top_of_page
*
METHOD set_end_of_page.
*
DATA: lo_footer TYPE REF TO cl_salv_form_layout_grid,
lo_f_label TYPE REF TO cl_salv_form_label,
lo_f_flow TYPE REF TO cl_salv_form_layout_flow.
*
* footer object
CREATE OBJECT lo_footer.
*
* information in bold
lo_f_label = lo_footer->create_label( row = 1 column = 1 ).
lo_f_label->set_text( 'Footer .. here it goes' ).
*
* tabular information
lo_f_flow = lo_footer->create_flow( row = 2 column = 1 ).
lo_f_flow->create_text( text = 'This is text of flow in footer' ).
*
lo_f_flow = lo_footer->create_flow( row = 3 column = 1 ).
lo_f_flow->create_text( text = 'Footer number' ).
*
lo_f_flow = lo_footer->create_flow( row = 3 column = 2 ).
lo_f_flow->create_text( text = 1 ).
*
* Online footer
co_alv->set_end_of_list( lo_footer ).
*
* Footer in print
co_alv->set_end_of_list_print( lo_footer ).
*
ENDMETHOD. "set_end_of_page
Set DISPLAY SETTINGS LIKE SET THE ZEBRA STYLE, TITLE OF THE ALV
METHOD set_display_setting.
*
DATA: lo_display TYPE REF TO cl_salv_display_settings.
*
* get display object
lo_display = co_alv->get_display_settings( ).
*
* set ZEBRA pattern
lo_display->set_striped_pattern( 'X' ).
*
* Title to ALV
lo_display->set_list_header( 'ALV Test for Display Settings' ).
*
ENDMETHOD. "SET_DISPLAY_SETTING
METHOD set_columns.
*
*...Get all the Columns
DATA: lo_cols TYPE REF TO cl_salv_columns.
lo_cols = o_alv->get_columns( ).
*
* set the Column optimization
lo_cols->set_optimize( 'X' ).
*
*...Process individual columns
DATA: lo_column TYPE REF TO cl_salv_column.
*
* Change the properties of the Columns KUNNR
TRY.
lo_column = lo_cols->get_column( 'KUNNR' ).
lo_column->set_long_text( 'Sold-To Party' ).
lo_column->set_medium_text( 'Sold-To Party' ).
lo_column->set_short_text( 'Sold-To' ).
lo_column->set_output_length( 10 ).
CATCH cx_salv_not_found. "#EC NO_HANDLER
ENDTRY.
*
ENDMETHOD. "SET_COLUMNS
METHOD set_hotspot_vbeln.
*
*...HotSpot
DATA: lo_cols_tab TYPE REF TO cl_salv_columns_table,
lo_col_tab TYPE REF TO cl_salv_column_table.
*
* get Columns object
lo_cols_tab = co_alv->get_columns( ).
*
* Get VBELN column
TRY.
lo_col_tab ?= lo_cols_tab->get_column( 'VBELN' ).
CATCH cx_salv_not_found.
ENDTRY.
*
* Set the HotSpot for VBELN Column
TRY.
CALL METHOD lo_col_tab->set_cell_type
EXPORTING
value = if_salv_c_cell_type=>hotspot.
.
CATCH cx_salv_data_error .
ENDTRY.
*
*...Events
DATA: lo_events TYPE REF TO cl_salv_events_table.
*
* all events
lo_events = o_alv->get_event( ).
*
* event handler
SET HANDLER co_report->on_link_click FOR lo_events.
*
ENDMETHOD. "set_hotspot_vbeln
*
* Handles the UI on the VBELN (HotSpot)
METHOD on_link_click.
*
DATA: la_vbak TYPE ty_vbak.
*
* Get the Sales Order number from the table
READ TABLE lo_report->t_vbak INTO la_vbak INDEX row.
IF la_vbak-vbeln IS NOT INITIAL.
MESSAGE i398(00) WITH 'You have selected' la_vbak-vbeln.
ENDIF.
*
ENDMETHOD. "on_link_click
METHOD set_sorts.
*
DATA: lo_sort TYPE REF TO cl_salv_sorts.
*
* get Sort object
lo_sort = co_alv->get_sorts( ).
*
* Set the SORT on the AUART with Subtotal
TRY.
CALL METHOD lo_sort->add_sort
EXPORTING
columnname = 'AUART'
subtotal = if_salv_c_bool_sap=>true.
CATCH cx_salv_not_found . "#EC NO_HANDLER
CATCH cx_salv_existing . "#EC NO_HANDLER
CATCH cx_salv_data_error . "#EC NO_HANDLER
ENDTRY.
*
ENDMETHOD.
METHOD set_aggregations.
*
DATA: lo_aggrs TYPE REF TO cl_salv_aggregations.
*
lo_aggrs = co_alv->get_aggregations( ).
*
* Add TOTAL for COLUMN NETWR
TRY.
CALL METHOD lo_aggrs->add_aggregation
EXPORTING
columnname = 'NETWR'
aggregation = if_salv_c_aggregation=>total.
CATCH cx_salv_data_error . "#EC NO_HANDLER
CATCH cx_salv_not_found . "#EC NO_HANDLER
CATCH cx_salv_existing . "#EC NO_HANDLER
ENDTRY.
*
* Bring the total line to top
lo_aggrs->set_aggregation_before_items( ).
*
ENDMETHOD. "set_aggregations
*
*
*$*$*.....CODE_ADD_3 - End....................................3..*$*$*
*
*
ENDCLASS. "lcl_report IMPLEMENTATION
*&--------------------------------------------------------------------
-*
*& This code snippet will show how to use the CL_SALV_TABLE to
*& generate the ALV and COLORs for Column, Row and Specific Cell
*&--------------------------------------------------------------------
-*
REPORT ztest_oo_alv_color.
*
*---------------------------------------------------------------------
-*
* CLASS lcl_report DEFINITION
*---------------------------------------------------------------------
-*
CLASS lcl_report DEFINITION.
*
PUBLIC SECTION.
*
* Final output table
TYPES: BEGIN OF ty_vbak,
vbeln TYPE vbak-vbeln,
erdat TYPE erdat,
auart TYPE auart,
kunnr TYPE kunnr,
t_color TYPE lvc_t_scol,
END OF ty_vbak.
TYPES: ty_t_vbak TYPE STANDARD TABLE OF ty_vbak.
*
DATA: t_vbak TYPE STANDARD TABLE OF ty_vbak.
*
* ALV reference
DATA: o_alv TYPE REF TO cl_salv_table.
*
METHODS:
* data selection
get_data,
*
* Generating output
generate_output.
*
*$*$*.....CODE_ADD_1 - Begin..................................1..*$*$*
*
* In this section we will define the private methods which can
* be implemented to set the properties of the ALV and can be
* called in the
*
PRIVATE SECTION.
METHODS:
set_pf_status
CHANGING
co_alv TYPE REF TO cl_salv_table.
*
METHODS:
set_colors
CHANGING
co_alv TYPE REF TO cl_salv_table
ct_vbak TYPE ty_t_vbak.
*
*$*$*.....CODE_ADD_1 - End....................................1..*$*$*
*
ENDCLASS. "lcl_report DEFINITION
*
*
START-OF-SELECTION.
DATA: lo_report TYPE REF TO lcl_report.
*
CREATE OBJECT lo_report.
*
lo_report->get_data( ).
*
lo_report->generate_output( ).
*
*---------------------------------------------------------------------
-*
* CLASS lcl_report IMPLEMENTATION
*---------------------------------------------------------------------
-*
CLASS lcl_report IMPLEMENTATION.
*
METHOD get_data.
* data selection
SELECT vbeln erdat auart kunnr
INTO CORRESPONDING FIELDS OF TABLE t_vbak
FROM vbak
UP TO 20 ROWS.
*
ENDMETHOD. "get_data
*
*.....................................................................
..
METHOD generate_output.
* New ALV instance
* We are calling the static Factory method which will give back
* the ALV object reference.
*
* exception class
DATA: lx_msg TYPE REF TO cx_salv_msg.
TRY.
cl_salv_table=>factory(
IMPORTING
r_salv_table = o_alv
CHANGING
t_table = t_vbak ).
CATCH cx_salv_msg INTO lx_msg.
ENDTRY.
*
*$*$*.....CODE_ADD_2 - Begin..................................2..*$*$*
*
* In this area we will call the methods which will set the
* different properties to the ALV
*
* Set default PF status
CALL METHOD set_pf_status
CHANGING
co_alv = o_alv.
*
* Set the colors to ALV display
CALL METHOD set_colors
CHANGING
co_alv = o_alv
ct_vbak = t_vbak.
*$*$*.....CODE_ADD_2 - End....................................2..*$*$*
*
*
* Displaying the ALV
* Here we will call the DISPLAY method to get the output on the scre
en
o_alv->display( ).
*
ENDMETHOD. "generate_output
*
*$*$*.....CODE_ADD_3 - Begin..................................3..*$*$*
*
* In this area we will implement the methods which are defined in
* the class definition
*
*
METHOD set_pf_status.
*
DATA: lo_functions TYPE REF TO cl_salv_functions_list.
*
lo_functions = co_alv->get_functions( ).
lo_functions->set_default( abap_true ).
*
ENDMETHOD. "set_pf_status
*
METHOD set_colors.
*
*.....Color for COLUMN.....
DATA: lo_cols_tab TYPE REF TO cl_salv_columns_table,
lo_col_tab TYPE REF TO cl_salv_column_table.
DATA: ls_color TYPE lvc_s_colo. " Colors strucutre
*
* get Columns object
lo_cols_tab = co_alv->get_columns( ).
*
INCLUDE <color>.
*
* Get ERDAT column & set the yellow Color for it
TRY.
lo_col_tab ?= lo_cols_tab->get_column( 'ERDAT' ).
ls_color-col = col_total.
lo_col_tab->set_color( ls_color ).
CATCH cx_salv_not_found.
ENDTRY.
*
*.......Color for Specific Cell & Rows.................
* Applying color on the 3rd Row and Column AUART
* Applying color on the Entire 5th Row
*
DATA: lt_s_color TYPE lvc_t_scol,
ls_s_color TYPE lvc_s_scol,
la_vbak LIKE LINE OF ct_vbak,
l_count TYPE i.
*
LOOP AT ct_vbak INTO la_vbak.
l_count = l_count + 1.
CASE l_count.
* Apply RED color to the AUART Cell of the 3rd Row
WHEN 3.
ls_s_color-fname = 'AUART'.
ls_s_color-color-col = col_negative.
ls_s_color-color-int = 0.
ls_s_color-color-inv = 0.
APPEND ls_s_color TO lt_s_color.
CLEAR ls_s_color.
*
* Apply GREEN color to the entire row # 5
* For entire row, we don't pass the Fieldname
WHEN 5.
ls_s_color-color-col = col_positive.
ls_s_color-color-int = 0.
ls_s_color-color-inv = 0.
APPEND ls_s_color TO lt_s_color.
CLEAR ls_s_color.
ENDCASE.
* Modify that data back to the output table
la_vbak-t_color = lt_s_color.
MODIFY ct_vbak FROM la_vbak.
CLEAR la_vbak.
CLEAR lt_s_color.
ENDLOOP.
*
* We will set this COLOR table field name of the internal table to
* COLUMNS tab reference for the specific colors
TRY.
lo_cols_tab->set_color_column( 'T_COLOR' ).
CATCH cx_salv_data_error. "#EC NO_HANDLER
ENDTRY.
*
ENDMETHOD. "set_colors
*
*
*
*$*$*.....CODE_ADD_3 - End....................................3..*$*$*
ENDCLASS. "lcl_report IMPLEMENTATION
REPORT zdemo_alv_edit.
*&---------------------------------------------------------------------*
*& Report ZDEMO_ALV_EDIT *
*& *
*&---------------------------------------------------------------------*
*& *
*& Example of a simple ALV Grid Report *
*& ................................... *
*& *
*& The basic ALV grid, Enhanced to display specific fields as *
*& editable depending on field value *
*&---------------------------------------------------------------------*
*REPORT ZDEMO_ALVGRID_EDIT .
TABLES: ekko.
TYPE-POOLS: slis. "ALV Declarations
*Data Declaration
*----------------
TYPES: BEGIN OF t_ekko,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
statu TYPE ekpo-statu,
aedat TYPE ekpo-aedat,
matnr TYPE ekpo-matnr,
menge TYPE ekpo-menge,
meins TYPE ekpo-meins,
netpr TYPE ekpo-netpr,
peinh TYPE ekpo-peinh,
field_style TYPE lvc_t_styl, "FOR DISABLE
END OF t_ekko.
DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
wa_ekko TYPE t_ekko.
*ALV data declarations
DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE.
DATA: it_fieldcat TYPE lvc_t_fcat, "slis_t_fieldcat_alv WITH HEADER LINE,
wa_fieldcat TYPE lvc_s_fcat,
gd_tab_group TYPE slis_t_sp_group_alv,
gd_layout TYPE lvc_s_layo, "slis_layout_alv,
gd_repid LIKE sy-repid.
************************************************************************
*Start-of-selection.
START-OF-SELECTION.
PERFORM data_retrieval.
PERFORM set_specific_field_attributes.
PERFORM build_fieldcatalog.
PERFORM build_layout.
PERFORM display_alv_report.
*&---------------------------------------------------------------------*
*& Form BUILD_FIELDCATALOG
*&---------------------------------------------------------------------*
* Build Fieldcatalog for ALV Report
*----------------------------------------------------------------------*
FORM build_fieldcatalog.
wa_fieldcat-fieldname = 'EBELN'.
wa_fieldcat-scrtext_m = 'Purchase Order'.
wa_fieldcat-col_pos = 0.
wa_fieldcat-outputlen = 10.
wa_fieldcat-emphasize = 'X'.
wa_fieldcat-key = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'EBELP'.
wa_fieldcat-scrtext_m = 'PO Item'.
wa_fieldcat-col_pos = 1.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'STATU'.
wa_fieldcat-scrtext_m = 'Status'.
wa_fieldcat-col_pos = 2.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'AEDAT'.
wa_fieldcat-scrtext_m = 'Item change date'.
wa_fieldcat-col_pos = 3.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'MATNR'.
wa_fieldcat-scrtext_m = 'Material Number'.
wa_fieldcat-col_pos = 4.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'MENGE'.
wa_fieldcat-scrtext_m = 'PO quantity'.
wa_fieldcat-col_pos = 5.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'MEINS'.
wa_fieldcat-scrtext_m = 'Order Unit'.
wa_fieldcat-col_pos = 6.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'NETPR'.
wa_fieldcat-scrtext_m = 'Net Price'.
wa_fieldcat-edit = 'X'. "sets whole column to be editable
wa_fieldcat-col_pos = 7.
wa_fieldcat-outputlen = 15.
wa_fieldcat-datatype = 'CURR'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'PEINH'.
wa_fieldcat-scrtext_m = 'Price Unit'.
wa_fieldcat-col_pos = 8.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
ENDFORM. " BUILD_FIELDCATALOG
*&---------------------------------------------------------------------*
*& Form BUILD_LAYOUT
*&---------------------------------------------------------------------*
* Build layout for ALV grid report
*----------------------------------------------------------------------*
FORM build_layout.
* Set layout field for field attributes(i.e. input/output)
gd_layout-stylefname = 'FIELD_STYLE'.
gd_layout-zebra = 'X'.
ENDFORM. " BUILD_LAYOUT
*&---------------------------------------------------------------------*
*& Form DISPLAY_ALV_REPORT
*&---------------------------------------------------------------------*
* Display report using ALV grid
*----------------------------------------------------------------------*
FORM display_alv_report.
gd_repid = sy-repid.
* call function 'REUSE_ALV_GRID_DISPLAY'
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
i_callback_program = gd_repid
* i_callback_user_command = 'USER_COMMAND'
is_layout_lvc = gd_layout
it_fieldcat_lvc = it_fieldcat
i_save = 'X'
TABLES
t_outtab = it_ekko
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " DISPLAY_ALV_REPORT
*&---------------------------------------------------------------------*
*& Form DATA_RETRIEVAL
*&---------------------------------------------------------------------*
* Retrieve data form EKPO table and populate itab it_ekko
*----------------------------------------------------------------------*
FORM data_retrieval.
SELECT ebeln ebelp statu aedat matnr menge meins netpr peinh
UP TO 10 ROWS
FROM ekpo
INTO CORRESPONDING FIELDS OF TABLE it_ekko.
ENDFORM. " DATA_RETRIEVAL
*&---------------------------------------------------------------------*
*& Form set_specific_field_attributes
*&---------------------------------------------------------------------*
* populate FIELD_STYLE table with specific field attributes
*----------------------------------------------------------------------*
FORM set_specific_field_attributes .
DATA ls_stylerow TYPE lvc_s_styl .
DATA lt_styletab TYPE lvc_t_styl .
* Populate style variable (FIELD_STYLE) with style properties
*
* The NETPR field/column has been set to editable in the fieldcatalog...
* The following code sets it to be disabled(display only) if 'NETPR'
* is gt than 10.
LOOP AT it_ekko INTO wa_ekko.
IF wa_ekko-netpr GT 10.
ls_stylerow-fieldname = 'NETPR' .
ls_stylerow-style = cl_gui_alv_grid=>mc_style_disabled.
"set field to disabled
APPEND ls_stylerow TO wa_ekko-field_style.
MODIFY it_ekko FROM wa_ekko.
ENDIF.
ENDLOOP.
ENDFORM. " set_specific_field_attributes