Skip to Content
1
Former Member
Jul 20, 2007 at 12:49 PM

ALV Problem

36 Views

Hi all,

I m doing this alv program but i m unable to get top of page, end of list.

Plz suggest what can be done.

Below i m giving my code.

<code>&----


*& Report ZSAMPLEALV3 *

*& *

&----


*& *

*& *

&----


REPORT ZSAMPLEALV3

MESSAGE-ID Z00.

************************************************************************

  • TABLE DECLARATIONS

************************************************************************

TABLES : EKKO. "Purchasing Document Header

************************************************************************

  • CONSTANTS DECLARATIONS

************************************************************************

CONSTANTS : C_EBELN(5) VALUE 'EBELN'.

************************************************************************

  • DATA DECLARATIONS

************************************************************************

DATA : V_FLAG, "For Select Status

V_DATA(50). "To Store Data

************************************************************************

  • TYPE DECLARATIONS FOR ALV *

************************************************************************

TYPE-POOLS : SLIS.

*Type Declarations for Field Catalog for Basic List

DATA : I_FLDCAT_HEAD TYPE SLIS_T_FIELDCAT_ALV,

WA_FLDCAT_HEAD TYPE SLIS_FIELDCAT_ALV.

*Type Declarations for Field Catalog for Secondary List

DATA : I_FLDCAT_ITEM TYPE SLIS_T_FIELDCAT_ALV,

WA_FLDCAT_ITEM TYPE SLIS_FIELDCAT_ALV.

*Type Declarations for Displaying Images on Basic Grid

DATA : I_COMMENT TYPE SLIS_T_LISTHEADER,

WA_COMMENT TYPE SLIS_LISTHEADER.

*Type Declarations for Displaying Images on Secondary Grid

DATA : I_COMMENT_SEC TYPE SLIS_T_LISTHEADER,

WA_COMMENT_SEC TYPE SLIS_LISTHEADER.

*Type Declarations for ALV Events for Basic Grid

DATA : I_EVENTS TYPE SLIS_T_EVENT,

WA_EVENT LIKE LINE OF I_EVENTS.

*Type Declarations for ALV Events for Secondary Grid

DATA : I_EVENTS_SEC TYPE SLIS_T_EVENT,

WA_EVENT_SEC LIKE LINE OF I_EVENTS.

*Type Declarations for Layout Design

DATA : WA_LAYOUT TYPE SLIS_LAYOUT_ALV.

*Type Declarations for Linking the fields

DATA : WA_KEYINFO TYPE SLIS_KEYINFO_ALV.

************************************************************************

  • INTERNAL TABLE DECLARATIONS

************************************************************************

*--Internal Table for Basic List

DATA : BEGIN OF IT_FINAL_BAS OCCURS 0,

EBELN LIKE EKKO-EBELN, "Purchasing Document Number

BUKRS LIKE EKKO-BUKRS, "Company Code

AEDAT LIKE EKKO-AEDAT, "Date on which the record was created

EKORG LIKE EKKO-EKORG, "Purchasing Organization

EKGRP LIKE EKKO-EKGRP, "Purchasing group

COLOR(3), "For applying color

END OF IT_FINAL_BAS.

*--Internal Table for Secondary List

DATA : BEGIN OF IT_FINAL_SEC OCCURS 0,

EBELN LIKE EKPO-EBELN, "Purchasing Document Number

MATNR LIKE EKPO-MATNR, "Material Number

TXZ01 LIKE EKPO-TXZ01, "Material Desc

WERKS LIKE EKPO-WERKS, "Plant

LGORT LIKE EKPO-LGORT, "Location

MATKL LIKE EKPO-MATKL, "Material Group

MENGE LIKE EKPO-MENGE, "Purchase order quantity

MEINS LIKE EKPO-MEINS, "Order unit

NETPR LIKE EKPO-NETPR, "Net price in purchasing document (in document currency)

NETWR LIKE EKPO-NETWR, "Net order value in PO currency

DUMMY LIKE ICON-ID, "For placing Icon

COLOR(3), "For applying color

END OF IT_FINAL_SEC.

*--Internal Table for Secondary List with selected records

DATA : BEGIN OF I_ITEM_DISPLAY OCCURS 0,

EBELN LIKE EKPO-EBELN, "Purchasing Document Number

MATNR LIKE EKPO-MATNR, "Material Number

TXZ01 LIKE EKPO-TXZ01, "Material Desc

WERKS LIKE EKPO-WERKS, "Plant

LGORT LIKE EKPO-LGORT, "Location

MATKL LIKE EKPO-MATKL, "Material Group

MENGE LIKE EKPO-MENGE, "Purchase order quantity

MEINS LIKE EKPO-MEINS, "Order unit

NETPR LIKE EKPO-NETPR, "Net price in purchasing document (in document currency)

NETWR LIKE EKPO-NETWR, "Net order value in PO currency

DUMMY LIKE ICON-ID, "For placing Icon

COLOR(3), "For applying color

END OF I_ITEM_DISPLAY.

************************************************************************

  • SELECTION SCREEN

************************************************************************

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-H01.

SELECT-OPTIONS: S_EBELN FOR EKKO-EBELN.

SELECTION-SCREEN END OF BLOCK B1.

************************************************************************

  • Event : INITIALIZATION

************************************************************************

INITIALIZATION.

MOVE 'Developed by'(001) TO V_DATA.

************************************************************************

  • Event : AT SELECTION SCREEN

************************************************************************

AT SELECTION-SCREEN.

PERFORM VALIDATE_EBELN.

************************************************************************

  • Event : START-OF-SELECTION

************************************************************************

START-OF-SELECTION.

*--Getting the Data

PERFORM GET_DATA.

*--Generating the Field catalog for basic and secondary grid

PERFORM GET_FLDCAT.

*--Generating the Layout for basic and secondary grid

PERFORM GET_LAYOUT.

*--Generating the key infor to link Basic grid to Secondary grid

PERFORM GET_KEYINFO.

*--Generating the Events for Basic and Secondary Grid

PERFORM GET_EVENTS.

************************************************************************

  • Event : END-OF-SELECTION

************************************************************************

END-OF-SELECTION.

IF V_FLAG EQ 'X'.

*--Generating Basic List

PERFORM DISP_BASIC_LIST.

ELSE.

MESSAGE I010 WITH 'No Data Found To Display'(002).

ENDIF.

*///////////////////////////////////////////////////////////////////////

************************************************************************

  • SUB-ROUTINES

************************************************************************

*///////////////////////////////////////////////////////////////////////

&----


*& Form VALIDATE_EBELN

&----


  • Validating the PO No

----


FORM VALIDATE_EBELN .

SELECT EBELN

UP TO 1 ROWS

INTO (EKKO-EBELN)

FROM EKKO

WHERE EBELN IN S_EBELN.

ENDSELECT.

IF SY-SUBRC NE 0.

MESSAGE I010 WITH 'Invalid PO No'(003) S_EBELN-LOW 'To'(004) S_EBELN-HIGH.

ENDIF.

ENDFORM. " VALIDATE_EBELN

&----


*& Form GET_DATA

&----


  • Getting Basic List and Secondary List Data

----


FORM GET_DATA .

*--Getting Basic List Data

SELECT EBELN "PO No

BUKRS "Company Code

AEDAT "Creation Date

EKORG "Purch Org

EKGRP "Purch Group

INTO TABLE IT_FINAL_BAS

FROM EKKO

WHERE EBELN IN S_EBELN.

*--Getting Secondary List Data

IF SY-SUBRC EQ 0.

SELECT EBELN "PO No

MATNR "Material No

TXZ01 "Material Desc

WERKS "Plant

LGORT "Location

MATKL "Material Group

MENGE "PO Qty

MEINS "Unit

NETPR "Net Price

NETWR "Net Value

INTO TABLE IT_FINAL_SEC

FROM EKPO

WHERE EBELN IN S_EBELN.

ENDIF.

IF SY-SUBRC EQ 0.

V_FLAG = 'X'.

ELSE.

V_FLAG = SPACE.

ENDIF.

ENDFORM. " GET_DATA

&----


*& Form GET_FLDCAT

&----


  • Generating the Field Catalog

----


FORM GET_FLDCAT .

*--Generating the Field Catalog for Basic List

WA_FLDCAT_HEAD-FIELDNAME = 'EBELN'(005).

WA_FLDCAT_HEAD-COL_POS = '1'.

WA_FLDCAT_HEAD-JUST = 'C'.

WA_FLDCAT_HEAD-OUTPUTLEN = '12'.

WA_FLDCAT_HEAD-SELTEXT_M = 'PO Number'(006).

WA_FLDCAT_HEAD-DDICTXT = 'M'.

WA_FLDCAT_HEAD-REF_TABNAME = ' '.

WA_FLDCAT_HEAD-HOTSPOT = 'X'.

APPEND WA_FLDCAT_HEAD TO I_FLDCAT_HEAD.

CLEAR WA_FLDCAT_HEAD .

WA_FLDCAT_HEAD-FIELDNAME = 'BUKRS'(007).

WA_FLDCAT_HEAD-COL_POS = '2'.

WA_FLDCAT_HEAD-OUTPUTLEN = '12'.

WA_FLDCAT_HEAD-SELTEXT_M = 'Company Code'(008).

WA_FLDCAT_HEAD-DDICTXT = 'M'.

APPEND WA_FLDCAT_HEAD TO I_FLDCAT_HEAD.

WA_FLDCAT_HEAD-FIELDNAME = 'AEDAT'(009).

WA_FLDCAT_HEAD-COL_POS = '3'.

WA_FLDCAT_HEAD-OUTPUTLEN = '10'.

WA_FLDCAT_HEAD-SELTEXT_M = 'PO Date'(010).

WA_FLDCAT_HEAD-DDICTXT = 'M'.

APPEND WA_FLDCAT_HEAD TO I_FLDCAT_HEAD.

WA_FLDCAT_HEAD-FIELDNAME = 'EKORG'(011).

WA_FLDCAT_HEAD-COL_POS = '4'.

WA_FLDCAT_HEAD-OUTPUTLEN = '6'.

WA_FLDCAT_HEAD-SELTEXT_M = 'PO Org'(012).

WA_FLDCAT_HEAD-DDICTXT = 'M'.

APPEND WA_FLDCAT_HEAD TO I_FLDCAT_HEAD.

WA_FLDCAT_HEAD-FIELDNAME = 'EKGRP'(013).

WA_FLDCAT_HEAD-COL_POS = '5'.

WA_FLDCAT_HEAD-OUTPUTLEN = '8'.

WA_FLDCAT_HEAD-SELTEXT_M = 'PO Group'(014).

WA_FLDCAT_HEAD-DDICTXT = 'M'.

WA_FLDCAT_HEAD-DO_SUM = 'X'.

APPEND WA_FLDCAT_HEAD TO I_FLDCAT_HEAD.

*--Generating the Field Catalog for Basic List

WA_FLDCAT_ITEM-FIELDNAME = 'EBELN'(005).

WA_FLDCAT_ITEM-COL_POS = '1'.

WA_FLDCAT_ITEM-JUST = 'C'.

WA_FLDCAT_ITEM-OUTPUTLEN = '12'.

WA_FLDCAT_ITEM-SELTEXT_M = 'PO Number'(006).

WA_FLDCAT_ITEM-DDICTXT = 'M'.

WA_FLDCAT_ITEM-REF_TABNAME = ' '.

APPEND WA_FLDCAT_ITEM TO I_FLDCAT_ITEM.

WA_FLDCAT_ITEM-FIELDNAME = 'MATNR'(015).

WA_FLDCAT_ITEM-COL_POS = '2'.

WA_FLDCAT_ITEM-JUST = 'C'.

WA_FLDCAT_ITEM-OUTPUTLEN = '18'.

WA_FLDCAT_ITEM-SELTEXT_M = 'Item Number'(016).

WA_FLDCAT_ITEM-DDICTXT = 'M'.

WA_FLDCAT_ITEM-REF_TABNAME = ' '.

APPEND WA_FLDCAT_ITEM TO I_FLDCAT_ITEM.

WA_FLDCAT_ITEM-FIELDNAME = 'TXZ01'(017).

WA_FLDCAT_ITEM-COL_POS = '3'.

WA_FLDCAT_ITEM-JUST = 'C'.

WA_FLDCAT_ITEM-OUTPUTLEN = '40'.

WA_FLDCAT_ITEM-SELTEXT_M = 'Item Desc'(018).

WA_FLDCAT_ITEM-DDICTXT = 'M'.

APPEND WA_FLDCAT_ITEM TO I_FLDCAT_ITEM.

WA_FLDCAT_ITEM-FIELDNAME = 'WERKS'(019).

WA_FLDCAT_ITEM-COL_POS = '4'.

WA_FLDCAT_ITEM-JUST = 'C'.

WA_FLDCAT_ITEM-OUTPUTLEN = '6'.

WA_FLDCAT_ITEM-SELTEXT_M = 'Plant'(020).

WA_FLDCAT_ITEM-DDICTXT = 'M'.

APPEND WA_FLDCAT_ITEM TO I_FLDCAT_ITEM.

WA_FLDCAT_ITEM-FIELDNAME = 'LGORT'(021).

WA_FLDCAT_ITEM-COL_POS = '5'.

WA_FLDCAT_ITEM-JUST = 'C'.

WA_FLDCAT_ITEM-OUTPUTLEN = '9'.

WA_FLDCAT_ITEM-SELTEXT_M = 'Location'(022).

WA_FLDCAT_ITEM-DDICTXT = 'M'.

APPEND WA_FLDCAT_ITEM TO I_FLDCAT_ITEM.

WA_FLDCAT_ITEM-FIELDNAME = 'MATKL'(023).

WA_FLDCAT_ITEM-COL_POS = '6'.

WA_FLDCAT_ITEM-JUST = 'C'.

WA_FLDCAT_ITEM-OUTPUTLEN = '10'.

WA_FLDCAT_ITEM-SELTEXT_M = 'Mat Group'(024).

WA_FLDCAT_ITEM-DDICTXT = 'M'.

APPEND WA_FLDCAT_ITEM TO I_FLDCAT_ITEM.

WA_FLDCAT_ITEM-FIELDNAME = 'MENGE'(025).

WA_FLDCAT_ITEM-COL_POS = '7'.

WA_FLDCAT_ITEM-JUST = 'C'.

WA_FLDCAT_ITEM-OUTPUTLEN = '17'.

WA_FLDCAT_ITEM-SELTEXT_M = 'PO Qty'(026).

WA_FLDCAT_ITEM-DDICTXT = 'M'.

APPEND WA_FLDCAT_ITEM TO I_FLDCAT_ITEM.

WA_FLDCAT_ITEM-FIELDNAME = 'MEINS'(027).

WA_FLDCAT_ITEM-COL_POS = '8'.

WA_FLDCAT_ITEM-JUST = 'C'.

WA_FLDCAT_ITEM-OUTPUTLEN = '3'.

WA_FLDCAT_ITEM-SELTEXT_M = 'Unit'(028).

WA_FLDCAT_ITEM-DDICTXT = 'M'.

APPEND WA_FLDCAT_ITEM TO I_FLDCAT_ITEM.

WA_FLDCAT_ITEM-FIELDNAME = 'NETPR'(029).

WA_FLDCAT_ITEM-COL_POS = '9'.

WA_FLDCAT_ITEM-JUST = 'C'.

WA_FLDCAT_ITEM-OUTPUTLEN = '14'.

WA_FLDCAT_ITEM-SELTEXT_M = 'Net Price'(037).

WA_FLDCAT_ITEM-DDICTXT = 'M'.

APPEND WA_FLDCAT_ITEM TO I_FLDCAT_ITEM.

WA_FLDCAT_ITEM-FIELDNAME = 'NETWR'(030).

WA_FLDCAT_ITEM-COL_POS = '10'.

WA_FLDCAT_ITEM-JUST = 'C'.

WA_FLDCAT_ITEM-OUTPUTLEN = '16'.

WA_FLDCAT_ITEM-SELTEXT_M = 'Net Value'(031).

WA_FLDCAT_ITEM-DDICTXT = 'M'.

APPEND WA_FLDCAT_ITEM TO I_FLDCAT_ITEM.

WA_FLDCAT_ITEM-FIELDNAME = 'DUMMY'(038).

WA_FLDCAT_ITEM-COL_POS = '11'.

WA_FLDCAT_ITEM-JUST = 'C'.

WA_FLDCAT_ITEM-OUTPUTLEN = '3'.

WA_FLDCAT_ITEM-SELTEXT_M = 'Status'(039).

WA_FLDCAT_ITEM-DDICTXT = 'M'.

WA_FLDCAT_ITEM-ICON = 'X'.

APPEND WA_FLDCAT_ITEM TO I_FLDCAT_ITEM.

ENDFORM. " GET_FLDCAT

&----


*& Form DISP_BASIC_LIST

&----


  • Generating the Basic List

----


FORM DISP_BASIC_LIST .

*--Applying the color to record in Basic List

  • LOOP AT IT_FINAL_BAS.

  • IF IT_FINAL_BAS-BUKRS LE 1000.

  • IT_FINAL_BAS-COLOR = 'C21'.

  • ELSEIF IT_FINAL_BAS-BUKRS GT 1000 AND IT_FINAL_BAS-BUKRS LE 2000.

  • IT_FINAL_BAS-COLOR = 'C41'.

  • ELSEIF IT_FINAL_BAS-BUKRS GT 2000 AND IT_FINAL_BAS-BUKRS LE 3000.

  • IT_FINAL_BAS-COLOR = 'C71'.

  • ELSEIF IT_FINAL_BAS-BUKRS GT 3000.

  • IT_FINAL_BAS-COLOR = 'C51'.

  • ENDIF.

  • MODIFY IT_FINAL_BAS INDEX SY-TABIX.

  • ENDLOOP.

*--Generating the Grid output

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = 'Z_SAMPLE_ALV'

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

  • I_CALLBACK_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

I_BACKGROUND_ID = 'PLAIN_BACKGROUND'

  • I_GRID_TITLE =

  • I_GRID_SETTINGS =

IS_LAYOUT = WA_LAYOUT

IT_FIELDCAT = I_FLDCAT_HEAD

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

IT_EVENTS = I_EVENTS

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IT_EXCEPT_QINFO =

  • I_HTML_HEIGHT_TOP =

  • I_HTML_HEIGHT_END =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

T_OUTTAB = IT_FINAL_BAS

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. " DISP_BASIC_LIST

&----


*& Form GET_EVENTS

&----


  • Getting the ALV Events

----


FORM GET_EVENTS .

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

I_LIST_TYPE = 0

IMPORTING

ET_EVENTS = I_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.

*--Calling the User Defined sub-routines for ALV Events

IF NOT I_EVENTS[] IS INITIAL.

READ TABLE I_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.

WA_EVENT-FORM = 'GENERATE_USERCOMMAND_HEADER'.

MODIFY I_EVENTS FROM WA_EVENT INDEX SY-TABIX.

READ TABLE I_EVENTS INTO WA_EVENT WITH KEY NAME = 'END_OF_LIST'.

WA_EVENT-FORM = 'GENERATE_USERCOMMAND_FOOTER'.

MODIFY I_EVENTS FROM WA_EVENT INDEX SY-TABIX.

READ TABLE I_EVENTS INTO WA_EVENT WITH KEY NAME = 'USER_COMMAND'.

WA_EVENT-FORM = 'GENERATE_USERCOMMAND3'.

MODIFY I_EVENTS FROM WA_EVENT INDEX SY-TABIX.

ENDIF.

ENDFORM. " GET_EVENTS

&----


*& Form GENERATE_USERCOMMAND_HEADER

&----


  • Displaying Header-Text and Logo on Grid

----


FORM GENERATE_USERCOMMAND_HEADER.

CLEAR I_COMMENT[].

WA_COMMENT-TYP = 'H'.

WA_COMMENT-INFO = 'General Purchase Order Info'(032).

APPEND WA_COMMENT TO I_COMMENT.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

IT_LIST_COMMENTARY = I_COMMENT

I_LOGO = 'ENJOYSAP_LOGO'.

  • I_END_OF_LIST_GRID = 'X'.

ENDFORM. " GENERATE_USERCOMMAND

&----


*& Form GENERATE_USERCOMMAND_FOOTER

&----


  • Displaying Footer-Text

----


FORM GENERATE_USERCOMMAND_FOOTER .

CLEAR I_COMMENT[].

WA_COMMENT-TYP = 'S'.

WA_COMMENT-KEY = V_DATA.

WA_COMMENT-INFO = 'Sathish Borancha'(033).

APPEND WA_COMMENT TO I_COMMENT.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

IT_LIST_COMMENTARY = I_COMMENT

  • I_LOGO = ''

I_END_OF_LIST_GRID = 'X'.

ENDFORM. " GENERATE_USERCOMMAND_FOOTER

&----


*& Form GENERATE_USERCOMMAND3

&----


  • Getting the F-Code and Calling Secondary List

----


  • --> P_UCOMM LIKE SY-UCOMM

  • --> P_SELFIELD TYPE SLIS_SELFIELD

----


FORM GENERATE_USERCOMMAND3 USING P_UCOMM LIKE SY-UCOMM

P_SELFIELD TYPE SLIS_SELFIELD.

CASE P_UCOMM.

WHEN '&IC1'. "DOUBLE CLICK Func-Code

READ TABLE IT_FINAL_BAS INDEX P_SELFIELD-TABINDEX.

REFRESH I_ITEM_DISPLAY.

*--Applying the color to record in Secondary List

LOOP AT IT_FINAL_SEC WHERE EBELN = IT_FINAL_BAS-EBELN.

IF IT_FINAL_SEC-NETPR EQ 0.

IT_FINAL_SEC-DUMMY = '@0A@'.

IT_FINAL_SEC-COLOR = 'C61'.

ELSEIF IT_FINAL_SEC-NETPR GT 0 AND IT_FINAL_SEC-NETPR LE 200.

IT_FINAL_SEC-DUMMY = '@09@'.

IT_FINAL_SEC-COLOR = 'C41'.

ELSEIF IT_FINAL_SEC-NETPR GT 200 AND IT_FINAL_SEC-NETPR LE 1000.

IT_FINAL_SEC-DUMMY = '@08@'.

IT_FINAL_SEC-COLOR = 'C71'.

ELSEIF IT_FINAL_SEC-NETPR GT 1000.

IT_FINAL_SEC-DUMMY = '@6P@'.

IT_FINAL_SEC-COLOR = 'C51'.

ENDIF.

MODIFY IT_FINAL_SEC INDEX SY-TABIX.

MOVE-CORRESPONDING IT_FINAL_SEC TO I_ITEM_DISPLAY.

APPEND I_ITEM_DISPLAY.

CLEAR I_ITEM_DISPLAY.

ENDLOOP.

*--Getting the ALV Events of Secondary List

PERFORM GET_EVENTS_SEC.

*--Generating the ALV Secondary Grid output

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = 'ZSAMPLEALV3'

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

  • I_STRUCTURE_NAME =

I_BACKGROUND_ID = 'PLAIN_BACKGROUND'

IS_LAYOUT = WA_LAYOUT

IT_FIELDCAT = I_FLDCAT_ITEM

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

IT_EVENTS = I_EVENTS_SEC

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

T_OUTTAB = I_ITEM_DISPLAY

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.

ENDCASE.

ENDFORM. " GENERATE_USERCOMMAND3

&----


*& Form GET_LAYOUT

&----


  • Generating the Layout

----


FORM GET_LAYOUT .

WA_LAYOUT-COLWIDTH_OPTIMIZE = 'X'. "OPTIMIZING FIELD WIDTH

WA_LAYOUT-ZEBRA = 'X'. "PUTTING ZEBRA COLORS

WA_LAYOUT-INFO_FIELDNAME = 'COLOR'(034). "APPLYING COLORS TO ROWS

ENDFORM. " GET_LAYOUT

&----


*& Form GET_KEYINFO

&----


  • Getting Key info

----


FORM GET_KEYINFO .

*--Linking the Basic List to Secondary List

WA_KEYINFO-HEADER01 = C_EBELN.

WA_KEYINFO-ITEM01 = C_EBELN.

ENDFORM. " GET_KEYINFO

&----


*& Form GET_EVENTS_SEC

&----


  • Getting Secondary List Events

----


FORM GET_EVENTS_SEC .

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

  • EXPORTING

  • I_LIST_TYPE = 0

IMPORTING

ET_EVENTS = I_EVENTS_SEC

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.

*--Calling user-defined sub-routines for Secondary List

IF NOT I_EVENTS_SEC[] IS INITIAL.

READ TABLE I_EVENTS_SEC INTO WA_EVENT_SEC WITH KEY NAME = 'TOP_OF_PAGE'.

WA_EVENT_SEC-FORM = 'GENERATE_USERCOMMAND_H_SEC'.

MODIFY I_EVENTS_SEC FROM WA_EVENT_SEC INDEX SY-TABIX.

READ TABLE I_EVENTS_SEC INTO WA_EVENT_SEC WITH KEY NAME = 'END_OF_LIST'.

WA_EVENT_SEC-FORM = 'GENERATE_USERCOMMAND_F_SEC'.

MODIFY I_EVENTS_SEC FROM WA_EVENT_SEC INDEX SY-TABIX.

ENDIF.

ENDFORM. " GET_EVENTS_SEC

&----


*& Form GENERATE_USERCOMMAND_H_SEC

&----


  • Displaying Header-Text and Logo on Grid For Secondary List

----


FORM GENERATE_USERCOMMAND_H_SEC.

CLEAR I_COMMENT_SEC[].

WA_COMMENT_SEC-TYP = 'H'.

WA_COMMENT_SEC-INFO = 'Purchase Order Info'(035).

APPEND WA_COMMENT_SEC TO I_COMMENT_SEC.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

IT_LIST_COMMENTARY = I_COMMENT_SEC

I_LOGO = 'ENJOYSAP_LOGO'.

  • I_END_OF_LIST_GRID = 'X'.

ENDFORM. " GENERATE_USERCOMMAND_H_SEC

&----


*& Form GENERATE_USERCOMMAND_F_SEC

&----


  • Displaying Footer-Text for Secondary List

----


FORM GENERATE_USERCOMMAND_F_SEC.

CLEAR I_COMMENT_SEC[].

WA_COMMENT_SEC-TYP = 'S'.

WA_COMMENT_SEC-KEY = V_DATA.

WA_COMMENT_SEC-INFO = 'Rajesh'(036).

APPEND WA_COMMENT_SEC TO I_COMMENT_SEC.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

IT_LIST_COMMENTARY = I_COMMENT_SEC

  • I_LOGO = ''

I_END_OF_LIST_GRID = 'X'.

ENDFORM. " GENERATE_USERCOMMAND_F_SEC

</code>

Regards,

Karthik