*&---------------------------------------------------------------------*
*& Report Z_ALV_SKELETON
*&
*& Author: Sheila Titchener
*& Date: December 2006
*&---------------------------------------------------------------------*
*& ALV Grid control skeleton using OO Methods
*&
*&---------------------------------------------------------------------*
REPORT Z_ALV_SKELETON .
*&---------------------------------------------------------------------*
*&---------------------------------------------------------------------*
* internal tables
DATA: i_tab TYPE TABLE OF zchangereq,
w_tab TYPE zchangereq.
* display field details
DATA: w_field_cat_wa TYPE lvc_s_fcat. " Field Catalog work area
*
*&---------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-020.
*&---------------------------------------------------------------------*
PARAMETERS: p_outs RADIOBUTTON GROUP g1,
p_comp RADIOBUTTON GROUP g1.
SELECTION-SCREEN END OF BLOCK b1.
*&---------------------------------------------------------------------*
*MACROS
*&---------------------------------------------------------------------*
DEFINE add_field.
* &1 = FIELDNAME &2 = HEADING &3 = Key field flag
clear w_field_cat_wa.
w_field_cat_wa-fieldname = &1.
* lw_field_cat_wa-ref_table = p_ref_table.
* lw_field_cat_wa-inttype = p_inttype.
* lw_field_cat_wa-decimals = p_decimals.
* lw_field_cat_wa-coltext = p_coltext.
* lw_field_cat_wa-seltext = p_seltext.
* lw_field_cat_wa-do_sum = p_do_sum.
* lw_field_cat_wa-no_out = p_no_out.
* lw_field_cat_wa-col_pos = p_col_pos.
* lw_field_cat_wa-reptext = p_coltext.
* lw_field_cat_wa-colddictxt = p_colddictxt.
w_field_cat_wa-scrtext_m = &2.
w_field_cat_wa-key = &3.
append w_field_cat_wa to i_field_cat.
END-OF-DEFINITION.
*-----------------------------------------------------------------------
* ALV specific Declarations...........................................
*-----------------------------------------------------------------------
* ALV specific Internal table declarations.............................
DATA: i_field_cat TYPE lvc_t_fcat, " Field catalogue
i_alv_sort TYPE lvc_t_sort. " Sort table
* ALV variables........................................................
DATA: w_alv_layout TYPE lvc_s_layo, " ALV Layout
w_alv_save TYPE c, " ALV save
w_alv_variant TYPE disvariant. " ALV Variant
* ALV Class definitions................................................
*-----------------------------------------------------------------------
CLASS lcl_event_handler DEFINITION.
*-----------------------------------------------------------------------
PUBLIC SECTION.
METHODS: handle_double_click
FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING e_row e_column.
METHODS: handle_hotspot
FOR EVENT hotspot_click OF cl_gui_alv_grid
IMPORTING e_row_id e_column_id.
ENDCLASS. " CLASS LCL_EVENT_HANDLER DEF..
* ALV Class implementation............................................
* In the Event of a Double Click drill down to the corresponding CHANGE REQUEST
*-----------------------------------------------------------------------
CLASS lcl_event_handler IMPLEMENTATION.
*-----------------------------------------------------------------------
METHOD handle_double_click.
DATA: l_tab LIKE LINE OF i_tab.
CHECK e_row-rowtype(1) EQ space.
READ TABLE i_tab INDEX e_row-index INTO l_tab.
SET PARAMETER ID 'ZTY' FIELD l_tab-ztype.
SET PARAMETER ID 'ZCR' FIELD l_tab-zcref.
CALL TRANSACTION 'ZCRT' AND SKIP FIRST SCREEN.
ENDMETHOD. " HANDLE_DOUBLE_CLICK
* not working yet - hotspot seems to stay in the gui!!
METHOD handle_hotspot.
DATA: l_tab LIKE LINE OF i_tab.
CHECK e_row_id-rowtype(1) EQ space.
READ TABLE i_tab INDEX e_row_id-index INTO l_tab.
SET PARAMETER ID 'ZTY' FIELD l_tab-ztype.
SET PARAMETER ID 'ZCR' FIELD l_tab-zcref.
CALL TRANSACTION 'ZCRT' AND SKIP FIRST SCREEN.
ENDMETHOD. " HANDLE_DOUBLE_CLICK
ENDCLASS. " CLASS LCL_EVENT_HANDLER IMPL...
* ALV Grid Control definitions........................................
DATA:
* ALV Grid Control itself
o_grid TYPE REF TO cl_gui_alv_grid,
* Container to hold the ALV Grid Control
o_custom_container TYPE REF TO cl_gui_custom_container,
* Event handler (defined in the class above)
o_event_handler TYPE REF TO lcl_event_handler.
*&----------------------------------------------------------------------*
INITIALIZATION.
*&----------------------------------------------------------------------*
PERFORM create_field_catalogue. " Create ALV Field Catalog
*&---------------------------------------------------------------------*
START-OF-SELECTION.
*&---------------------------------------------------------------------*
* Outstanding requests
IF p_outs = 'X'.
SELECT * FROM zchangereq
INTO TABLE i_tab
WHERE zstatus < 99.
ELSE.
* completed requests
SELECT * FROM zchangereq
INTO TABLE i_tab
WHERE zstatus = 99.
ENDIF.
*&---------------------------------------------------------------------*
END-OF-SELECTION.
*&---------------------------------------------------------------------*
PERFORM list_output_to_alv. " Perform ALV Output operations
*----------------------------------------------------------------------*
* FORM LIST_OUTPUT_TO_ALV *
*----------------------------------------------------------------------*
* This subroutine is used to call the screen for ALV Output. *
*----------------------------------------------------------------------*
* There are no interface parameters to be passed to this subroutine. *
*----------------------------------------------------------------------*
FORM list_output_to_alv.
CALL SCREEN 100.
*
ENDFORM. " LIST_OUTPUT_TO_ALV
*----------------------------------------------------------------------*
* Module STATUS_0100 OUTPUT *
*----------------------------------------------------------------------*
* This is the PBO module which will be processed befor displaying the *
* ALV Output. *
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
SET PF-STATUS '0100'. " PF Status for ALV Output Screen
IF p_outs = 'X'.
SET TITLEBAR 'STD'.
ELSE.
* completed requests
SET TITLEBAR 'COMP'.
ENDIF.
CREATE OBJECT: o_custom_container
EXPORTING container_name = 'SC_GRID',
o_grid
EXPORTING i_parent = o_custom_container.
PERFORM define_alv_layout. " ALV Layout options definitions
PERFORM save_alv_layout_options. " save ALV layout options
PERFORM call_alv_grid. " Call ALV Grid Control
ENDMODULE. " STATUS_0100 OUTPUT
*----------------------------------------------------------------------*
* Module USER_COMMAND_0100 INPUT *
*----------------------------------------------------------------------*
* This is the PAI module which will be processed when the user performs*
* any operation from the ALV output. *
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
CASE sy-ucomm.
WHEN 'EXIT' OR 'BACK' OR 'CANC'.
* may need to do this so display is refreshed if other report selected
CALL METHOD o_custom_container->free.
SET SCREEN 0.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
*----------------------------------------------------------------------*
* FORM DEFINE_ALV_LAYOUT *
*----------------------------------------------------------------------*
* This subroutine is used to Define the ALV layout. *
*----------------------------------------------------------------------*
FORM define_alv_layout .
w_alv_layout-numc_total = 'X'. " Numc total line
w_alv_layout-cwidth_opt = 'X'. " Optimal column width
w_alv_layout-detailinit = 'X'. " Show values that are initial in
" detail list.
w_alv_layout-sel_mode = 'A'. " Column selection mode
w_alv_layout-no_merging = 'X'. " No merging while sorting columns
w_alv_layout-keyhot = 'X'.
ENDFORM. " DEFINE_ALV_LAYOUT
*----------------------------------------------------------------------*
* FORM SAVE_ALV_LAYOUT_OPTIONS *
*----------------------------------------------------------------------*
* This subroutine is used to Save the ALV layout options. *
*----------------------------------------------------------------------*
FORM save_alv_layout_options.
* See the ALV grid control documentation for full list of options
w_alv_save = 'A'.
w_alv_variant-report = sy-repid.
ENDFORM. " SAVE_ALV_LAYOUT_OPTIONS
*----------------------------------------------------------------------*
* FORM CALL_ALV_GRID *
*----------------------------------------------------------------------*
* This subroutine is used to call ALV Grid control for processing. *
*----------------------------------------------------------------------*
FORM call_alv_grid.
CALL METHOD o_grid->set_table_for_first_display
EXPORTING
is_layout = w_alv_layout
i_save = w_alv_save
is_variant = w_alv_variant
CHANGING
it_outtab = i_tab[]
it_sort = i_alv_sort
it_fieldcatalog = i_field_cat.
* Link used Events and Event Handler Methods
CREATE OBJECT o_event_handler.
* Set handler o_event_handler->handle_top_of_page for o_grid.
SET HANDLER o_event_handler->handle_double_click FOR o_grid.
ENDFORM. " CALL_ALV_GRID
*&---------------------------------------------------------------------*
*& Form create_field_catalogue
*&---------------------------------------------------------------------*
* set up field catalogue
*&---------------------------------------------------------------------*
FORM create_field_catalogue .
* Fieldname Heading Key?
*eg add_field 'ZTYPE' 'Type' 'X'.
ENDFORM. " create_field_catalogue
Tuesday, May 6, 2008
Sample SAP ABAP Program of ALV Grid control using OO Methods
Labels:
Sample ABAP Code Programs
Subscribe to:
Post Comments (Atom)
Blog Archive
-
▼
2008
(300)
-
▼
May
(80)
- Object oriented programming (OOP) All Steps
- Object oriented programming (OOP) Step2
- Object oriented programming (OOP) Step-by-step
- Object oriented programming (OOP) explained with a...
- Interview Question on BAPI, RFC, ABAP Objects, Tables
- The Other 50 ABAP Interview Faq's
- More than 100 ABAP Interview Faq's
- Events in Report
- Example: The IDoc Type ORDERS01
- Program for Outbound IDOC
- Basic Configuration in IDOC
- Sample ABAP Program to Upload table using new func...
- Sample ABAP Program for Submitting report with sel...
- Sample ABAP Program for Submitting report with sel...
- Sample ABAP Program for Sending SAP Mail
- Sample ABAP Program for Search Layout sets for giv...
- Sample ABAP Program for Sapscript PerForm Module
- Sample ABAP Program for Create IDOC
- Sample ABAP Program for Output file to application...
- Sample ABAP Program for Module Pool Skeleton
- Sample ABAP Program for Module Pool containing scr...
- Sample ABAP Program for MB1B Call Transaction
- Sample ABAP Program of Function Module to Convert ...
- Sample ABAP Program of FTP Function Module
- Sample ABAP Program to EXPORT LIST TO MEMORY
- Sample ABAP Program to Execute Unix command from w...
- Sample ABAP Program to Get Output in EXCEL
- Sample ABAP Program to Implement EDI
- Sample Program to dynamically change upload/downlo...
- Sample ABAP Program to download table using new fu...
- Sample ABAP Program to Download file to Presentati...
- Sample ABAP Program to display pop message to avoi...
- Sample ABAP Program of ALV Grid
- Sample ABAP Program of Dialogue Module Pool
- Sample ABAP Program to DIALOGUE FLOW LOGIC
- Sample ABAP Program to Delete a file from the appl...
- Sample ABAP Program to Compare to Unix or PC files...
- Sample ABAP Program to Colour cells in ALV
- Sample ABAP Program to Calculate difference betwee...
- Sample ABAP Program of BW User Exit
- Sample SAP ABAP Program to Browse a file on the ap...
- Sample SAP ABAP Program of ALV Grid control using ...
- SE30 - Runtime Analysis Tool
- List of System fields
- Write a report that displays the text 'Hello world...
- HR (Human Resource) Tutorials Free downloads
- FI (Financial) Tutorials Free downloads
- PM (Plant Maintenance) Tutorials Free downloads
- WM (Warehouse Management) Tutorials Free downloads
- QM (Quality Management) Tutorials Free downloads
- PP (Production Planning) Tutorials Free downloads
- SD (Sales and Distribution) Tutorials Free downloads
- MM (Material Management) Tutorials Free downloads
- IDOC INTRODUCTION & STRUCTURE
- Step-by-Step Guide for using LSMW to Update Custom...
- LIST of TABLES
- Transporting Objects and Standard Text from one cl...
- SAP R/3 INTERVIEW ARCHITECTURE QUESTIONS
- SAP TRANSACTIONS INTERVIEW QUESTIONS
- SAP MODULARIZATION INTERVIEW QUESTIONS
- SAP LOGICAL DATABASE INTERVIEW QUESTIONS
- SAP R/3 DATA DICTIONARY INTERVIEW QUESTIONS
- SAP BDC INTERVIEW QUESTIONS & ANSWERS
- SAP ABAP MENU PAINTER & SCREEN PAINTER Tutorials
- SAP ABAP WORKFLOW Tutorials PDF Free downloads
- SAP ABAP ITS Tutorials PDF Free downloads
- SAP ABAP EDI Tutorials PDF Free downloads
- SAP ABAP BAPI Tutorials PDF Free downloads
- SAP ABAP Change&Transport System Tutorials PDF Fre...
- SAP ABAP OBJECTS Tutorials PDF Free downloads
- SAP ABAP USER EXITS Tutorials PDF Free downloads
- SAP ABAP ALE Tutorials PDF Free downloads
- SAP ABAP IDOC Tutorials PDF Free downloads
- SAP ABAP LSMW Tutorials PDF Free downloads
- SAP ABAP BDC (Batch Data Communication) Tutorials ...
- SAP ABAP SAPSCRIPTS Tutorials Free downloads
- ALV Grid free download
- SAP ABAP INTERACTIVE REPORTING FAQs
- SAP ABAP REPORTING GENERAL
- SAP REPORTS FAQ
-
▼
May
(80)
No comments:
Post a Comment