Reus_alv_grid_display
hi, can any one help me in calculating total and subtotal for a field of type 'curr'.... using performs and reuse_alv_grid_display
hI,
you need to use the do_sum statement in the modify field catalogue perform .
checkout this program...
Type pools
TYPE-POOLS : SLIS.
Tables
TABLES: VBAK,VBAP,ICON.
DATA Declaration
*--Table to hold the Header Sales data
DATA: BEGIN OF TB_VBAK OCCURS 0,
INDICAT LIKE ICON-ID, " Icon
VBELN LIKE VBAK-VBELN, " Sales Document
AUDAT LIKE VBAK-AUDAT, " Document date
VBTYP LIKE VBAK-VBTYP, " SD document category
AUART LIKE VBAK-AUART, " Sales Document Type
AUGRU LIKE VBAK-AUGRU, " Order reason
NETWR LIKE VBAK-NETWR, " Net Value
WAERK LIKE VBAK-WAERK, " SD document currency
END OF TB_VBAK.
*--Table to hold the Icons
DATA: BEGIN OF TB_ICON OCCURS 0,
ID TYPE ICON-ID, " Icon
NAME TYPE ICON-NAME, " Name of an Icon
END OF TB_ICON.
*--Table to hold the Item Sales data
DATA: BEGIN OF TB_VBAP OCCURS 0,
VBELN LIKE VBAP-VBELN, " Sales Document
POSNR LIKE VBAP-POSNR, " Sales Document Item
MATNR LIKE VBAP-MATNR, " Material Number
END OF TB_VBAP.
*--Declaration of ALV Tables
DATA : TB_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV, " Field Catalog
TB_FIELDCAT1 TYPE SLIS_T_FIELDCAT_ALV, " Field Catalog
TB_EVENTS TYPE SLIS_T_EVENT, " ALV Events
TB_SORT_ALV TYPE SLIS_T_SORTINFO_ALV, " ALV Sort
TB_COMMENTS TYPE SLIS_T_LISTHEADER. " Comment
*--Declaration of Local Variables
DATA : G_REPID LIKE SY-REPID. " For Program name
DATA : L_TABIX TYPE SY-TABIX.
STRUCTURES
*-- Declaration of ALV structures
DATA : X_FIELDCAT TYPE SLIS_FIELDCAT_ALV, " For Field Catalog
X_LAYOUT TYPE SLIS_LAYOUT_ALV, " For Layout
X_EVENTS TYPE SLIS_ALV_EVENT, " For Events
X_SORT TYPE SLIS_SORTINFO_ALV, " For Sort
X_COMMENTS TYPE SLIS_LISTHEADER. " For Comments
C O N S T A N T S
*--Declaration of Constants
CONSTANTS : C_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE',
C_PF_STATUS TYPE SLIS_FORMNAME VALUE 'FRM_PF_STATUS',
C_USER_COMMAND TYPE SLIS_FORMNAME VALUE 'FRM_USER_COMMAND',
C_GREEN(40) TYPE C VALUE 'ICON_GREEN_LIGHT',
C_RED(40) TYPE C VALUE 'ICON_RED_LIGHT',
C_YELLOW(40) TYPE C VALUE 'ICON_YELLOW_LIGHT',
C_X TYPE C VALUE 'X', " Flag
C_H TYPE C VALUE 'H', " For Commenet-Type
C_S TYPE C VALUE 'S'. " For Commenet-Type
INITIALIZATION
*--Intialization.
INITIALIZATION.
G_REPID = SY-REPID.
SELECTION SCREEN
*--Block 1.
SELECTION-SCREEN : BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
PARAMETER: P_AUDAT LIKE VBAK-AUDAT
DEFAULT '20050101'(003). " doc date.
SELECTION-SCREEN: END OF BLOCK B1.
*--bLOCK 2.
SELECTION-SCREEN : BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-002.
PARAMETER :P_ALVDIS AS CHECKBOX. " For List/Grid
SELECTION-SCREEN : END OF BLOCK B2.
START OF SELECTION
START-OF-SELECTION.
*--Populating the header data from VBAK
PERFORM POPULATE_VBAK.
*--Populating all icons from ICON table
PERFORM POPULATE_ICONS.
*--Populating the final dispaly table
PERFORM FINAL_POPULATION.
END OF SELECTION
END-OF-SELECTION.
IF NOT TB_VBAK[] IS INITIAL.
*--Populating the field catalog for final display table
PERFORM BUILD-FIELDCATALOG.
*--Modifying the field catalog table
PERFORM MODIFY_FIELDCATALOG.
*--Generating all the events into the table
PERFORM GET_EVENTS.
*--sorting the Final table
PERFORM SORT_TABLE.
*--Dispalying the Fianl ALV Table
PERFORM DISPLAY_TABLE.
ELSE.
MESSAGE I999 WITH 'No Records found for the selection criteria'(006)
ENDIF.
*& Form build-fieldcatalog
Populating the fieldcatalog table for the Final display
FORM BUILD-FIELDCATALOG .
DATA :L_TABNAME TYPE SLIS_TABNAME. " Table Name
L_TABNAME = 'TB_VBAK'.
REFRESH : TB_FIELDCAT.
CLEAR : TB_FIELDCAT.
*--calling a function to build fieldcatalog for header data
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = G_REPID
I_INTERNAL_TABNAME = L_TABNAME
I_INCLNAME = G_REPID
CHANGING
CT_FIELDCAT = TB_FIELDCAT
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " build-fieldcatalog
*& Form display_table
Module to display the ALV Grid/List
FORM DISPLAY_TABLE .
*--Layout settings
CLEAR X_LAYOUT.
X_LAYOUT-ZEBRA = C_X.
X_LAYOUT-COLWIDTH_OPTIMIZE = C_X.
X_LAYOUT-NO_COLHEAD = SPACE.
*--for list format settings
IF P_ALVDIS = C_X.
X_LAYOUT-NO_VLINE = C_X.
X_LAYOUT-NO_HLINE = C_X.
ENDIF.
*--Displaying the ALV
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = G_REPID
I_CALLBACK_PF_STATUS_SET = C_PF_STATUS
IS_LAYOUT = X_LAYOUT
IT_EVENTS = TB_EVENTS
IT_FIELDCAT = TB_FIELDCAT
IT_SORT = TB_SORT_ALV
TABLES
T_OUTTAB = TB_VBAK
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " display_table
*& Form get_events
Module to GET EVENTS for ALV Dispaly
FORM GET_EVENTS .
REFRESH : TB_EVENTS.
CLEAR : TB_EVENTS.
*--functin to get events
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = TB_EVENTS
EXCEPTIONS
LIST_TYPE_WRONG = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Modifing Top of Page event
READ TABLE TB_EVENTS WITH KEY NAME = SLIS_EV_TOP_OF_PAGE
INTO X_EVENTS.
CLEAR L_TABIX.
L_TABIX = SY-TABIX.
IF SY-SUBRC = 0.
X_EVENTS-FORM = C_TOP_OF_PAGE.
MODIFY TB_EVENTS FROM X_EVENTS INDEX L_TABIX.
CLEAR X_EVENTS.
ENDIF.
Modifing User comand event
READ TABLE TB_EVENTS WITH KEY NAME = SLIS_EV_USER_COMMAND
INTO X_EVENTS.
CLEAR L_TABIX.
L_TABIX = SY-TABIX.
IF SY-SUBRC = 0.
X_EVENTS-FORM = C_USER_COMMAND.
MODIFY TB_EVENTS FROM X_EVENTS INDEX L_TABIX.
CLEAR X_EVENTS.
ENDIF.
ENDFORM. " get_events
*& Form TOP_OF_PAGE
Top Of Page for the ALV format
FORM TOP_OF_PAGE.
DATA : L_DATE(02) TYPE C, "Date
L_MONTH(02) TYPE C, "Month
L_YEAR(04) TYPE C, "Year
L_DATE_INFO(10) TYPE C, "DATE
L_TEMP1(100) TYPE C, "temp
L_TEMP(100) TYPE C, "temp
L_TITLE(50) TYPE C. "title
CLEAR : TB_COMMENTS,
TB_COMMENTS[].
Filling Comments for Top of Page
X_COMMENTS-TYP = C_H.
L_TITLE = SY-TITLE.
X_COMMENTS-INFO = L_TITLE.
APPEND X_COMMENTS TO TB_COMMENTS.
CLEAR X_COMMENTS.
CLEAR :L_TEMP,L_TEMP1.
X_COMMENTS-TYP = C_S.
date
L_DATE = SY-DATUM+6(2).
L_MONTH = SY-DATUM+4(2).
L_YEAR = SY-DATUM+0(4).
L_TEMP = 'Date :'(005).
CONCATENATE L_YEAR '-' L_MONTH '-' L_DATE INTO L_DATE_INFO.
CONCATENATE L_TEMP L_DATE_INFO
INTO L_TEMP1 SEPARATED BY SPACE.
X_COMMENTS-INFO = L_TEMP1.
APPEND X_COMMENTS TO TB_COMMENTS.
*--Function to write Comments
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = TB_COMMENTS.
ENDFORM. " TOP_OF_PAGE
*& Form FINAL_POPULATION
Populating the FINAL table
FORM FINAL_POPULATION .
CLEAR SY-TABIX.
LOOP AT TB_VBAK.
L_TABIX = SY-TABIX.
IF TB_VBAK-NETWR <= 10.
READ TABLE TB_ICON WITH KEY NAME = C_GREEN BINARY SEARCH.
IF SY-SUBRC = 0.
TB_VBAK-INDICAT = TB_ICON-ID.
MODIFY TB_VBAK INDEX L_TABIX.
CLEAR TB_ICON.
ENDIF.
ELSEIF TB_VBAK-NETWR > 10 AND TB_VBAK-NETWR < 100.
READ TABLE TB_ICON WITH KEY NAME = C_YELLOW BINARY SEARCH.
IF SY-SUBRC = 0.
TB_VBAK-INDICAT = TB_ICON-ID.
MODIFY TB_VBAK INDEX L_TABIX.
CLEAR TB_ICON.
ENDIF.
ELSEIF TB_VBAK-NETWR => 100.
READ TABLE TB_ICON WITH KEY NAME = C_RED BINARY SEARCH.
IF SY-SUBRC = 0.
TB_VBAK-INDICAT = TB_ICON-ID.
MODIFY TB_VBAK INDEX L_TABIX.
CLEAR TB_ICON.
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM. " FINAL_POPULATION
*& Form MODIFY_FIELDCATALOG
Modifying the FIELD CATALOG
FORM MODIFY_FIELDCATALOG .
DATA: L_DDICTXT TYPE C VALUE 'L'. "FLAG
LOOP AT TB_FIELDCAT INTO X_FIELDCAT.
CLEAR L_TABIX.
L_TABIX = SY-TABIX.
CASE X_FIELDCAT-FIELDNAME.
WHEN 'INDICAT'. " icon
X_FIELDCAT-SELTEXT_L = 'Status indicator'(008).
X_FIELDCAT-DDICTXT = L_DDICTXT.
WHEN 'VBELN'. " sales doc
X_FIELDCAT-SELTEXT_L = 'Sales Doc #'(009).
X_FIELDCAT-DDICTXT = L_DDICTXT.
WHEN 'AUDAT'. " doc date
X_FIELDCAT-SELTEXT_L = 'Document Date'(010).
X_FIELDCAT-DDICTXT = L_DDICTXT.
WHEN 'VBTYP'. " doc category
X_FIELDCAT-SELTEXT_L = 'Category'(011).
X_FIELDCAT-DDICTXT = L_DDICTXT.
WHEN 'AUART'. " doc type
X_FIELDCAT-SELTEXT_L = 'Doc Type'(012).
X_FIELDCAT-DDICTXT = L_DDICTXT.
WHEN 'AUGRU'. " reason
X_FIELDCAT-SELTEXT_L = 'Reason'(013).
X_FIELDCAT-DDICTXT = L_DDICTXT.
WHEN 'WAERK'. " Currency unit
X_FIELDCAT-SELTEXT_L = 'Unit'(014).
X_FIELDCAT-DDICTXT = L_DDICTXT.
WHEN 'NETWR' . " Amount
X_FIELDCAT-SELTEXT_L = 'Net Value'(015).
X_FIELDCAT-DDICTXT = L_DDICTXT.
*-- TO display the total sum at the end.
X_FIELDCAT-DO_SUM = C_X.
ENDCASE.
MODIFY TB_FIELDCAT FROM X_FIELDCAT INDEX L_TABIX.
ENDLOOP.
ENDFORM. " MODIFY_FIELDCATALOG
*& Form SORT_TABLE
SORTING the ALV
FORM SORT_TABLE .
*--sorting the fields
CLEAR X_SORT.
X_SORT-SPOS = '1'.
X_SORT-FIELDNAME = 'AUART'.
X_SORT-TABNAME = 'TB_VBAK'.
X_SORT-UP = C_X.
APPEND X_SORT TO TB_SORT_ALV.
CLEAR X_SORT.
X_SORT-SPOS = '2'.
X_SORT-FIELDNAME = 'VBTYP'.
X_SORT-TABNAME = 'TB_VBAK'.
X_SORT-UP = C_X.
APPEND X_SORT TO TB_SORT_ALV.
CLEAR X_SORT.
X_SORT-SPOS = '3'.
X_SORT-FIELDNAME = 'WAERK'.
X_SORT-TABNAME = 'TB_VBAK'.
X_SORT-UP = C_X.
X_SORT-SUBTOT = C_X.
APPEND X_SORT TO TB_SORT_ALV.
ENDFORM. " SORT_TABLE
*& Form FRM_PF_STATUS
Customizing the PF-STATUS
FORM FRM_PF_STATUS USING EXTAB TYPE SLIS_T_EXTAB .
DATA: L_EXTAB TYPE SLIS_EXTAB.
CLEAR EXTAB[].
L_EXTAB-FCODE = '&EB9'.
APPEND L_EXTAB TO EXTAB.
L_EXTAB-FCODE = '&SUM'.
APPEND L_EXTAB TO EXTAB.
L_EXTAB-FCODE = '&OAD'.
APPEND L_EXTAB TO EXTAB.
L_EXTAB-FCODE = '&UMC'.
APPEND L_EXTAB TO EXTAB.
L_EXTAB-FCODE = '&AVE'.
APPEND L_EXTAB TO EXTAB.
L_EXTAB-FCODE = '&RNT'.
APPEND L_EXTAB TO EXTAB.
*--excluding some the tool buttons from the PF status
SET PF-STATUS 'PRACTICE_ALV' EXCLUDING EXTAB.
ENDFORM. " FRM_PF_STATUS
*& Form FRM_USER_COMMAND
USER COMMAND for the ALV event
FORM FRM_USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD .
CASE R_UCOMM.
WHEN '&IC1'.
READ TABLE TB_VBAK INDEX RS_SELFIELD-TABINDEX.
IF SY-SUBRC = 0.
*--selecting the line items for the selected VBELN
SELECT VBELN POSNR MATNR
FROM VBAP
INTO TABLE TB_VBAP
WHERE VBELN = TB_VBAK-VBELN.
IF SY-SUBRC = 0.
*--Perforrming the field catalog for line item table
PERFORM FIELDCAT_ITEM.
PERFORM DISPLAY_POPUP.
ELSE.
MESSAGE I999 WITH 'NO item data existing for the record'(007).
ENDIF.
ENDIF.
ENDCASE.
ENDFORM. " FRM_USER_COMMAND
*& Form FIELDCAT_ITEM
Build field catalog for the line items
FORM FIELDCAT_ITEM .
DATA : L_TABNAME TYPE SLIS_TABNAME.
L_TABNAME = 'TB_VBAP'.
CLEAR : TB_FIELDCAT1,TB_FIELDCAT1[].
*-- building catalog for line items
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = G_REPID
I_INTERNAL_TABNAME = L_TABNAME
I_INCLNAME = G_REPID
CHANGING
CT_FIELDCAT = TB_FIELDCAT1
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " FIELDCAT_ITEM
*& Form POPULATE_VBAK
Populating the Sales header data
FORM POPULATE_VBAK .
*-- selecting from VBAK
SELECT VBELN
AUDAT
VBTYP
AUART
AUGRU
NETWR
WAERK
INTO CORRESPONDING FIELDS OF TABLE TB_VBAK
FROM VBAK
WHERE AUDAT > P_AUDAT AND
NETWR > 0.
IF SY-SUBRC <> 0.
SORT TB_VBAK BY AUART VBTYP WAERK .
ENDIF.
ENDFORM. " POPULATE_VBAK
*& Form POPULATE_ICONS
Populating the ICON table
FORM POPULATE_ICONS .
*--selecting from ICON table
SELECT ID
NAME
INTO TABLE TB_ICON
FROM ICON.
IF SY-SUBRC = 0.
SORT TB_ICON BY NAME .
ENDIF.
ENDFORM. " POPULATE_ICONS
*& Form DISPLAY_POPUP
Displaying the POP UP with line item details
FORM DISPLAY_POPUP .
DATA: L_TITLE(40) TYPE C . " For pop up title
L_TITLE = 'Sales document Item Data'(004).
*--Function to display the pop up with line item details
CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'
EXPORTING
I_TITLE = L_TITLE
I_TABNAME = 'TB_VBAP'
IT_FIELDCAT = TB_FIELDCAT1
I_CALLBACK_PROGRAM = G_REPID
TABLES
T_OUTTAB = TB_VBAP
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " DISPLAY_POPUP
regards,
sateesh
Similar Messages
-
New Page in ALV GRID display.
HI Experts,
I have a requirement of displaying top of page and corresponding detailed records for specific combination of top of page(say plant,material,batch etc). Again for the next combination I need repeated header and detail list.
I guess I have to use NEW PAGE to get this.
However, I am using the REUSE ALV GRID DISPLAY for which the sort table does not display as required.
Could you please help me on this?
In addition could you please suggest how to use NEW page in report without using OOPS concept.
Please reply.
Thanks,
Suchi.Hi,
1.Put a pushbutton on the ALV o/p say 'Next'.
2. Now in the user comand routine you have to change the table contents u supply to reuse_alv_commentary write, also fill the o/p internal table with data corresponding to ur specific combination and supply to reuse_alv_grid_display.
3.In the user comand routine u have slis_selfield.
4.It contains a component refresh, mark it as 'X'.( slis_selfield-refresh = 'X'.)
5.No need of new page or calling reus_alv_grid_display number of times.
Regards,
Phani.
Maybe you are looking for
-
I changed my AppleID / email address after my old email expired, and now whenever I go to sign into iCloud on my computer it still shows my OLD AppleID in the log-in and it won't let me change it. So I can't sign into iCloud! I can still sign into iT
-
PSE 9.0.1 Runtime Error in Organizer
Good Day All, I am running Windows XP Pro. Recently instlled PSE 9 and I cannot get the organizer to launch. The editor seems to work okay but every time I try and launch the organizer I get the following. Is there a solution set? While I see many si
-
HD series "cannot be played"?
I downloaded the entire first season of Mad Men in HD. Now, my Apple TV won't sync because "they cannot be played on this Apple TV." Can I do anything or have I just wasted the money. I've looked through all the settings...and read through many of th
-
Errors using aCC 3.31--- Unexpected 'std'
[Compilation Errors using aCC 3.31/HP-UX 11.0 -- Unexpected 'std'] Hi, I get the following errors when I try to include 'occi.h' in my programs while working with the OCCI classes for Oracle9i database connectivity. Please let
-
27" won't let me switch sound to headphone
Hi, I just bought a 27 inch Cinema Display and I'm having an issue where OS X won't let me switch from the display's USB sound to my headphone jack (where I have external speakers connected). When I go to the Sound preferences item and change the dev