Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

secondary list

Former Member
0 Likes
680

how tocreate secondary list in alv reports.

how tocreate secondary list in alv reports.

5 REPLIES 5
Read only

Former Member
0 Likes
660

hi,

hope this helps you.

http://voiceofabap.blogspot.com/2008/04/display-secondary-list-using-alv-grid.html

reward if useful.

regards

srishti

Read only

Former Member
Read only

Former Member
0 Likes
660

Hi,

Click this link for sample code for secondary list in ALV:

Regards,

KK

Read only

Former Member
0 Likes
660

hi,

see the below example.

TYPE-POOLS: SLIS.

TABLES: VBAK,

VBAP.

TYPES: BEGIN OF TY_VBAK,

VBELN TYPE VBELN_VA,

ERDAT TYPE ERDAT,

ERNAM TYPE ERNAM ,

END OF TY_VBAK.

TYPES: BEGIN OF TY_VBAP,

VBELN TYPE VBELN_VA,

POSNR TYPE POSNR_VA,

MATNR TYPE MATNR,

MATKL TYPE MATKL,

NETWR TYPE NETWR_AP,

END OF TY_VBAP,

BEGIN OF TY_MARA,

MATNR TYPE MATNR,

MBRSH TYPE MBRSH,

MTART TYPE MTART,

END OF TY_MARA.

DATA: T_VBAK TYPE TABLE OF TY_VBAK,

T_VBAP TYPE TABLE OF TY_VBAP,

T_MARA TYPE TABLE OF TY_MARA,

W_VBAK TYPE TY_VBAK,

W_VBAP TYPE TY_VBAP,

W_MARA TYPE TY_MARA.

DATA: T_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,

W_FIELDCAT TYPE SLIS_FIELDCAT_ALV,

I_EVENT TYPE SLIS_T_EVENT ,

W_EVENT TYPE SLIS_ALV_EVENT.

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

SELECT-OPTIONS: S_VBELN FOR VBAK-VBELN.

SELECTION-SCREEN: END OF BLOCK B1.

PERFORM POPULATE_DATA.

PERFORM FIELDCAT.

PERFORM EVENTS_GET.

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

SELECT-OPTIONS: S_VBELN FOR VBAK-VBELN.

SELECTION-SCREEN: END OF BLOCK B1.

PERFORM POPULATE_DATA.

PERFORM FIELDCAT.

PERFORM EVENTS_GET.

FORM POPULATE_DATA .

SELECT VBELN

FROM VBAK INTO TABLE T_VBAK

WHERE VBELN IN S_VBELN.

IF SY-SUBRC = 0.

SELECT VBELN

POSNR

MATNR

MATKL

NETWR

FROM VBAP INTO TABLE T_VBAP FOR ALL ENTRIES IN T_VBAK

WHERE VBELN = T_VBAK-VBELN.

SORT T_VBAP BY VBELN .

ENDIF.

ENDFORM.

FORM FIELDCAT .

W_FIELDCAT-COL_POS = 1.

W_FIELDCAT-FIELDNAME = 'VBELN'.

W_FIELDCAT-TABNAME = 'T_VBAP'.

  • w_fieldcat-do_sum = .

  • W_FIELDCAT-KEY = 'X'.

W_FIELDCAT-SELTEXT_M = 'SALES DOCU'.

W_FIELDCAT-OUTPUTLEN = 20.

APPEND W_FIELDCAT TO T_FIELDCAT.

CLEAR W_FIELDCAT.

W_FIELDCAT-COL_POS = 2.

W_FIELDCAT-FIELDNAME = 'POSNR'.

W_FIELDCAT-TABNAME = 'T_VBAP'.

  • w_fieldcat-do_sum = .

  • w_fieldcat-key = 'X'.

W_FIELDCAT-SELTEXT_M = 'ITEM DETAILS'.

W_FIELDCAT-OUTPUTLEN = 20.

APPEND W_FIELDCAT TO T_FIELDCAT.

CLEAR W_FIELDCAT.

W_FIELDCAT-COL_POS = 3.

W_FIELDCAT-FIELDNAME = 'MATNR'.

W_FIELDCAT-TABNAME = 'T_VBAP'.

  • w_fieldcat-do_sum = .

W_FIELDCAT-KEY = 'X'.

W_FIELDCAT-SELTEXT_M = 'MATERIAL NO'.

W_FIELDCAT-OUTPUTLEN = 20.

APPEND W_FIELDCAT TO T_FIELDCAT.

CLEAR W_FIELDCAT.

W_FIELDCAT-COL_POS = 4.

W_FIELDCAT-FIELDNAME = 'MATKL'.

W_FIELDCAT-TABNAME = 'T_VBAP'.

  • w_fieldcat-do_sum = .

  • w_fieldcat-key = 'X'.

W_FIELDCAT-SELTEXT_M = 'MATERIAL DESC'.

W_FIELDCAT-OUTPUTLEN = 20.

APPEND W_FIELDCAT TO T_FIELDCAT.

CLEAR W_FIELDCAT.

W_FIELDCAT-COL_POS = 5.

W_FIELDCAT-FIELDNAME = 'NETWR'.

W_FIELDCAT-TABNAME = 'T_VBAP'.

W_FIELDCAT-DO_SUM = 'X'.

  • w_fieldcat-key = 'X'.

W_FIELDCAT-SELTEXT_M = 'NET PRICE'.

W_FIELDCAT-OUTPUTLEN = 20.

APPEND W_FIELDCAT TO T_FIELDCAT.

CLEAR W_FIELDCAT.

ENDFORM. " fieldcat

&----


*& Form display

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM DISPLAY .

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = SY-REPID

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

  • I_CALLBACK_TOP_OF_PAGE = 'LISTHEADER'

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

  • I_GRID_TITLE =

  • I_GRID_SETTINGS =

  • IS_LAYOUT =

IT_FIELDCAT = T_FIELDCAT

IT_EXCLUDING = I_EXCLUDING

  • IT_SPECIAL_GROUPS =

  • IT_SORT = i_sort

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

IT_EVENTS = I_EVENT

  • 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

  • I_HTML_HEIGHT_TOP = 0

  • I_HTML_HEIGHT_END = 0

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IT_EXCEPT_QINFO =

  • IR_SALV_FULLSCREEN_ADAPTER =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

T_OUTTAB = T_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

FORM EVENTS_GET .

W_EVENT-NAME = 'USER_COMMAND'.

W_EVENT-FORM = 'USER_COMMAND'.

APPEND W_EVENT TO I_EVENT.

CLEAR W_EVENT.

ENDFORM.

FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM HIDE TYPE SLIS_SELFIELD.

DATA: H_MATNR TYPE MATNR.

H_MATNR = HIDE-VALUE.

SELECT MATNR MBRSH MTART FROM MARA INTO TABLE T_MARA WHERE MATNR = H_MATNR.

DATA: T_FIELDCAT1 TYPE SLIS_T_FIELDCAT_ALV,

W_FIELDCAT1 TYPE SLIS_FIELDCAT_ALV.

W_FIELDCAT1-COL_POS = 1.

W_FIELDCAT1-FIELDNAME = 'MATNR'.

W_FIELDCAT1-TABNAME = 'T_MATNR'.

  • w_fieldcat-do_sum = .

  • W_FIELDCAT-KEY = 'X'.

W_FIELDCAT1-SELTEXT_M = 'MATERIAL NUMBER'.

W_FIELDCAT1-OUTPUTLEN = 20.

APPEND W_FIELDCAT1 TO T_FIELDCAT1.

CLEAR W_FIELDCAT1.

W_FIELDCAT1-COL_POS = 2.

W_FIELDCAT1-FIELDNAME = 'MBRSH'.

W_FIELDCAT1-TABNAME = 'T_MATNR'.

  • w_fieldcat-do_sum = .

  • W_FIELDCAT-KEY = 'X'.

W_FIELDCAT1-SELTEXT_M = 'MATERIAL TYPE'.

W_FIELDCAT1-OUTPUTLEN = 20.

APPEND W_FIELDCAT1 TO T_FIELDCAT1.

CLEAR W_FIELDCAT1.

W_FIELDCAT1-COL_POS = 3.

W_FIELDCAT1-FIELDNAME = 'MTART'.

W_FIELDCAT1-TABNAME = 'T_MATNR'.

  • w_fieldcat-do_sum = .

  • W_FIELDCAT-KEY = 'X'.

W_FIELDCAT1-SELTEXT_M = 'INDUSTRY SECTOR'.

W_FIELDCAT1-OUTPUTLEN = 20.

APPEND W_FIELDCAT1 TO T_FIELDCAT1.

CLEAR W_FIELDCAT1.

PERFORM HEADER.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = SY-REPID

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

I_CALLBACK_TOP_OF_PAGE = 'HEADER'

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

  • I_GRID_TITLE =

  • I_GRID_SETTINGS =

  • IS_LAYOUT =

IT_FIELDCAT = T_FIELDCAT1

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

  • IT_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

  • I_HTML_HEIGHT_TOP = 0

  • I_HTML_HEIGHT_END = 0

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IT_EXCEPT_QINFO =

  • IR_SALV_FULLSCREEN_ADAPTER =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

T_OUTTAB = T_MARA

  • 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.

reward if useful,

thanks and regards.

Read only

Former Member
0 Likes
660

Hi

Check thi Code As Follows

*&---------------------------------------------------------------------*
*& Report  ZALV_INTER
*&
*&---------------------------------------------------------------------*
*&
*&Interactive alv report abap
*&---------------------------------------------------------------------*

report  zalv_inter
        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                = sy-repid
     i_callback_pf_status_set          = 'ZSTAT'
*     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'.
        else.
          it_final_sec-dummy = '@09@'.
          it_final_sec-color = 'C41'.
        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             = sy-repid
         i_callback_pf_status_set       = 'X'
*         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 = 'Sathish Borancha'(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

Reward All Helpfull Answers

Regards

Fareedas