************************************************************************
* AUTHOR : Ravi Shankar Rajan
* FIRM : GMI
* DATE : 08/2006
* PURPOSE : Test report using the ALV OM model
* TASK ID :
************************************************************************
* Required fields - 12
TYPES : exception TYPE char1.
TYPES: aktiv TYPE aktivd. "Asset capitalization date
TYPES: anln1 TYPE anln1. "Main Asset Number - key(non-editable)
TYPES: anln2 TYPE anln2. "Asset Subnumber - key(non-editable)
TYPES: bukrs TYPE bukrs. "Company Code - key(non-editable)
TYPES: anlkl TYPE anlkl. "Asset class
TYPES: ord42 TYPE ord42. "Smart entity
TYPES: gdlgrp TYPE gdlgrp. "Tax Facility Code
TYPES: kostl TYPE kostl. "Cost Center
TYPES: werks TYPE werks_d. "Plant
TYPES: stort TYPE stort. "Asset location
TYPES: txt50 TYPE txa50_anlt. "Asset description
TYPES: posnr TYPE am_posnr. "WBS element - internal key (numc 8)
TYPES: posid TYPE am_posid. "WBS element - external key (char 24)
* Optional fields - 17
TYPES: sernr TYPE sernr. "Serial number
TYPES: invnr TYPE invnr_anla. "Inventory number
TYPES: invzu TYPE invzu_anla. "Supplementary inventory note
TYPES: kfzkz TYPE am_kfzkz. "License plate no. of vehichle
TYPES: ord41 TYPE ord41. "Platform
TYPES: ord43 TYPE ord43. "Class Code
TYPES: ord44 TYPE ord44. "Location Type
TYPES: liefe TYPE liefe. "Name of asset supplier
TYPES: herst TYPE herst. "Manufacturer of asset
TYPES: typbz TYPE typbz_anla. "Asset type name
TYPES: izwek TYPE izwek. "Reason for investment
TYPES: ivdat TYPE ivdat_anla. "Last inventory date
TYPES: gsber TYPE gsber. "Business Area
TYPES: kostlv TYPE kostlv. "Cost center responsible for asset
TYPES: raumn TYPE raumnr. "Room
TYPES: fiamt TYPE fiamt. "Local tax office
TYPES: txa50 TYPE txa50_more. "Additional asset description
* Layout style
TYPES: celltab TYPE lvc_t_styl. "Layout style
TYPES : aggr TYPE c .
TYPES : t_color TYPE lvc_t_scol.
TYPES: END OF t_asset.
TYPES: BEGIN OF t_prps.
TYPES: posid TYPE ps_posid. "WBS Element
TYPES: prart TYPE ps_prart. "Project type
TYPES: END OF t_prps.
DATA: gt_asset TYPE STANDARD TABLE OF t_asset.
DATA: gt_table TYPE REF TO cl_salv_table.
SELECT-OPTIONS s_user FOR anla-ernam MATCHCODE OBJECT user_addr
NO INTERVALS NO-EXTENSION MODIF ID m2. "User name
SELECT-OPTIONS s_date FOR anla-erdat MODIF ID m2. "Date
PARAMETERS p_pspid2 TYPE ps_pspid MODIF ID m2. "Project definition
SELECTION-SCREEN SKIP 2.
PARAMETERS p_max TYPE i DEFAULT 200 MODIF ID m2. "Maximum number of records
DATA : gv_records TYPE sy-dbcnt.
CONSTANTS: gc_true TYPE sap_bool VALUE 'X',
gc_false TYPE sap_bool VALUE space.
PARAMETERS : p_var TYPE slis_vari. "Layout Setting
DATA: gs_asset TYPE t_asset,
gv_count TYPE i.
CLASS lcl_handle_events DEFINITION DEFERRED.
DATA: gr_events TYPE REF TO lcl_handle_events.
*---------------------------------------------------------------------*
* CLASS lcl_handle_events DEFINITION
*---------------------------------------------------------------------*
* 5.1 define a local class for handling events of cl_salv_table
*---------------------------------------------------------------------*
CLASS lcl_handle_events DEFINITION.
PUBLIC SECTION.
METHODS:
on_user_command FOR EVENT added_function OF cl_salv_events
IMPORTING e_salv_function,
on_before_salv_function FOR EVENT before_salv_function OF
cl_salv_events
IMPORTING e_salv_function,
on_after_salv_function FOR EVENT after_salv_function OF cl_salv_events
IMPORTING e_salv_function,
on_double_click FOR EVENT double_click OF cl_salv_events_table
IMPORTING row column,
on_link_click FOR EVENT link_click OF cl_salv_events_table
IMPORTING row column.
ENDCLASS. "lcl_handle_events DEFINITION
*---------------------------------------------------------------------*
* CLASS lcl_handle_events IMPLEMENTATION
*---------------------------------------------------------------------*
* 5.2 implement the events for handling the events of cl_salv_table
*---------------------------------------------------------------------*
CLASS lcl_handle_events IMPLEMENTATION.
METHOD on_user_command.
PERFORM show_function_info USING e_salv_function 'Own Function'.
ENDMETHOD. "on_user_command
METHOD on_before_salv_function.
PERFORM show_function_info USING e_salv_function 'Before ALV Function'.
ENDMETHOD. "on_before_salv_function
METHOD on_after_salv_function.
PERFORM show_function_info USING e_salv_function 'After ALV Function'.
ENDMETHOD. "on_after_salv_function
METHOD on_double_click.
PERFORM show_cell_info USING row column 'Execute a Function, Double-
Click or Hotspot-Click'.
ENDMETHOD. "on_double_click
METHOD on_link_click.
PERFORM show_cell_info USING row column 'Execute a Function, Double-
Click or Hotspot-Click'.
ENDMETHOD. "on_single_click
ENDCLASS. "lcl_handle_events IMPLEMENTATION
INITIALIZATION.
PERFORM get_default_layout.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_var.
PERFORM f4_layouts.
*Interactive events
*... 6 register to the events of cl_salv_table
DATA: lr_events TYPE REF TO cl_salv_events_table.
lr_events = gt_table->get_event( ).
CREATE OBJECT gr_events.
*... 6.1 register to the event USER_COMMAND
SET HANDLER gr_events->on_user_command FOR lr_events.
*... 6.2 register to the event BEFORE_SALV_FUNCTION
SET HANDLER gr_events->on_before_salv_function FOR lr_events.
*... 6.3 register to the event AFTER_SALV_FUNCTION
SET HANDLER gr_events->on_after_salv_function FOR lr_events.
*... 6.4 register to the event DOUBLE_CLICK
SET HANDLER gr_events->on_double_click FOR lr_events.
**... 6.5 register to the event LINK_CLICK
* SET HANDLER gr_events->on_link_click FOR lr_events.
*... set list title
DATA: lr_display_settings TYPE REF TO cl_salv_display_settings,
l_title TYPE lvc_title.
value = 'X'.
.
*Process the variant for future save
PERFORM process_variant.
gt_table->display( ).
ENDFORM. " display_grid
*&---------------------------------------------------------------------*
*& Form create_alv_form_content_tol
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->I_PRINT text
* -->CR_CONTENT text
*----------------------------------------------------------------------*
FORM create_alv_form_content_tol
USING i_print TYPE sap_bool
CHANGING cr_content TYPE REF TO cl_salv_form_element.
DATA: lr_header TYPE REF TO cl_salv_form_header_info,
l_text TYPE string.
*... create header information
CASE i_print.
WHEN space.
CONCATENATE 'TOP_OF_LIST' text-h01 INTO l_text SEPARATED BY space.
WHEN gc_true.
CONCATENATE 'TOP_OF_LIST_PRINT' text-h01 INTO l_text SEPARATED BY
space.
ENDCASE.
CREATE OBJECT lr_header
EXPORTING
text = l_text
tooltip = l_text.
cr_content = lr_header.
ENDFORM. " create_alv_form_content_tol
*&---------------------------------------------------------------------*
*& Form create_top_of_list
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->LR_GRID text
*----------------------------------------------------------------------*
FORM create_top_of_list CHANGING lr_grid TYPE REF TO
cl_salv_form_layout_grid.
DATA : lr_grid1 TYPE REF TO cl_salv_form_layout_grid,
lr_flow TYPE REF TO cl_salv_form_layout_flow,
lr_label TYPE REF TO cl_salv_form_label,
lr_text TYPE REF TO cl_salv_form_text,
l_text TYPE string.
*ENDIF.
ENDFORM. "create_top_of_list
*&--------------------------------------------------------------------*
*& Form show_cell_info
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM show_cell_info USING i_row TYPE i
i_column TYPE lvc_fname
i_text TYPE string.
DATA: l_row_string TYPE string,
l_col_string TYPE string,
l_row TYPE char128.
WRITE i_row TO l_row LEFT-JUSTIFIED.
CONCATENATE text-i02 l_row INTO l_row_string SEPARATED BY space.
CONCATENATE text-i03 i_column INTO l_col_string SEPARATED BY space.
MESSAGE i000(0k) WITH i_text l_row_string l_col_string.
ENDFORM. " show_cell_info
*&---------------------------------------------------------------------*
*& Form show_function_info
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->I_FUNCTION text
* -->I_TEXT text
*----------------------------------------------------------------------*
FORM show_function_info USING i_function TYPE salv_de_function
i_text TYPE string.
DATA: l_string TYPE string.
CONCATENATE i_text i_function INTO l_string SEPARATED BY space.
MESSAGE i000(0k) WITH l_string.
ENDFORM. " show_function_info
*&---------------------------------------------------------------------*
*& Form process_variant
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_P_VAR text
*----------------------------------------------------------------------*
FORM process_variant.
DATA : lr_layout TYPE REF TO cl_salv_layout,
ls_key TYPE salv_s_layout_key.
CALL METHOD gt_table->get_layout
RECEIVING
value = lr_layout.
*Set the layout key
ls_key-report = sy-cprog.
CALL METHOD lr_layout->set_key
EXPORTING
value = ls_key.
*Set usage of default layout
CALL METHOD lr_layout->set_default
EXPORTING
value = abap_true.
*Set layout save restriction
CALL METHOD lr_layout->set_save_restriction
EXPORTING
value = if_salv_c_layout=>restrict_none.
*Set initial layout
IF p_var IS NOT INITIAL.
CALL METHOD lr_layout->set_initial_layout
EXPORTING
value = p_var.
ENDIF.
ENDFORM. " process_variant
*&---------------------------------------------------------------------*
*& Form f4_layouts
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM f4_layouts .
DATA :
ls_layout TYPE salv_s_layout_info,
ls_key TYPE salv_s_layout_key.
ENDFORM. " f4_layouts
*&---------------------------------------------------------------------*
*& Form get_default_layout
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_P_VAR text
*----------------------------------------------------------------------*
FORM get_default_layout.
DATA :
ls_layout TYPE salv_s_layout_info,
ls_key TYPE salv_s_layout_key.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.