Académique Documents
Professionnel Documents
Culture Documents
Notes
Introduction.
• ALV – ABAP List Viewer (4.6B)
• ALV Grid Control vs. ALV List
• Advantages
o No huge selection screens – use filters – (moderate use!)
o Minimal maintenance if done properly
Extract lots of data
Work with user on possible data requirements
Setup variants together with the user
o User-friendly functionality (Download to Excel etc.)
o Non-Static
o It is not an updating tool!
• Workings
o Grid / Report
Moving of columns
Total / Sub Total (Breaks) / Hide Columns
Sort / Filter / Blank Control Breaks not on List
Hotspots
Multiple lines report (ALV List only)
Buttons
Variants (User / Set as default / “/GENERAL”)
When it dump (Flush / CNTL-ERROR)
Differences between 4.6B & 4.6C
• Help
o Users & ABAPers
SAP Library ► Search Tab ► Enter “ALV Grid” ► Select “ABAP
List Viewer (ALV) Grid Control (Getting Started)”
o ABAPers
SAP Library ► Index Tab ► Enter “ALV” ► Select “ALV Grid
Control” ► Select “BC – ALV Grid Control” (Hotspot on right-hand
panel)
Additional Stuff.
• Logos
• Using ALV Grid in WANs
• Full Excel capabilities in SAP
• Using Graphs (minimal effort)
Report ZXX0001....
* Tables, Types and Data Declaration
Tables: ....
Types: ....
Data: ....
Type-Pools: slis.
Data: .... " * (See details on following pages)
* Selection Screen
Selection Screen: ....
Select Options: ....
Parameters: ....
Parameters: p_vari like disvariant-variant default '/GENERAL'.
EVENTS
Initialization.
....
Perform Initialize_ALV.
At Selection Screen (on value request for ????).
....
At Selection-Screen on Value-Request for p_vari.
Perform F4_for_Variant.
At Selection-Screen.
Perform PAI_of_Selection_Screen.
At Line-Selection.
....
Call Transaction ....
GUI Status (Copy any BALV... program's and change)
Top-Of-Page.
Perform Headings.
Start-Of-Selection.
Perform Select_Data.
End-Of-Selection.
Perform Display_Data
Text Elements
SUBROUTINES
Form Select_Data.
Select * from ....
....
If flag = ' '.
wa_itab-linecolor = 'C000'.
flag = 'X'.
Else.
wa_itab-linecolor = 'C200'.
flag = ' '.
EndIf.
Append Wa_Itab to Itab.
EndSelect.
EndForm.
Form Display_Data.
Call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = report
is_layout = layout
i_callback_pf_status_set = status
i_callback_user_command = user_command
it_fieldcat = fldcat[]
i_save = 'A'
it_events = event[]
is_print = print ABC Company
is_variant = variant
tables Code Description T
t_outtab = itab 0001 HP Printer 3
exceptions
program_error =1 0005 PC 5
others = 2. TOTAL 8
If sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
EndForm.
EndIf.
Form Top_Of_Page. " Headings
* (See details on following pages) ALV Report
EndForm.
ALV (ABAP List Viewer) vs. Normal ABAP Report
Form Top_Of_Page.
* Prepare standard heading
refresh heading.
data: line type slis_listheader,
len type i,
pos type i,
page(4) type c.
Text Elements
SUBROUTINES
if sy-subrc = 0.
concatenate user_addr-mc_namefir user_addr-mc_namelas into name
separated by space.
concatenate sy-uname '-' name into line-info separated by space.
else.
move sy-uname to line-info.
endif.
append line to heading.
clear line.
line-typ = 'A'.
if not s_bukrs is initial.
write: 'Company : ' to line-info,
GUI Status (Copy any BALV... program's and change)
s_bukrs-low to line-info+29.
if not s_bukrs-high is initial.
write: 'to' to line-info+35,
s_bukrs-high to line-info+38.
endif.
append line to heading.
endif.
*
Text Elements
EndForm.
Form Get_Module_Heading using p_module.
* To be displayed in the heading.
case p_module.
when 'AA'.
move 'Asset Accounting' to module_text.
when 'AM'.
move 'Asset Management' to module_text.
when 'BA'.
move 'Basis, R/3 Administration' to module_text.
when 'CA'.
move 'Cross Application' to module_text.
when 'CO'.
move 'Controlling' to module_text.
when 'EC'.
move 'Enterprise Control' to module_text.
when 'FI'.
move 'Financial Accounting' to module_text.
when 'FS'.
move 'Consolidation' to module_text.
when 'HR'.
move 'Human Recources' to module_text.
when 'GL'.
move 'General Ledger' to module_text.
when 'IM'.
move 'Inventory Management' to module_text.
when 'MM'.
move 'Material Management' to module_text.
....
endcase.
EndForm.
ALV (ABAP List Viewer) vs. Normal ABAP Report
SUBROUTINES
Form Initialize_ALV.
* Printing layout
print-no_print_selinfos = 'X'. " display no selection infos
print-no_coverpage = 'X'.
print-reserve_lines = 1. " lines reserved for end of page
print-no_print_listinfos = 'X'. " display no listinfos
* Display options
GUI Status (Copy any BALV... program's and change)
* Sums
Text Elements
EndForm.
Form Column using name length desc datatype dec sum noout.
clear fldcat.
fldcat-fieldname = name.
fldcat-outputlen = length.
fldcat-seltext_l = desc.
fldcat-datatype = datatype.
fldcat-decimals_out = dec.
fldcat-do_sum = sum.
fldcat-no_out = noout.
if name = 'SEL'.
fldcat-checkbox = 'X'.
endif.
append fldcat.
EndForm.
ALV (ABAP List Viewer) vs. Normal ABAP Report
SUBROUTINES
Form F4_For_Variant.
variant-report = sy-repid.
variant-log_group = 'ZVAR'.
clear def_variant.
EndForm.
Form PAI_of_Selection_Screen.
EndForm.
case ucomm.
* At line-selection interactive event - call transaction
when '&IC1'.
* READ TABLE itab INTO itab INDEX rs_selfield-tabindex.
* CHECK NOT rs_selfield-value IS INITIAL.
* CASE rs_selfield-fieldname.
* WHEN 'VBELN'.
* SET PARAMETER ID 'AUN' FIELD rs_selfield-value.
* CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.
* WHEN 'EBELN'.
* SET PARAMETER ID 'BES' FIELD rs_selfield-value.
* CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
* ENDCASE.
endcase.
clear ucomm.
EndForm.
EndForm.