Sandi Wijaya
Page 1
10/22/2008
ABAP List Viewer This is an escort for creating ABAP List Viewer (ALV) report. In creating ALV, first you must do are : 1. 2.
Add line“type-pools : slis” in your program. Create functional ALV procedures which is : a. Category Fields This functions for registry which fields will be display on the report. b. Layout Configuring layout properties of ALV reports. c. Color Configuring color layout in ALV report. d. Event before call procedure Comment, call this function first. e. Sort and Subtotal Configuring ALV Sort and Subtotal Function f. Group g. Comment Configuring header and Footer ALV report. h. Filter Configuring ALV filter. i. Print Configuring for ALV Report Printing. j. .....
3.
Call function “REUSE_ALV_LIST_DISPLAY” in background mode (outside of Start-Of-Selection), this function for execute the ALV report program. Fill the parameter : a. I_CALLBACK_PROGRAM with Program ID (Sy-REPID) b. I_STRUCTURE_NAME with internal table name or structure table name c. IS_LAYOUT with data which has been set in procedure Layout d. IT_FIELDCAT with table which has been set in procedure Category Fields. e. IT_FILTER with Filter Data f. IT_SPECIAL_GROUPS with Groups data g. IT_EVENTS with Event data h. IT_SORT with Sort Data i. IS_PRINT with Print Data j. Tables T_OUTTAB with your
Sandi Wijaya
Page 2
10/22/2008
Category Fields Category Fields are fields which will be display on ALV Report. You must create variable with type slis_t_fieldcat_alv. Then make procedure which set property of that variable. Here is the structure of Structure slis_t_fieldcat_alv. TYPES: BEGIN OF SLIS_FIELDCAT_MAIN, ROW_POS LIKE SY-CUROW, " output in row COL_POS LIKE SY-CUCOL, " position of the column FIELDNAME TYPE SLIS_FIELDNAME, TABNAME TYPE SLIS_TABNAME, REF_FIELDNAME LIKE DD03P-FIELDNAME, REF_TABNAME LIKE DD03P-TABNAME, CFIELDNAME TYPE SLIS_FIELDNAME, " field with currency unit CTABNAME TYPE SLIS_TABNAME, " and table QFIELDNAME TYPE SLIS_FIELDNAME, " field with quantity unit QTABNAME TYPE SLIS_TABNAME, " and table ROUNDFIELDNAME TYPE SLIS_FIELDNAME, ROUNDTABNAME TYPE SLIS_TABNAME, ROUND TYPE I, " round in write statement DECIMALSFIELDNAME TYPE SLIS_FIELDNAME, DECIMALSTABNAME TYPE SLIS_TABNAME, DECIMALS_OUT(6) TYPE C, " decimals in write statement EXPONENT(3) TYPE C, " exponent for floats KEY(1) TYPE C, " column with key-color ICON(1) TYPE C, " as icon SYMBOL(1) TYPE C, " as symbol CHECKBOX(1) TYPE C, " as checkbox JUST(1) TYPE C, " (R)ight (L)eft (C)ent. LZERO(1) TYPE C, " leading zero NO_SIGN(1) TYPE C, " write no-sign NO_ZERO(1) TYPE C, " write no-zero EDIT_MASK TYPE SLIS_EDIT_MASK, " EMPHASIZE(4) TYPE C, " emphasize FIX_COLUMN(1) TYPE C, " Spalte fixieren DO_SUM(1) TYPE C, " sum up NO_OUT(1) TYPE C, " (O)blig.(X)no out TECH(1) TYPE C, " technical field OUTPUTLEN LIKE DD03P-OUTPUTLEN, SELTEXT_L LIKE DD03P-SCRTEXT_L, " long key word SELTEXT_M LIKE DD03P-SCRTEXT_M, " middle key word SELTEXT_S LIKE DD03P-SCRTEXT_S, " short key word REPTEXT_DDIC LIKE DD03P-REPTEXT, " heading (ddic) DDICTXT(1) TYPE C, " (S)hort (M)iddle (L)ong ROLLNAME LIKE DD03P-ROLLNAME, * domname like dd03p-domname, "Domname für Checkbox DATATYPE LIKE DD03P-DATATYPE, DDIC_OUTPUTLEN LIKE DD03P-OUTPUTLEN, INTLEN LIKE DD03P-INTLEN, END OF SLIS_FIELDCAT_MAIN. TYPES: BEGIN OF SLIS_FIELDCAT_ALV_SPEC, KEY_SEL(1) TYPE C, " field not obligatory NO_SUM(1) TYPE C, " do not sum up SP_GROUP(1) TYPE C, " group specification REPREP(1) TYPE C, " selection for rep/rep INPUT(1) TYPE C, " input HOTSPOT(1) TYPE C, " hotspot END OF SLIS_FIELDCAT_ALV_SPEC. TYPES: BEGIN OF SLIS_FIELDCAT_ALV. INCLUDE TYPE SLIS_FIELDCAT_MAIN. INCLUDE TYPE SLIS_FIELDCAT_ALV_SPEC. TYPES: END OF SLIS_FIELDCAT_ALV. TYPES: SLIS_T_FIELDCAT_ALV TYPE SLIS_FIELDCAT_ALV OCCURS 1.
Sandi Wijaya
Page 3
10/22/2008
After you set the properties, it will be use in executing ALV reports. Take a look at this example : FORM FIELDCAT_INIT. DATA: FIELDCAT_IN TYPE SLIS_FIELDCAT_ALV. CLEAR FIELDCAT_IN. *-- add matnr -CLEAR FIELDCAT_IN. FIELDCAT_IN-FIELDNAME = 'MATNR'. FIELDCAT_IN-REF_FIELDNAME = 'MATNR'. FIELDCAT_IN-REF_TABNAME = 'MARA'. FIELDCAT_IN-OUTPUTLEN = 20. APPEND FIELDCAT_IN TO GT_FIELDCAT. *-- add matkl -CLEAR FIELDCAT_IN. FIELDCAT_IN-FIELDNAME = 'MATKL'. FIELDCAT_IN-REF_FIELDNAME = 'MATKL'. FIELDCAT_IN-REF_TABNAME = 'MARA'. FIELDCAT_IN-OUTPUTLEN = 20. FIELDCAT_IN-HOTSPOT = 'X'. FIELDCAT_IN-SELTEXT_L = 'Material Type (MATKL)'. FIELDCAT_IN-EMPHASIZE = 'C700'. APPEND FIELDCAT_IN TO GT_FIELDCAT. *-- add mtart -CLEAR FIELDCAT_IN. FIELDCAT_IN-FIELDNAME = 'MTART'. FIELDCAT_IN-REF_FIELDNAME = 'MTART'. FIELDCAT_IN-REF_TABNAME = 'MARA'. FIELDCAT_IN-NO_OUT = ''. FIELDCAT_IN-OUTPUTLEN = 20. APPEND FIELDCAT_IN TO GT_FIELDCAT. ENDFORM.
Of course we can see that if you want to show more than one field Use it like you use internal table.
Sandi Wijaya
Page 4
10/22/2008
Layout This properties gives you, you can configure what you want about the layout of ALV report. Here is the structure of Layout properties plus brief explanation. TYPES: BEGIN OF SLIS_LAYOUT_MAIN, DUMMY, END OF SLIS_LAYOUT_MAIN. TYPES: BEGIN OF SLIS_LAYOUT_ALV_SPEC, * Display options COLWIDTH_OPTIMIZE(1) TYPE C, NO_COLHEAD(1) TYPE C, " no headings NO_HOTSPOT(1) TYPE C, " headings not as hotspot ZEBRA(1) TYPE C, " striped pattern NO_VLINE(1) TYPE C, " columns separated by space NO_MIN_LINESIZE(1) TYPE C, " line size = width of the list MIN_LINESIZE LIKE SY-LINSZ, " if initial min_linesize = 80 MAX_LINESIZE LIKE SY-LINSZ, " Default 250 WINDOW_TITLEBAR LIKE RSMPE-TITTEXT, * Exceptions LIGHTS_FIELDNAME TYPE SLIS_FIELDNAME," fieldname for exception LIGHTS_TABNAME TYPE SLIS_TABNAME, " fieldname for exception LIGHTS_ROLLNAME LIKE DFIES-ROLLNAME," rollname f. exceptiondocu LIGHTS_CONDENSE(1) TYPE C, " fieldname for exception * Sums NO_SUMCHOICE(1) TYPE C, " no choice for summing up NO_TOTALLINE(1) TYPE C, " no total line NO_SUBCHOICE(1) TYPE C, " no choice for subtotals NO_SUBTOTALS(1) TYPE C, " no subtotals possible NUMC_SUM(1) TYPE C, " totals for NUMC-Fields possib. TOTALS_ONLY(1) TYPE C, " show only totals TOTALS_TEXT(60) TYPE C, " text for 1st col. in total line SUBTOTALS_TEXT(60) TYPE C, " text for 1st col. in subtotals * Interaction BOX_FIELDNAME TYPE SLIS_FIELDNAME, " fieldname for checkbox BOX_TABNAME TYPE SLIS_TABNAME," tabname for checkbox EXPAND_FIELDNAME TYPE SLIS_FIELDNAME, " fieldname flag 'expand' HOTSPOT_FIELDNAME TYPE SLIS_FIELDNAME, " fieldname flag hotspot NO_INPUT(1) TYPE C, " only display fields F2CODE LIKE SY-UCOMM, " CONFIRMATION_PROMPT, " confirm. prompt when leaving KEY_HOTSPOT(1) TYPE C, " keys as hotspot " K_KEYHOT REPREP(1) TYPE C, " report report interface active GROUP_BUTTONS(1) TYPE C, " buttons for COL1 - COL5 NO_KEYFIX(1) TYPE C, " do not fix keycolumns GET_SELINFOS(1) TYPE C, " read selection screen GROUP_CHANGE_EDIT(1) TYPE C, " Settings by user for new group NO_SCROLLING(1) TYPE C, " no scrolling * Detailed screen DETAIL_POPUP(1) TYPE C, " show detail in popup DETAIL_INITIAL_LINES(1) TYPE C, " show also initial lines DETAIL_TITLEBAR(30) TYPE C, " Titlebar for detail * Display variants HEADER_TEXT(20) TYPE C, " Text for header button ITEM_TEXT(20) TYPE C, " Text for item button DEFAULT_ITEM(1) TYPE C, " Items as default * colour INFO_FIELDNAME TYPE SLIS_FIELDNAME, " infofield for listoutput COLTAB_FIELDNAME TYPE SLIS_FIELDNAME, " colors * others LIST_APPEND(1) TYPE C, " no call screen END OF SLIS_LAYOUT_ALV_SPEC. TYPES: BEGIN OF SLIS_LAYOUT_ALV. INCLUDE TYPE SLIS_LAYOUT_MAIN. INCLUDE TYPE SLIS_LAYOUT_ALV_SPEC. TYPES: END OF SLIS_LAYOUT_ALV.
Sandi Wijaya
Page 5
Color Below is structure for Color in ALV Report. TYPES: BEGIN OF SLIS_COLOR, COL TYPE I, INT TYPE I, INV TYPE I, END OF SLIS_COLOR. TYPES: BEGIN OF SLIS_COLTYPES, HEACOLFIR TYPE SLIS_COLOR, " heading_cols_first HEACOLNEX TYPE SLIS_COLOR, " heading_cols_nex HEAROWFIR TYPE SLIS_COLOR, " heading_rows_first HEAROWNEX TYPE SLIS_COLOR, " heading_rows_next LISBODFIR TYPE SLIS_COLOR, " list_body_first LISBODNEX TYPE SLIS_COLOR, " list_body_next LISBOD TYPE SLIS_COLOR, " list_body HIGCOLKEY TYPE SLIS_COLOR, " highlight_col_key HIGCOL TYPE SLIS_COLOR, " highlight_col HIGROW TYPE SLIS_COLOR, " highlight_row HIGSUM TYPE SLIS_COLOR, " highlight_sum HIGSUMHIG TYPE SLIS_COLOR, " highlight_sum_high HIGSUMLOW TYPE SLIS_COLOR, " highlight_sum_low HIGINS TYPE SLIS_COLOR, " highlight_inserted HIGPOS TYPE SLIS_COLOR, " highlight_positive HIGNEG TYPE SLIS_COLOR, " highlight_negative HIG TYPE SLIS_COLOR, " highlight HEAHIE TYPE SLIS_COLOR, " heading_hier LISBODHIE TYPE SLIS_COLOR, " list_body_hierinfo END OF SLIS_COLTYPES.
You can give touch of color for your report by setting this properties. Examples of using. < Insert code here >
10/22/2008
Sandi Wijaya
Page 6
10/22/2008
Event With this function we can handle event. The way to handle is first you must call function “REUSE_ALV_EVENTS_GET” with input parameter of I_LIST_TYPE with value : a. 0 : Simple List (default) b. 1 : Hierarchy – sequential List c. 2 : Simple Block List d. 3 : Hierarchy – sequential block list NB: I still don’t know what the differences for each type and Output parameter of ET_EVENTS with table which has type SLIS_T_EVENT. Here is the constants for Event Constants. CONSTANTS: * Events SLIS_EV_ITEM_DATA_EXPAND TYPE SLIS_FORMNAME VALUE 'ITEM_DATA_EXPAND', SLIS_EV_CALLER_EXIT_AT_START TYPE SLIS_FORMNAME VALUE 'CALLER_EXIT', SLIS_EV_USER_COMMAND TYPE SLIS_FORMNAME VALUE 'USER_COMMAND', SLIS_EV_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE', SLIS_EV_TOP_OF_COVERPAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_COVERPAGE', SLIS_EV_END_OF_COVERPAGE TYPE SLIS_FORMNAME VALUE 'END_OF_COVERPAGE', SLIS_EV_FOREIGN_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'FOREIGN_TOP_OF_PAGE', SLIS_EV_FOREIGN_END_OF_PAGE TYPE SLIS_FORMNAME VALUE 'FOREIGN_END_OF_PAGE', SLIS_EV_PF_STATUS_SET TYPE SLIS_FORMNAME VALUE 'PF_STATUS_SET', SLIS_EV_LIST_MODIFY TYPE SLIS_FORMNAME VALUE 'LIST_MODIFY', SLIS_EV_TOP_OF_LIST TYPE SLIS_FORMNAME VALUE 'TOP_OF_LIST', SLIS_EV_END_OF_PAGE TYPE SLIS_FORMNAME VALUE 'END_OF_PAGE', SLIS_EV_END_OF_LIST TYPE SLIS_FORMNAME VALUE 'END_OF_LIST', SLIS_EV_AFTER_LINE_OUTPUT TYPE SLIS_FORMNAME VALUE 'AFTER_LINE_OUTPUT', SLIS_EV_BEFORE_LINE_OUTPUT TYPE SLIS_FORMNAME VALUE 'BEFORE_LINE_OUTPUT'.
Below is Structure of SLIS_T_EVENT. *--- Structure for event handling TYPES: BEGIN OF SLIS_ALV_EVENT, NAME(30), FORM(30), END OF SLIS_ALV_EVENT. TYPES: SLIS_T_EVENT TYPE SLIS_ALV_EVENT OCCURS 0.
Then you can check what events has occured. by Check the SLIS_ALV_EVENT-NAME with event – constants. Check the code below. FORM EVENTTAB_BUILD. DATA: LS_EVENT TYPE SLIS_ALV_EVENT. CALL FUNCTION 'REUSE_ALV_EVENTS_GET' EXPORTING I_LIST_TYPE =0 IMPORTING ET_EVENTS = GT_EVENTS EXCEPTIONS LIST_TYPE_WRONG = 1 OTHERS = 2. * check what event has occured. READ TABLE GT_EVENTS WITH KEY NAME = SLIS_EV_TOP_OF_PAGE INTO LS_EVENT.
Sandi Wijaya
Page 7
* if event occured. IF SY-SUBRC = 0. MOVE GC_FORMNAME_TOP_OF_PAGE TO LS_EVENT-FORM. APPEND LS_EVENT TO GT_EVENTS. ENDIF. ENDFORM.
Note: You must call this function before creating call function COMMENT.
10/22/2008
Sandi Wijaya
Sort and
Page 8
10/22/2008
Subtotal
Below is Structure Sort (SLIS_T_SORTINFO_ALV). * information for sort and subtotals TYPES: BEGIN OF SLIS_SORTINFO_ALV, SPOS LIKE ALVDYNP-SORTPOS, FIELDNAME TYPE SLIS_FIELDNAME, TABNAME TYPE SLIS_FIELDNAME, UP LIKE ALVDYNP-SORTUP, “Ascending DOWN LIKE ALVDYNP-SORTDOWN, “Descending GROUP LIKE ALVDYNP-GROUPLEVEL, “Grouping SUBTOT LIKE ALVDYNP-SUBTOTALS, “Field Subtotal COMP(1) TYPE C, EXPA(1) TYPE C, END OF SLIS_SORTINFO_ALV. TYPES: SLIS_T_SORTINFO_ALV TYPE SLIS_SORTINFO_ALV OCCURS 1.
Every field to be configured is added to SLIS_T_SORTINFO_ALV. This table will be use as input parameter of function “REUSE_ALV_LIST_DISPLAY”.
Sandi Wijaya
Group not yet studied.
Page 9
10/22/2008
Sandi Wijaya
Page 10
10/22/2008
Comment This function use for creating header and footer ALV report. This is the structure for use Comment. * Header table for top of page TYPES: BEGIN OF SLIS_LISTHEADER, TYP(1) TYPE C, " H = Header, S = Selection, A = Action KEY(20) TYPE C, INFO TYPE SLIS_ENTRY, END OF SLIS_LISTHEADER. TYPES: SLIS_T_LISTHEADER TYPE SLIS_LISTHEADER OCCURS 1.
Take a look code below. .... Data GT_LIST_TOP_PAGE type slis_t_listheader. ... ... FORM COMMENT_BUILD. DATA: GS_LINE TYPE SLIS_LISTHEADER, TEXT(60) TYPE C. GS_LINE-TYP = 'H'. GS_LINE-INFO = 'Hello Header'. APPEND GS_LINE TO GT_LIST_TOP_PAGE. ENDFORM. ... ...
It will pring ‘Hello Header’ in top-of-page ALV report.
Sandi Wijaya
Filter
Page 11
10/22/2008
Sandi Wijaya
Print
Page 12
10/22/2008
Sandi Wijaya
Page 13
This standard Type in SLIS type-groups. TYPES: SLIS_LIST_TYPE(1) TYPE N, SLIS_CHAR_1(1) TYPE C, SLIS_TEXT40(40) TYPE C. TYPES: SLIS_TABNAME(30) TYPE C, SLIS_FIELDNAME(30) TYPE C, SLIS_FORMNAME(30) TYPE C, SLIS_ENTRY(60) TYPE C, SLIS_EDIT_MASK(60) TYPE C, SLIS_COLDESC(4) TYPE C.
10/22/2008