on 06-28-2007 8:08 AM
hi experts,
i hav never used alv. how can i use alv ?what is the purpose of alv?if possible give related examples.
regards.
Prakash
Hi Prakash,
ALV (ABAP List Viewer) is one of the fascinating tools provided by SAP for displaying reports. This tool has the merit of reducing the development time of reports by providing standard interfaces (Function Modules). These standard interfaces provide GUI and formatting options for the on screen display.
<u><b>Check out following Link for ALV using OO concepts</b></u>
Check the following program also.
&----
Global data definitions for ALV
&----
&----
Object reference
&----
ALV Grid instance reference
DATA: gr_alvgrid TYPE REF TO cl_gui_alv_grid,
Custom container instance reference
gr_ccontainer TYPE REF TO cl_gui_custom_container.
&----
Internal Table
&----
Field catalog table
DATA: gt_fieldcat TYPE lvc_t_fcat,
Internal table holding list data
gt_list TYPE STANDARD TABLE OF sflight.
&----
Work area
&----
Layout structure
DATA: gs_layout TYPE lvc_s_layo,
Field catalog structure
gs_fcat TYPE lvc_s_fcat.
&----
Variables
&----
DATA: ok_code TYPE sy-ucomm,
save_ok TYPE sy-ucomm,
Name of the custom control added on the screen
gv_custom_control_name TYPE scrfname VALUE 'CC_ALV'.
&----
Calling the screen where ALV output is displayed
&----
CALL SCREEN 100.
&----
*& Module STATUS_0100 OUTPUT
&----
PBO
----
MODULE status_0100 OUTPUT.
PF Status
SET PF-STATUS 'MENU'.
ALV display
PERFORM display_alv.
ENDMODULE. " STATUS_0100 OUTPUT
&----
*& Module USER_COMMAND_0100 INPUT
&----
PAI
----
MODULE user_command_0100 INPUT.
save_ok = ok_code.
CLEAR ok_code.
IF save_ok EQ 'EXIT'.
LEAVE PROGRAM.
ENDIF.
ENDMODULE. " USER_COMMAND_0100 INPUT
&----
*& Form display_alv
&----
ALV display
----
FORM display_alv.
PERFORM get_data.
PERFORM create_alv.
ENDFORM. " display_alv
&----
*& Form get_data
&----
Fetch data to be displayed in the list
----
FORM get_data.
SELECT * FROM sflight
INTO TABLE gt_list.
ENDFORM. " get_data
&----
*& Form create_alv
&----
Create and set or Refresh ALV
----
FORM create_alv.
Checking whether an instance of the container (or ALV Grid) exists.
IF gr_alvgrid IS INITIAL.
If not, creating and setting ALV for the first display.
Creating custom container instance
CREATE OBJECT gr_ccontainer
EXPORTING
container_name = gv_custom_control_name
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
OTHERS = 6.
Creating ALV Grid instance
CREATE OBJECT gr_alvgrid
EXPORTING
i_parent = gr_ccontainer
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
OTHERS = 5.
Preparing field catalog.
PERFORM prepare_field_catalog CHANGING gt_fieldcat.
Preparing layout structure
PERFORM prepare_layout CHANGING gs_layout.
Method to display ALV grid
CALL METHOD gr_alvgrid->set_table_for_first_display
EXPORTING
is_layout = gs_layout
CHANGING
it_outtab = gt_list
it_fieldcatalog = gt_fieldcat
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
ELSE.
If an instance of the container (or ALV Grid) exists, refreshing it.
CALL METHOD gr_alvgrid->refresh_table_display
EXCEPTIONS
finished = 1
OTHERS = 2.
ENDIF.
ENDFORM. " create_alv
&----
*& Form prepare_field_catalog
&----
Subroutine to populate field catalog
----
<--P_GT_FIELDCAT Table to describe the field catalog
----
FORM prepare_field_catalog CHANGING p_gt_fieldcat TYPE lvc_t_fcat.
Generating the field catalog semi automatically
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'SFLIGHT'
CHANGING
ct_fieldcat = p_gt_fieldcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
LOOP AT p_gt_fieldcat INTO gs_fcat.
CASE gs_fcat-fieldname.
WHEN 'CARRID'.
gs_fcat-outputlen = '10'.
gs_fcat-coltext = 'Airline Carrier ID'.
MODIFY p_gt_fieldcat FROM gs_fcat.
WHEN 'FLDATE'.
gs_fcat-just = 'C'.
gs_fcat-hotspot = 'X'.
MODIFY p_gt_fieldcat FROM gs_fcat.
ENDCASE.
ENDLOOP.
ENDFORM. " prepare_field_catalog
&----
*& Form prepare_layout
&----
Preparing layout structure
----
<--P_GS_LAYOUT Layout structure
----
FORM prepare_layout CHANGING p_gs_layout TYPE lvc_s_layo.
p_gs_layout-zebra = 'X' .
p_gs_layout-grid_title = 'Flight Info System'.
p_gs_layout-smalltitle = 'X'.
ENDFORM. " prepare_layout
__________________________________________________________________
<b>Award points if found useful.</b>
Regards
Indrajit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
Refer this
Also, you can use search function in SDN to know the postings related to ALV.
Regards
Raj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
go through alv robot........
Actually there is no transaction for this.
There is a link wherein u can go, fill in the detials and get the ready ABAP code.
Just copy paste it in SE38 and the program is ready 4 u.
The link is www.ALVROBOT.com.ar.
Hi Prakash,
goto SE80
give the package as SLIS
and expand the <b>Programs</b>
you will get lot many examples on alv
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.