ALV is very an useful tools in reporting. Just pass the data to ALV, than it will display interactive report easy to sort, filter, calculate total, etc.
There are two ALV model, list report (function REUSE_ALV_LIST_DISPLAY) and grid report (function REUSE_ALV_GRID_DISPLAY). Please read the function module documentation for complete guidance.
There are two main part of simple ALV report.
1. Create field catalog.
Field catalog containing descriptions of the list output fields.
2. Pass data and field catalog to ALV function (function REUSE_ALV_LIST_DISPLAY or REUSE_ALV_GRID_DISPLAY).
You can also playing with ALV format, find it in "Change Format in ALV".
This is a simple sample of how to use ALV.
REPORT ZAALGAL0001.
*-----------------------------------------
*Data declaration
TABLES: mara,
makt.
* Data output
DATA: BEGIN OF t_report OCCURS 3,
matnr LIKE mara-matnr,
mtart LIKE mara-mtart,
maktx LIKE makt-maktx,
END OF t_report.
* Field desciption / field catalog
TYPE-POOLS: SLIS.
data t_fcat type SLIS_T_FIELDCAT_ALV.
*-
DATA: d_repid LIKE sy-repid.
*-----------------------------------------
*--Selection Screen
SELECT-OPTIONS: s_matnr FOR mara-matnr,
s_mtart FOR mara-mtart.
*-----------------------------------------
START-OF-SELECTION.
*-Read data
SELECT * FROM mara
WHERE matnr IN s_matnr AND
mtart IN s_mtart.
CLEAR makt.
SELECT SINGLE *
FROM makt
WHERE matnr = mara-matnr AND
spras = sy-langu.
MOVE: mara-matnr TO t_report-matnr,
mara-mtart TO t_report-mtart,
makt-maktx TO t_report-maktx.
APPEND t_report.
ENDSELECT.
IF sy-subrc NE 0.
WRITE 'No data found'.
EXIT.
ENDIF.
*-----------------------------------------
*-Create Field Catalog
* Store report name
d_repid = sy-repid.
* Create Fieldcatalogue from internal table
* Use capital letter for I_INTERNAL_TABNAME
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = d_repid
I_INTERNAL_TABNAME = 'T_REPORT'
I_INCLNAME = d_repid
CHANGING
CT_FIELDCAT = t_fcat
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
write: / 'Error:',sy-subrc,
'when Create Field Catalog'.
EXIT.
ENDIF.
* Call ALV List Display
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = d_repid
IT_FIELDCAT = t_fcat
TABLES
T_OUTTAB = t_report
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
write: / 'Error:',sy-subrc,
'when Call ALV List Display'.
EXIT.
ENDIF.
Tuesday, July 17, 2007
Simple ALV
Diposting oleh alionzo di 8:34 PM
Label: ABAP Sample Code
Subscribe to:
Post Comments (Atom)
14 comments:
hi..
i have created ALV program but the total icon in the toolbar disappear (by default). How to display this icon in the toolbar? thanks in advanced.
In function module REUSE_ALV_LIST_DISPLAY / REUSE_ALV_GRID_DISPLAY there is importing parameter named I_CALLBACK_PF_STATUS_SET.
The toolbar missing happened when you passed the value to I_CALLBACK_PF_STATUS_SET, and set PF-STATUS in your program, but you didn't create the GUI status.
Check your code, is there any command "SET PF-STATUS" ?
Do you pass value to I_CALLBACK_PF_STATUS_SET ?
Hi ,
I am new to SAP's-ABAP.This Simple ALV progrm helped me very much to understand the ALV program concept.Thank you very much..!
hi i am sreenu new to sap abap can u tell me about the scripts
Refer this code...
Simple AVL Report with fieldcatalog....
http://theabap.blogspot.in/2012/01/simple-alv-table-without-field-catalog.html
Hello sir,
i am sendhil from chennai.
I am doing my SAP ABAP course and also i am doing my Pg in ME.
i have many doubts in ABAP.
I need ur suggestion and ideas.
why is slis ued in alv reports
Hi, I have just made an alv report, but in the reuse_alv_grid_display function whenever I am uncommenting and using a function, an error "is not expected" is coming. For e.g., if there is I_CALLBACK_PROGRAM = SY-REPID, the error showing is "I_CALLBACK_PROGRAM = SY-REPID" is not expected. Is it due to any installation problem? Please help.
When Ever we are using field catalog in alv reports we should use slis by using ther command
type-pools :slis.
and should make an internal table for the field catalog using the command data fieldcatalog type slis_t_fieldcat_alv ..and when we need a work area slis_fieldcatalog is used.
Other wise we can use data fieldcatalog type slis_t_fieldcat_alv with headerline also
I_CALLBACK_PROGRAM = SY-REPID is used like this only.It can be any other system level errors.You can contact your Bo consultant
Sir, I want to adjust my ALV layout in group left format, it can be done through tollbar functionality but when i take print out the lay out gets disturbed..
The 10 best slots in the UK for 2021 - JTM Hub
Play 보령 출장샵 these 논산 출장샵 10 slot games online 창원 출장안마 for free at JTM. Find out the 인천광역 출장샵 top games from the top software companies at 제주 출장안마 JTM and get a bonus!
شركة تنظيف خزانات بالمدينة المنورة
أفضل مكان لعلاج أورام الكبد بالإسكندرية
Post a Comment