2007 Dec 27 2:12 AM
Hi All,
I am new to ABAp and I haven't worked on ALV reports, so can you please explain me in detail what are ALV reports with some examples.
Any help will be appreciated.
Thanks,
Rajeev ..........
2007 Dec 27 5:55 AM
hi rajeev,
The brief notes below can give u an basic idea of what is ALV..
What is ALV programming in ABAP? When is this grid used in ABAP?
ALV is Application List viewer.
Sap provides a set of ALV (ABAP LIST VIEWER) function modules which can be put into use to embellish the output of a report. This set of ALV functions is used to enhance the readability and functionality of any report output. Cases arise in sap when the output of a report contains columns extending more than 255 characters in length.
In such cases, this set of ALV functions can help choose selected columns and arrange the different columns from a report output and also save different variants for report display. This is a very efficient tool for dynamically sorting and arranging the columns from a report output.
The report output can contain up to 90 columns in the display with the wide array of display options.
The commonly used ALV functions used for this purpose are;
1. REUSE_ALV_VARIANT_DEFAULT_GET
2. REUSE_ALV_VARIANT_F4
3. REUSE_ALV_VARIANT_EXISTENCE
4. REUSE_ALV_EVENTS_GET
5. REUSE_ALV_COMMENTARY_WRITE
6. REUSE_ALV_FIELDCATALOG_MERGE
7. REUSE_ALV_LIST_DISPLAY
8. REUSE_ALV_GRID_DISPLAY
9. REUSE_ALV_POPUP_TO_SELECT
Purpose of the above Functions are differ not all the functions are required in all the ALV Report.
But either no.7 or No.8 is there in the Program.
How you call this function in your report?
After completion of all the data fetching from the database and append this data into an Internal Table. say I_ITAB.
Then use follwing function module.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = 'Prog.name'
I_STRUCTURE_NAME = 'I_ITAB'
I_DEFAULT = 'X'
I_SAVE = 'A'
TABLES
T_OUTTAB = I_ITAB.
IF SY-SUBRC <> 0.
WRITE: 'SY-SUBRC: ', SY-SUBRC .
ENDIF.
ENDFORM. " GET_FINAL_DATA
Reward if helpful.
Thank you,
Regards.
Hi All,
I am new to ABAp and I haven't worked on ALV reports, so can you please explain me in detail what are ALV reports with some examples.
Any help will be appreciated.
Thanks,
Rajeev ..........
2007 Dec 27 2:15 AM
ALV is Application List viewer.
Sap provides a set of ALV (ABAP LIST VIEWER) function modules which can be put into use to embellish the output of a report. This set of ALV functions is used to enhance the readability and functionality of any report output. Cases arise in sap when the output of a report contains columns extending more than 255 characters in length.
In such cases, this set of ALV functions can help choose selected columns and arrange the different columns from a report output and also save different variants for report display. This is a very efficient tool for dynamically sorting and arranging the columns from a report output.
The commonly used ALV functions used for this purpose are;
1. REUSE_ALV_VARIANT_DEFAULT_GET
2. REUSE_ALV_VARIANT_F4
3. REUSE_ALV_VARIANT_EXISTENCE
4. REUSE_ALV_EVENTS_GET
5. REUSE_ALV_COMMENTARY_WRITE
6. REUSE_ALV_FIELDCATALOG_MERGE
7. REUSE_ALV_LIST_DISPLAY
8. REUSE_ALV_GRID_DISPLAY
9. REUSE_ALV_POPUP_TO_SELECT
ALV Demo program
BCALV_DEMO_HTML
BCALV_FULLSCREEN_DEMO ALV Demo: Fullscreen Mode
BCALV_FULLSCREEN_DEMO_CLASSIC ALV demo: Fullscreen mode
BCALV_GRID_DEMO Simple ALV Control Call Demo Program
BCALV_TREE_DEMO Demo for ALV tree control
BCALV_TREE_SIMPLE_DEMO
BC_ALV_DEMO_HTML_D0100
http://www.geocities.com/mpioud/Abap_programs.html
http://www.sapdevelopment.co.uk/reporting/reportinghome.htm
Simple ALV report
http://www.sapgenie.com/abap/controls/alvgrid.htm
http://wiki.ittoolbox.com/index.php/Code:Ultimate_ALV_table_toolbox
ALV
1. Please give me general info on ALV.
http://www.sapfans.com/forums/viewtopic.php?t=58286
http://www.sapfans.com/forums/viewtopic.php?t=76490
http://www.sapfans.com/forums/viewtopic.php?t=20591
http://www.sapfans.com/forums/viewtopic.php?t=66305 - this one discusses which way should you use - ABAP Objects calls or simple function modules.
2. How do I program double click in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=11601
http://www.sapfans.com/forums/viewtopic.php?t=23010
3. How do I add subtotals (I have problem to add them)...
http://www.sapfans.com/forums/viewtopic.php?t=20386
http://www.sapfans.com/forums/viewtopic.php?t=85191
http://www.sapfans.com/forums/viewtopic.php?t=88401
http://www.sapfans.com/forums/viewtopic.php?t=17335
4. How to add list heading like top-of-page in ABAP lists?
http://www.sapfans.com/forums/viewtopic.php?t=58775
http://www.sapfans.com/forums/viewtopic.php?t=60550
http://www.sapfans.com/forums/viewtopic.php?t=16629
5. How to print page number / total number of pages X/XX in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=29597 (no direct solution)
6. ALV printing problems. The favourite is: The first page shows the number of records selected but I don't need this.
http://www.sapfans.com/forums/viewtopic.php?t=64320
http://www.sapfans.com/forums/viewtopic.php?t=44477
7. How can I set the cell color in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=52107
8. How do I print a logo/graphics in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=81149
http://www.sapfans.com/forums/viewtopic.php?t=35498
http://www.sapfans.com/forums/viewtopic.php?t=5013
9. How do I create and use input-enabled fields in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=84933
http://www.sapfans.com/forums/viewtopic.php?t=69878
10. How can I use ALV for reports that are going to be run in background?
http://www.sapfans.com/forums/viewtopic.php?t=83243
http://www.sapfans.com/forums/viewtopic.php?t=19224
11. How can I display an icon in ALV? (Common requirement is traffic light icon).
http://www.sapfans.com/forums/viewtopic.php?t=79424
http://www.sapfans.com/forums/viewtopic.php?t=24512
12. How can I display a checkbox in ALV?
http://www.sapfans.com/forums/viewtopic.php?t=88376
http://www.sapfans.com/forums/viewtopic.php?t=40968
http://www.sapfans.com/forums/viewtopic.php?t=6919
Regards,
Maha
2007 Dec 27 2:39 AM
Hi,
ALV is nothing but we are doing the process of totals subtotal,calculations, layout designing these r do the process in normal reports it is to be late. so for that one sap created some predefined function modules for that one.
those function modules are
REUSE_ALV_GRID_DISPLAY
REUSE_ALV_POPUP_TO_SELECT
REUSE_ALV_VARIANT_EXISTENCE
REUSE_ALV_COMMENTARY_WRITE
REUSE_ALV_fieldcatalog_merge.
REUSE_ALV_events_get
ABAP LIST VIEWER
Purpose
Commonly used ALV Function Modules
DEFINING OUTPUT CHARACTERISTICS:
PREPARING DISPLAY FIELDS CATALOG
 A field catalog is prepared using the internal
table(I_FIELDCAT) of type SLIS_T_FIELDCAT_ALV.
 Field catalog containing descriptions of the list
output fields (usually a subset of the internal output
table fields).
 A field catalog is required for every ALV list output to add desired functionality (i.e. Key, hotspot,Specific headings, Justify, Col. Position etc) to certain fields of the output. If not mentioned specifically, then the defaults are taken.
 The field catalog for the output table is built-up in the caller's coding. The build-up can be completely or partially automated by calling the function module
REUSE_ALV_FIELDCATALOG_MERGE.
Example:
Suppose I_PO_DETAILS is an internal table containing two fields
EBELN (PO number) and EBELP (PO item no).
DATA: L_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
CLEAR L_FIELDCAT.
L_FIELDCAT-TABNAME = 'I_PO_DETAILS'.
L_FIELDCAT-FIELDNAME = 'EBELN'.
L_FIELDCAT-KEY = 'X'. The PO no is made the key field,
Colored and non scrollable
L_FIELDCAT-HOTSPOT = 'X'. The po no becomes a hotspot
L_FIELDCAT-SELTEXT_S = P.O No.
L_FIELDCAT-SELTEXT_M = 'P order No'.
L_FIELDCAT-SELTEXT_L = 'Purchase order No'.
APPEND L_FIELDCAT TO I_FIELDTAB.
CLEAR L_FIELDCAT.
L_FIELDCAT-TABNAME = 'I_PO_DETAILS'.
L_FIELDCAT-FIELDNAME = 'EBELP'.
L_FIELDCAT-KEY = 'X'. The PO item no is made the key field,
Colored and non scrollable
L_FIELDCAT-SELTEXT_S = Item No.
L_FIELDCAT-SELTEXT_M = 'PO item No'.
L_FIELDCAT-SELTEXT_L = 'Purchase order Item No'.
APPEND L_FIELDCAT TO I_FIELDTAB.
Thus the catalog for the report output is prepared.
 The next step is to build an event table, which are used for
firing both user commands and the system dependent events i.e. top of page, end of page etc.
 A list of possible events is populated into an event table. When this table is passed to the function module
REUSE_ALV_EVENT_NAMES_GET. The return table from this function module contains all the possible events.
 The internal table only needs to be modified with the associated form names corresponding to each of the events.
 The next step is to build an event table, which are used for
firing both user commands and the system dependent events i.e. top of page, end of page etc.
 A list of possible events is populated into an event table. When this table is passed to the function module
REUSE_ALV_EVENT_NAMES_GET. The return table from this function module contains all the possible events.
 The internal table only needs to be modified with the associated form names corresponding to each of the events.
Example:
DATA: L_I_EVENT TYPE SLIS_ALV_EVENT.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = I_EVENTS.
READ TABLE I_EVENTS WITH KEY NAME = SLIS_EV_TOP_OF_PAGE
INTO L_I_EVENT.
IF SY-SUBRC = 0.
MOVE FORMNAME_TOP_OF_PAGE TO L_I_EVENT-FORM.
APPEND L_I_EVENT TO I_EVENTS.
ENDIF.
READ TABLE I_EVENTS WITH KEY NAME = SLIS_EV_END_OF_PAGE
INTO L_I_EVENT.
IF SY-SUBRC = 0.
MOVE FORMNAME_END_OF_PAGE TO L_I_EVENT-FORM.
APPEND L_I_EVENT TO I_EVENTS.
ENDIF.
CLEAR L_I_EVENT.
READ TABLE I_EVENTS WITH KEY NAME = SLIS_EV_USER_COMMAND
INTO L_I_EVENT.
IF SY-SUBRC = 0.
MOVE FORMNAME_USER_COMMAND TO L_I_EVENT-FORM.
APPEND L_I_EVENT TO I_EVENTS.
ENDIF.
The function module REUSE_ALV_COMMENTARY_WRITE can
be used to pass the headings for TOP OF PAGE event. Also,
any logo specific to the report can be passed to the function
module.
Example:
PERFORM comment_build USING i_list_top_of_page.
.
.
FORM comment_build USING l_top_of_page TYPE slis_t_listheader.
DATA: ls_line TYPE slis_listheader.
CLEAR ls_line.
ls_line-typ = 'H'.
ls_line-info = 'Heading list'.
APPEND ls_line TO l_top_of_page.
CLEAR ls_line.
ls_line-typ = 'S'.
ls_line-key = 'Key 1'.
ls_line-info = 'Information'.
APPEND ls_line TO l_top_of_page.
ls_line-key = 'Key 2'.
APPEND ls_line TO l_top_of_page.
ENDFORM.
The next step is to build a layout report output list
description.
The parameters are described under the following heads:
 Display options
 Exceptions
 Totals
 Interaction
 Detail screen
 Display variants (only for hierarchical-sequential lists)
 Color
 Other
The layout table is of type slis_layout_alv_spec.
The next step is to sort the basic list with respect to
some of the fields in the list output. An internal
table needs to be declared according to the
structure slis_t_sortinfo_alv.
The structure has got the following parameters.
Spos : Sort sequence
Fieldname : Internal output table field name
Tabname : Only relevant for hierarchical-sequential lists. Name of the internal
output table.
up : 'X' = sort in ascending order
down : 'X' = sort in descending order
subtot : 'X' = subtotal at group value change
group : '* ' = new page at group value change ,'UL' = underline at group value
change
The final step in the output of the report is the use of
two ALV functions modules.
 REUSE_ALV_FIELDCATALOG_MERGE
Import parameters
I_PROGRAM_NAME : Program in which the internal output table is
declared and populated
I_INTERNAL_TABNAME : Internal output table name
I_STRUCTURE_NAME : Structure name (structure, table, and view)
I_CLIENT_NEVER_DISPL : Hide client fields default X
I_INCLNAME : Data declarations include name
CHANGING parameter
CT_FIELDCAT : Field catalog with field descriptions
The final function module for displaying the output according to the catalog, event build, sort sequence, layout and comment build are either
REUSE_ALV_LIST_DISPLAY
OR
REUSE_ALV_LIST_DISPLAY
REUSE_ALV_LIST_DISPLAY
Import parameters
I_INTERFACE_CHECK : Interface consistency check log output.
I_CALLBACK_PROGRAM : Name of the calling program
I_CALLBACK_PF_STATUS_SET : Set EXIT routine to status.
I_CALLBACK_USER_COMMAND : EXIT routine for command handling
I_STRUCTURE_NAME : Internal output table structure name
IS_LAYOUT : List layout specifications
IT_FIELDCAT : Field catalog with field descriptions
IT_EXCLUDING : Table of inactive function codes
IT_SPECIAL_GROUPS : Grouping fields for column selection
IT_SORT : Sort criteria for first list display
IT_FILTER : Filter criteria for first list output
IS_SEL_HIDE : Selection information modification
I_DEFAULT : Initial variant active/inactive logic
I_SAVE : Variants can be saved
IS_VARIANT : Variant information
IT_EVENTS : Table of events to perform
IT_EVENT_EXIT : Standard fcode exit requests table
IS_PRINT : Print information
IS_REPREP_ID : Initialization keys for Re/Re interface
I_SCREEN_START_COLUMN : Coordinates for list in dialog box
I_SCREEN_START_LINE : Coordinates for list in dialog box
I_SCREEN_END_COLUMN : Coordinates for list in dialog box
Export parameters
E_EXIT_CAUSED_BY_CALLER : Delete list in CALLBACK_USER_COMMAND
ES_EXIT_CAUSED_BY_USER : How the user left the list Tables
T_OUTTAB : Table with data to be displayed ---mandatory
Example :
WS_REPNAME = SY-REPID.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = WS_REPNAME
I_INTERNAL_TABNAME = Internal output table field name
I_INCLNAME = WS_REPNAME
CHANGING
CT_FIELDCAT = I_FIELDTAB.
IF SY-SUBRC <> 0.
WRITE: 'SY-SUBRC: ', SY-SUBRC, 'REUSE_ALV_FIELDCATALOG_MERGE'.
ENDIF.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = WS_REPNAME
I_STRUCTURE_NAME = Internal output table field name
IS_LAYOUT = I_LAYOUT
IT_FIELDCAT = I_FIELDTAB
I_DEFAULT = 'A'
I_SAVE = 'A'
IS_VARIANT = 'X'
IT_EVENTS = I_EVENTS[]
IT_SORT = I_SORT
IS_SEL_HIDE = I_SELINFO
TABLES
T_OUTTAB = Internal output table field name.
IF SY-SUBRC <> 0.
WRITE: 'SY-SUBRC: ', SY-SUBRC, 'REUSE_ALV_LIST_DISPLAY'.
ENDIF
Popup information using ALV
REUSE_ALV_POPUP_TO_SELECT
This function module for displaying or selecting
table entries in internal tables in a popup (single or
multiple selection is possible).
Principle:
 Pass an internal table with the superset of information to be output
 Pass list layout detail flags
 Pass a field catalog in the form of an internal table
 The field catalog describes the fields to be output in the list.
Popup information using ALV
Example:
REPORT y_demo_alv_3.
TYPE-POOLS: slis.
DATA: BEGIN OF i_outtab OCCURS 0.
INCLUDE STRUCTURE sflight.
DATA: w_chk TYPE c. "For multiple selection
DATA: END OF i_outtab.
DATA: i_private TYPE slis_data_caller_exit,
i_selfield TYPE slis_selfield,
W_exit(1) TYPE c.
PARAMETERS: p_title TYPE sy-title.
*
START-OF-SELECTION.
SELECT * FROM sflight INTO TABLE i_outtab.
CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'
EXPORTING
i_title = p_title
i_selection = 'X'
i_zebra = 'X'
i_checkbox_fieldname = 'W_CHK'
i_tabname = 'I_OUTTAB'
i_structure_name = 'SFLIGHT'
IMPORTING
es_selfield = i_selfield
e_exit = w_exit
TABLES
t_outtab = i_outtab
EXCEPTIONS
program_error = 1
OTHERS = 2.
Popup information using ALV
Example(Contd):
IF sy-subrc <> 0.
MESSAGE i000(0k) WITH sy-subrc.
ENDIF.
*****the internal table is modified with a cross sign for marking the
***rows selected
LOOP AT i_outtab WHERE w_chk = 'X'.
WRITE: / i_outtab-carrid, i_outtab-price.
ENDLOOP.
An Observation on ALV
If some of the icons in the GUI status of standard ALV interface needs to be
omitted or deleted, the STANDARD GUI status from the function group SALV
needs to be copied into own program and the likely or unlikely buttons needs
to be omitted or included.
Example:
DATA : BEGIN OF I_RT_EXTAB OCCURS 0.
INCLUDE STRUCTURE SLIS_T_EXTAB.
DATA : END OF I_RT_EXTAB.
APPEND '&UMC' TO I_RT_EXTAB.
APPEND '&SUM' TO I_RT_EXTAB.
APPEND '&XPA' TO I_RT_EXTAB.
APPEND '&OMP' TO I_RT_EXTAB.
SET PF-STATUS 'STANDARD' EXCLUDING I_RT_EXTAB.
Steps Summary
 DATA DECLARATION
 SELECTING THE VARIANTS FOR INITIAL LIST DISPLAY
 DEFINING OUTPUT CHARACTERISTICS: PREPARING
DISPLAY FIELDS CATALOG
 PREPARATION OF EVENT TABLE
 LAYOUT BUILD
 SORT SEQUENCE BUILD
 DISPLAY OUTPUT
i am giving some links
http://www.sapgenie.com/abap/reports.htm
http://www.allsaplinks.com/material.html
http://www.sapdevelopment.co.uk/reporting/reportinghome.htm
http://www.sapfans.com/forums/viewtopic.php?t=58286
http://www.sapfans.com/forums/viewtopic.php?t=76490
http://www.sapfans.com/forums/viewtopic.php?t=20591
http://www.sapfans.com/forums/viewtopic.php?t=66305 - this one discusses which way should you use - ABAP Objects calls or simple function modules.
please reward points,if it is useful.
regards,
satish.
2007 Dec 27 3:32 AM
Hi Gupta,
i prepared some slides on ALV reports.
if u want gv me ur mailid i can send.
Later i can send some simple examples on each type of ALV reports.
thank you
chandu
2007 Dec 27 5:47 AM
2007 Dec 27 5:55 AM
hi rajeev,
The brief notes below can give u an basic idea of what is ALV..
What is ALV programming in ABAP? When is this grid used in ABAP?
ALV is Application List viewer.
Sap provides a set of ALV (ABAP LIST VIEWER) function modules which can be put into use to embellish the output of a report. This set of ALV functions is used to enhance the readability and functionality of any report output. Cases arise in sap when the output of a report contains columns extending more than 255 characters in length.
In such cases, this set of ALV functions can help choose selected columns and arrange the different columns from a report output and also save different variants for report display. This is a very efficient tool for dynamically sorting and arranging the columns from a report output.
The report output can contain up to 90 columns in the display with the wide array of display options.
The commonly used ALV functions used for this purpose are;
1. REUSE_ALV_VARIANT_DEFAULT_GET
2. REUSE_ALV_VARIANT_F4
3. REUSE_ALV_VARIANT_EXISTENCE
4. REUSE_ALV_EVENTS_GET
5. REUSE_ALV_COMMENTARY_WRITE
6. REUSE_ALV_FIELDCATALOG_MERGE
7. REUSE_ALV_LIST_DISPLAY
8. REUSE_ALV_GRID_DISPLAY
9. REUSE_ALV_POPUP_TO_SELECT
Purpose of the above Functions are differ not all the functions are required in all the ALV Report.
But either no.7 or No.8 is there in the Program.
How you call this function in your report?
After completion of all the data fetching from the database and append this data into an Internal Table. say I_ITAB.
Then use follwing function module.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = 'Prog.name'
I_STRUCTURE_NAME = 'I_ITAB'
I_DEFAULT = 'X'
I_SAVE = 'A'
TABLES
T_OUTTAB = I_ITAB.
IF SY-SUBRC <> 0.
WRITE: 'SY-SUBRC: ', SY-SUBRC .
ENDIF.
ENDFORM. " GET_FINAL_DATA
Reward if helpful.
Thank you,
Regards.
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |