Skip to Content
author's profile photo Former Member
Former Member

hi gurur's how we do the interactive report in ALV

hi gurur's how we do the interactive report in ALV.

PLZ HELP ME

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 17, 2008 at 03:59 AM

    Hi Sri

    Hope this code will resolve ur problem

    report yh645_secndry_alv.

    type-pools: slis.

    data: fieldcat type slis_t_fieldcat_alv,

    fieldcat_ln like line of fieldcat,

    fs_layout type slis_layout_alv,

    t_layoout like standard table

    of fs_layout.

    data: begin of fs_spfli,

    carrid type spfli-carrid,

    connid type spfli-connid,

    countryfr type spfli-countryfr,

    cityfrom type spfli-cityfrom,

    airpfrom type spfli-airpfrom,

    countryto type spfli-countryto,

    cityto type spfli-cityto,

    airpto type spfli-airpto,

    fltime type spfli-fltime,

    deptime type spfli-deptime,

    arrtime type spfli-arrtime,

    distance type spfli-distance,

    distid type spfli-distid,

    fltype type spfli-fltype,

    period type spfli-period,

    checkbox,

    color(3),

    end of fs_spfli.

    data:

    begin of fs_table,

    carrid type spfli-carrid,

    connid type spfli-connid,

    end of fs_table.

    data: begin of fs_sflight,

    check,

    color(3).

    include type sflight.

    data:end of fs_sflight.

    data:

    begin of fs_table1,

    carrid type sflight-carrid,

    connid type sflight-connid,

    fldate type sflight-fldate,

    end of fs_table1.

    data:

    t_spfli like standard table

    of fs_spfli.

    data:

    t_table like standard table

    of fs_table.

    data:

    t_table1 like standard table

    of fs_table1.

    data:

    t_sflight like standard table

    of fs_sflight.

    data:

    t_sbook like standard table

    of sbook.

    data t_layout type slis_layout_alv.

    select *

    into corresponding fields of table t_spfli

    from spfli.

    perform start_list_viewer.

    perform get_spfli_details.

    &----


    *& Form SUB1

    &----


    • text

    ----


    • -->RT_EXTAB text

    ----


    form sub1 using rt_extab type slis_t_extab.

    data: flight type slis_extab.

    flight-fcode = 'SFLIGHT'.

    append flight to rt_extab.

    set pf-status 'SFLIGHT'. " EXCLUDING RT_EXTAB.

    endform. "SUB1

    &----


    *& Form START_LIST_VIEWER

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    form start_list_viewer .

    data: pgm like sy-repid.

    pgm = sy-repid.

    fs_layout-box_fieldname = 'CHECKBOX'.

    fs_layout-info_fieldname = 'COLOR'.

    call function 'REUSE_ALV_LIST_DISPLAY'

    exporting

    i_callback_program = pgm

    i_callback_pf_status_set = 'SUB1'

    i_callback_user_command = 'USER_COMMAND'

    i_structure_name = 'SPFLI'

    is_layout = fs_layout

    tables

    t_outtab = t_spfli

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

    *******Process Call Back Events (Begin)**************************

    form user_command using ucomm like sy-ucomm

    selfield type slis_selfield.

    case ucomm.

    when 'SFLIGHT'.

    selfield-refresh = 'X'.

    perform get_spfli_details.

    select *

    from sflight

    into corresponding fields of table t_sflight

    for all entries in t_table

    where carrid eq t_table-carrid

    and connid eq t_table-connid.

    perform display_sflight.

    when 'SBOOK'.

    selfield-refresh = 'X'.

    perform get_sflight_details.

    select *

    from sbook

    into corresponding fields of table t_sbook

    for all entries in t_table1

    where carrid eq t_table1-carrid

    and connid eq t_table1-connid

    and fldate eq t_table1-fldate.

    perform display_sbook.

    endcase.

    endform. "USER_COMMAND

    &----


    *& Form SUB2

    &----


    • text

    ----


    • -->RT_EXTAB text

    ----


    form sub2 using rt_extab type slis_t_extab.

    data: flight type slis_extab.

    flight-fcode = 'SBOOK'.

    append flight to rt_extab.

    set pf-status 'SBOOK'. " EXCLUDING RT_EXTAB.

    endform. "SUB2

    &----


    *& Form DISPLAY_SFLIGHT

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    form display_sflight .

    data: pgm like sy-repid.

    pgm = sy-repid.

    clear t_layout.

    fs_layout-box_fieldname = 'CHECK'.

    fs_layout-info_fieldname = 'COLOR'.

    call function 'REUSE_ALV_LIST_DISPLAY'

    exporting

    i_callback_program = pgm

    i_callback_pf_status_set = 'SUB2'

    i_callback_user_command = 'USER_COMMAND'

    i_structure_name = 'SFLIGHT'

    is_layout = fs_layout

    tables

    t_outtab = t_sflight

    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_SFLIGHT

    &----


    *& Form GET_SPFLI_DETAILS

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    form get_spfli_details .

    loop at t_spfli into fs_spfli.

    if fs_spfli-checkbox = 'X'.

    fs_spfli-color = 'C51'.

    fs_spfli-checkbox = '1'.

    fs_table-carrid = fs_spfli-carrid.

    fs_table-connid = fs_spfli-connid.

    append fs_table to t_table.

    modify t_spfli from fs_spfli.

    endif.

    endloop.

    endform. " GET_SFLIGHT_DETAILS

    &----


    *& Form GET_SFLIGHT_DETAILS

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    form get_sflight_details .

    loop at t_sflight into fs_sflight.

    if fs_sflight-check = 'X'.

    fs_sflight-color = 'C71'.

    fs_sflight-check = '1'.

    fs_table1-carrid = fs_sflight-carrid.

    fs_table1-connid = fs_sflight-connid.

    fs_table1-fldate = fs_sflight-fldate.

    append fs_table1 to t_table1.

    modify t_sflight from fs_sflight.

    endif.

    endloop.

    endform. " GET_SFLIGHT_DETAILS

    &----


    *& Form DISPLAY_SBOOK

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    form display_sbook .

    data: pgm like sy-repid.

    pgm = sy-repid.

    call function 'REUSE_ALV_LIST_DISPLAY'

    exporting

    i_callback_program = pgm

    i_structure_name = 'SBOOK'

    tables

    t_outtab = t_sbook

    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_SBOOK

    reward if help.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

      • EXPORTING

      • I_LIST_TYPE = 0

      IMPORTING

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

      READ TABLE LT_EVENTS INTO LS_EVENTS WITH KEY NAME = 'USER_COMMAND'.

      LS_EVENTS-FORM = 'SECOND_LIST'.

      MODIFY LT_EVENTS FROM LS_EVENTS TRANSPORTING FORM WHERE NAME = 'USER_COMMAND'.

      FORM SECOND_LIST USING UCOMM LIKE SY-UCOMM

      SELFIELD TYPE SLIS_SELFIELD.

      IF SELFIELD-FIELDNAME = 'ORDERNO'.

      SELECT * FROM ZTT_ORDER_ITEM INTO TABLE LT_ORDERI WHERE ORDERNO = SELFIELD-VALUE.

      ***Fill fieldcat table******

      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 = ' '

      • IS_LAYOUT =

      IT_FIELDCAT = lt_fieldcat

      • IT_EXCLUDING =

      • IT_SPECIAL_GROUPS =

      • IT_SORT =

      • IT_FILTER =

      • IS_SEL_HIDE =

      • I_DEFAULT = 'X'

      • I_SAVE = ' '

      • IS_VARIANT =

      IT_EVENTS = lt_events1

      TABLES

      t_outtab = lt_orderi

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

      ENDIF.

      ENDFORM.

  • author's profile photo Former Member
    Former Member
    Posted on Jan 17, 2008 at 05:36 AM

    Hi Srivasu,

    I will send a sample code along with Comments check it once ok.copy the below code and execute it and debug it ok..

    &----


    *& Report YPURCHASEORDER_ALV_LISTDISP *

    *& *

    &----


    *& DEVELOPER : KIRAN KUMAR.G *

    & PURPOSE : CREATING A PURCHASE ORDER BASED ON PURCHASE DOC NUMBER

    *& CREATION DT: 22/11/2007 *

    *& REQUEST : ERPK900035 *

    &----


    REPORT YPURCHASEORDER_ALV_LISTDISP.

    ----


    • Tables

    ----


    TABLES : ekko, "Purchasing Document Header

    ekpo. "Purchasing Document Item

    ----


    • Type pools

    ----


    TYPE-POOLS: slis.

    ----


    • Internal Tables

    ----


    DATA: BEGIN OF gt_headerdat OCCURS 0,

    ebeln LIKE ekko-ebeln, " Purchasing Document Number

    bukrs LIKE ekko-bukrs, " Company Code

    bstyp LIKE ekko-bstyp, " Purchasing Document Category

    bsart LIKE ekko-bsart, " Purchasing Document LIKE

    aedat LIKE ekko-aedat, " Date on which the recordwascreate

    ernam LIKE ekko-ernam, " Name of Person who Created Object

    lifnr LIKE ekko-lifnr, " Vendor's account number

    spras LIKE ekko-spras, " Language Key

    ekorg LIKE ekko-ekorg, " Purchasing Organization

    ekgrp LIKE ekko-ekgrp, " Purchasing group

    END OF gt_headerdat.

    DATA: BEGIN OF gt_item OCCURS 0,

    matnr LIKE ekpo-matnr, "Material Number

    werks LIKE ekpo-werks, "Plant

    lgort LIKE ekpo-lgort, "Storage 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

    kunnr LIKE ekpo-kunnr, "Customer Number 1

    END OF gt_item.

    ----


    • Global Structures

    ----


    DATA: gt_header TYPE slis_t_listheader, "For Headings

    wa_header TYPE slis_listheader,

    gt_fieldcat TYPE slis_t_fieldcat_alv, "Structure Defintion

    wa_fieldcat TYPE slis_fieldcat_alv,

    gt_fieldcat1 TYPE slis_t_fieldcat_alv,

    wa_fieldcat1 TYPE slis_fieldcat_alv,

    wa_layout TYPE slis_layout_alv, "Layout

    gt_events TYPE slis_t_event, "For Events

    wa_events TYPE slis_alv_event.

    ----


    • Selection Screen

    ----


    SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

    SELECT-OPTIONS : s_ebeln FOR ekko-ebeln.

    SELECTION-SCREEN: END OF BLOCK b1.

    ----


    • Initialization

    ----


    INITIALIZATION.

    PERFORM initial.

    ----


    • Fetch Data

    ----


    START-OF-SELECTION.

    PERFORM fetch_data.

    END-OF-SELECTION.

    • Bulid fieldcatalog

    PERFORM fieldcat.

    • Change fieldcatalog

    PERFORM fieldcat_change.

    • Events Triggering

    PERFORM place_events.

    • Layout.

    PERFORM layout.

    ----


    • Display Data

    ----


    SORT gt_headerdat BY ebeln.

    PERFORM display_list.

    &----


    *& Form initial

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM initial .

    s_ebeln-sign = 'I'.

    s_ebeln-option = 'BT'.

    s_ebeln-low = '3000000090'.

    s_ebeln-high = '3000000166'.

    APPEND s_ebeln.

    ENDFORM. " initial

    &----


    *& Form fetch_data

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM fetch_data .

    REFRESH gt_headerdat. "Clear the Body of Internal Table

    CLEAR gt_headerdat. "Clear Header Line

    SELECT ebeln

    bukrs

    bstyp

    bsart

    aedat

    ernam

    lifnr

    spras

    ekorg

    ekgrp

    FROM ekko

    INTO TABLE gt_headerdat

    WHERE ebeln IN s_ebeln.

    ENDFORM. " fetch_data

    &----


    *& Form display_list

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM display_list .

    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

    EXPORTING

    • I_INTERFACE_CHECK = ' '

    • I_BYPASSING_BUFFER =

    • I_BUFFER_ACTIVE = ' '

    i_callback_program = sy-cprog

    • I_CALLBACK_PF_STATUS_SET = ' '

    i_callback_user_command = 'USERCOMMAND'

    • I_STRUCTURE_NAME =

    is_layout = wa_layout

    it_fieldcat = gt_fieldcat

    • IT_EXCLUDING =

    • IT_SPECIAL_GROUPS =

    • IT_SORT =

    • IT_FILTER =

    • IS_SEL_HIDE =

    • I_DEFAULT = 'X'

    • I_SAVE = ' '

    • IS_VARIANT =

    it_events = gt_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

    • IMPORTING

    • E_EXIT_CAUSED_BY_CALLER =

    • ES_EXIT_CAUSED_BY_USER =

    TABLES

    t_outtab = gt_headerdat

    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_list

    &----


    *& Form place_events

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM place_events .

    CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

    EXPORTING

    i_list_type = 0

    IMPORTING

    et_events = gt_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.

    CLEAR wa_events. "Clear Header Line

    READ TABLE gt_events INTO wa_events WITH KEY name = 'TOP_OF_PAGE'.

    IF sy-subrc = 0.

    wa_events-form = 'HEADING'.

    MODIFY gt_events FROM wa_events INDEX sy-tabix.

    ENDIF.

    CLEAR wa_events. "Clear Header Line

    READ TABLE gt_events INTO wa_events WITH KEY name = 'END_OF_LIST'.

    IF sy-subrc = 0.

    wa_events-form = 'PAGEDOWN'.

    MODIFY gt_events FROM wa_events INDEX sy-tabix.

    ENDIF.

    CLEAR wa_events. "Clear Header Line

    READ TABLE gt_events INTO wa_events WITH KEY name = 'USER_COMMAND'.

    IF sy-subrc = 0.

    wa_events-form = 'USERCOMMAND'.

    MODIFY gt_events FROM wa_events INDEX sy-tabix.

    ENDIF.

    ENDFORM. " place_events

    &----


    *& Form layout

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM layout .

    CLEAR wa_layout. "Clear Header Line

    wa_layout-zebra = 'X'. "Zebra Lines in the Output

    wa_layout-colwidth_optimize = 'X'. "Optimize the Column Width

    ENDFORM. " layout

    &----


    *& Form heading

    &----


    • text

    ----


    FORM heading.

    WRITE:/6 'THIS REPORT DISPLAYS THE PURCHASE ORDER DETAILS'.

    WRITE:/6 'CLICK ON PURCHASE DOC NO FIELD(INTERACTIVE LIST)'.

    ENDFORM. "heading

    &----


    *& Form fieldcat

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM fieldcat .

    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

    EXPORTING

    i_program_name = SY-CPROG

    i_internal_tabname = 'GT_HEADERDAT'

    • I_STRUCTURE_NAME =

    • I_CLIENT_NEVER_DISPLAY = 'X'

    i_inclname = SY-CPROG

    • I_BYPASSING_BUFFER =

    • I_BUFFER_ACTIVE =

    CHANGING

    ct_fieldcat = gt_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. " fieldcat

    &----


    *& Form fieldcat_change

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM fieldcat_change .

    LOOP AT gt_fieldcat INTO wa_fieldcat.

    CASE wa_fieldcat-fieldname.

    WHEN 'EBELN'.

    wa_fieldcat-hotspot = 'X'.

    ENDCASE.

    MODIFY gt_fieldcat FROM wa_fieldcat INDEX sy-tabix.

    ENDLOOP.

    ENDFORM. " fieldcat_change

    &----


    *& Form pagedown

    &----


    • text

    ----


    FORM pagedown.

    WRITE:/35 'HAVE A NICE DAY...' COLOR 4.

    ENDFORM. "pagedown

    &----


    *& Form usercommand

    &----


    • text

    ----


    • -->UCOMM text

    • -->SELFIELD text

    ----


    FORM usercommand USING ucomm LIKE sy-ucomm selfield TYPE slis_selfield.

    READ TABLE gt_headerdat INDEX selfield-tabindex.

    CASE selfield-sel_tab_field.

    WHEN 'GT_HEADERDAT-EBELN'.

    REFRESH : gt_item.

    CLEAR : gt_item.

    SELECT matnr

    werks

    lgort

    matkl

    menge

    meins

    netpr

    kunnr

    FROM ekpo

    INTO TABLE gt_item

    WHERE ekpo~ebeln EQ gt_headerdat-ebeln.

    *Build a Field Catalog

    PERFORM fieldcat1.

    *For Heading in the Interactive List

    PERFORM heading1.

    *Display Interactive Data

    PERFORM display_data1.

    ENDCASE.

    ENDFORM. "usercommand

    &----


    *& Form fieldcat1

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM fieldcat1 .

    REFRESH : gt_fieldcat1.

    CLEAR : wa_fieldcat1.

    wa_fieldcat1-col_pos = '1'. "Column Postion

    wa_fieldcat1-fieldname = 'MATNR'. "Field Name

    wa_fieldcat1-tabname = 'GT_ITEM'. "Internal Table

    wa_fieldcat1-key = 'X'. "Blue Color

    wa_fieldcat1-seltext_l = 'MATERIAL NO'. "Display Text Screen

    APPEND wa_fieldcat1 TO gt_fieldcat1.

    CLEAR wa_fieldcat1.

    wa_fieldcat1-col_pos = '2'. "Column Postion

    wa_fieldcat1-fieldname = 'WERKS'. "Field Name

    wa_fieldcat1-tabname = 'GT_ITEM'. "Internal Table

    wa_fieldcat1-seltext_l = 'PLANT'. "Display Text Screen

    APPEND wa_fieldcat1 TO gt_fieldcat1.

    CLEAR wa_fieldcat1.

    wa_fieldcat1-col_pos = '3'. "Column Postion

    wa_fieldcat1-fieldname = 'LGORT'. "Field Name

    wa_fieldcat1-tabname = 'GT_ITEM'. "Internal Table

    wa_fieldcat1-seltext_l = 'STORAGE LOCATION'."Display Text Screen

    APPEND wa_fieldcat1 TO gt_fieldcat1.

    CLEAR wa_fieldcat1.

    wa_fieldcat1-col_pos = '4'. "Column Postion

    wa_fieldcat1-fieldname = 'MATKL'. "Field Name

    wa_fieldcat1-tabname = 'GT_ITEM'. "Internal Table

    wa_fieldcat1-seltext_l = 'MATERIAL GRP'. "Display Text Screen

    APPEND wa_fieldcat1 TO gt_fieldcat1.

    CLEAR wa_fieldcat1.

    wa_fieldcat1-col_pos = '5'. "Column Postion

    wa_fieldcat1-fieldname = 'MENGE'. "Field Name

    wa_fieldcat1-tabname = 'GT_ITEM'. "Internal TAble

    wa_fieldcat1-seltext_l = 'PO QUANTITY'. "Display Text Screen

    APPEND wa_fieldcat1 TO gt_fieldcat1.

    CLEAR wa_fieldcat1.

    wa_fieldcat1-col_pos = '6'. "Column Pos tion

    wa_fieldcat1-fieldname = 'MEINS'. "Field Name

    wa_fieldcat1-tabname = 'GT_ITEM'. "Internal TAble

    wa_fieldcat1-seltext_l = 'BASE UNIT MEASURE'."Display Text Screen

    APPEND wa_fieldcat1 TO gt_fieldcat1.

    CLEAR wa_fieldcat1.

    wa_fieldcat1-col_pos = '7'. "Column Postion

    wa_fieldcat1-fieldname = 'NETPR'. "Field Name

    wa_fieldcat1-tabname = 'GT_ITEM'. "Internal Table

    wa_fieldcat1-seltext_l = 'NET PRICE'. "Display Text Screen

    APPEND wa_fieldcat1 TO gt_fieldcat1.

    CLEAR wa_fieldcat1.

    wa_fieldcat1-col_pos = '8'. "Column Postion

    wa_fieldcat1-fieldname = 'KUNNR'. "Field Name

    wa_fieldcat1-tabname = 'GT_ITEM'. "Internal Table

    wa_fieldcat1-seltext_l = 'CUSTOMER NO'. "Display Text Screen

    APPEND wa_fieldcat1 TO gt_fieldcat1.

    CLEAR wa_fieldcat1.

    ENDFORM. " fieldcat1

    &----


    *& Form heading1

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM heading1 .

    REFRESH : gt_header.

    CLEAR : wa_header.

    wa_header-typ = 'H'.

    wa_header-info = 'THIS IS AN INTERACTIVE LIST'.

    APPEND wa_header TO gt_header.

    ENDFORM. " heading1

    &----


    *& Form top

    &----


    • text

    ----


    FORM top.

    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

    EXPORTING

    it_list_commentary = gt_header

    • I_LOGO =

    • I_END_OF_LIST_GRID =

    .

    ENDFORM. "top

    &----


    *& Form display_data1

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    FORM display_data1 .

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    • I_INTERFACE_CHECK = ' '

    • I_BYPASSING_BUFFER = ' '

    • I_BUFFER_ACTIVE = ' '

    i_callback_program = SY-CPROG

    • I_CALLBACK_PF_STATUS_SET = ' '

    • I_CALLBACK_USER_COMMAND = ' '

    i_callback_top_of_page = 'TOP'

    • 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 = gt_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

    • 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 = gt_item

    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_data1

    Reward points if helpful.

    Kiran Kumar.G.A

    Have a Nice Day..

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 17, 2008 at 05:26 AM

    Hi,

    Check the following program:

    TYPE-POOLS: SLIS.

    *type declaration for values from ekko

    TYPES: BEGIN OF I_EKKO,

    EBELN LIKE EKKO-EBELN,

    AEDAT LIKE EKKO-AEDAT,

    BUKRS LIKE EKKO-BUKRS,

    BSART LIKE EKKO-BSART,

    LIFNR LIKE EKKO-LIFNR,

    END OF I_EKKO.

    DATA: IT_EKKO TYPE STANDARD TABLE OF I_EKKO INITIAL SIZE 0,

    WA_EKKO TYPE I_EKKO.

    *type declaration for values from ekpo

    TYPES: BEGIN OF I_EKPO,

    EBELN LIKE EKPO-EBELN,

    EBELP LIKE EKPO-EBELP,

    MATNR LIKE EKPO-MATNR,

    MENGE LIKE EKPO-MENGE,

    MEINS LIKE EKPO-MEINS,

    NETPR LIKE EKPO-NETPR,

    END OF I_EKPO.

    DATA: IT_EKPO TYPE STANDARD TABLE OF I_EKPO INITIAL SIZE 0,

    WA_EKPO TYPE I_EKPO .

    *variable for Report ID

    DATA: V_REPID LIKE SY-REPID .

    *declaration for fieldcatalog

    DATA: I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,

    WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.

    DATA: IT_LISTHEADER TYPE SLIS_T_LISTHEADER.

    • declaration for events table where user comand or set PF status will

    • be defined

    DATA: V_EVENTS TYPE SLIS_T_EVENT,

    WA_EVENT TYPE SLIS_ALV_EVENT.

    • declartion for layout

    DATA: ALV_LAYOUT TYPE SLIS_LAYOUT_ALV.

    • declaration for variant(type of display we want)

    DATA: I_VARIANT TYPE DISVARIANT,

    I_VARIANT1 TYPE DISVARIANT,

    I_SAVE(1) TYPE C.

    *PARAMETERS : p_var TYPE disvariant-variant.

    *Title displayed when the alv list is displayed

    DATA: I_TITLE_EKKO TYPE LVC_TITLE VALUE 'FIRST LIST DISPLAYED'.

    DATA: I_TITLE_EKPO TYPE LVC_TITLE VALUE 'SECONDRY LIST DISPLAYED'.

    INITIALIZATION.

    V_REPID = SY-REPID.

    PERFORM BUILD_FIELDCATLOG.

    PERFORM EVENT_CALL.

    PERFORM POPULATE_EVENT.

    START-OF-SELECTION.

    PERFORM DATA_RETRIEVAL.

    PERFORM BUILD_LISTHEADER USING IT_LISTHEADER.

    PERFORM DISPLAY_ALV_REPORT.

    &----


    *& Form BUILD_FIELDCATLOG

    &----


    • Fieldcatalog has all the field details from ekko

    ----


    FORM BUILD_FIELDCATLOG.

    WA_FIELDCAT-TABNAME = 'IT_EKKO'.

    WA_FIELDCAT-FIELDNAME = 'EBELN'.

    WA_FIELDCAT-SELTEXT_M = 'PO NO.'.

    APPEND WA_FIELDCAT TO I_FIELDCAT.

    CLEAR WA_FIELDCAT.

    WA_FIELDCAT-TABNAME = 'IT_EKKO'.

    WA_FIELDCAT-FIELDNAME = 'AEDAT'.

    WA_FIELDCAT-SELTEXT_M = 'DATE.'.

    APPEND WA_FIELDCAT TO I_FIELDCAT.

    CLEAR WA_FIELDCAT.

    WA_FIELDCAT-TABNAME = 'IT_EKKO'.

    WA_FIELDCAT-FIELDNAME = 'BUKRS'.

    WA_FIELDCAT-SELTEXT_M = 'COMPANY CODE'.

    APPEND WA_FIELDCAT TO I_FIELDCAT.

    CLEAR WA_FIELDCAT.

    WA_FIELDCAT-TABNAME = 'IT_EKKO'.

    WA_FIELDCAT-FIELDNAME = 'BUKRS'.

    WA_FIELDCAT-SELTEXT_M = 'DOCMENT TYPE'.

    APPEND WA_FIELDCAT TO I_FIELDCAT.

    CLEAR WA_FIELDCAT.

    WA_FIELDCAT-TABNAME = 'IT_EKKO'.

    WA_FIELDCAT-FIELDNAME = 'LIFNR'.

    WA_FIELDCAT-NO_OUT = 'X'.

    WA_FIELDCAT-SELTEXT_M = 'VENDOR CODE'.

    APPEND WA_FIELDCAT TO I_FIELDCAT.

    CLEAR WA_FIELDCAT.

    ENDFORM. "BUILD_FIELDCATLOG

    &----


    *& Form EVENT_CALL

    &----


    • we get all events - TOP OF PAGE or USER COMMAND in table v_events

    ----


    FORM EVENT_CALL.

    CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

    EXPORTING

    I_LIST_TYPE = 0

    IMPORTING

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

    ENDFORM. "EVENT_CALL

    &----


    *& Form POPULATE_EVENT

    &----


    • Events populated for TOP OF PAGE & USER COMAND

    ----


    FORM POPULATE_EVENT.

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

    IF SY-SUBRC EQ 0.

    WA_EVENT-FORM = 'TOP_OF_PAGE'.

    MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =

    WA_EVENT-FORM.

    ENDIF.

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

    IF SY-SUBRC EQ 0.

    WA_EVENT-FORM = 'USER_COMMAND'.

    MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =

    WA_EVENT-NAME.

    ENDIF.

    ENDFORM. "POPULATE_EVENT

    &----


    *& Form data_retrieval

    &----


    • retreiving values from the database table ekko

    ----


    FORM DATA_RETRIEVAL.

    SELECT EBELN AEDAT BUKRS BSART LIFNR FROM EKKO INTO TABLE IT_EKKO.

    ENDFORM. "data_retrieval

    &----


    *& Form bUild_listheader

    &----


    • text

    ----


    • -->I_LISTHEADEtext

    ----


    FORM BUILD_LISTHEADER USING I_LISTHEADER TYPE SLIS_T_LISTHEADER.

    DATA HLINE TYPE SLIS_LISTHEADER.

    HLINE-INFO = 'this is my first alv pgm'.

    HLINE-TYP = 'H'.

    ENDFORM. "build_listheader

    &----


    *& Form display_alv_report

    &----


    • text

    ----


    FORM DISPLAY_ALV_REPORT.

    V_REPID = SY-REPID.

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    I_CALLBACK_PROGRAM = V_REPID

    • I_CALLBACK_PF_STATUS_SET = ' '

    I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

    I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'

    I_GRID_TITLE = I_TITLE_EKKO

    • I_GRID_SETTINGS =

    • IS_LAYOUT = ALV_LAYOUT

    IT_FIELDCAT = I_FIELDCAT[]

    • IT_EXCLUDING =

    • IT_SPECIAL_GROUPS =

    • IT_SORT =

    • IT_FILTER =

    • IS_SEL_HIDE =

    • i_default = 'ZLAY1'

    I_SAVE = 'A'

    • is_variant = i_variant

    IT_EVENTS = V_EVENTS

    TABLES

    T_OUTTAB = IT_EKKO

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

    &----


    *& Form TOP_OF_PAGE

    &----


    • text

    ----


    FORM TOP_OF_PAGE.

    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

    EXPORTING

    IT_LIST_COMMENTARY = IT_LISTHEADER

    • i_logo =

    • I_END_OF_LIST_GRID =

    .

    ENDFORM. "TOP_OF_PAGE

    &----


    *& Form USER_COMMAND

    &----


    • text

    ----


    • -->R_UCOMM text

    • -->, text

    • -->RS_SLEFIELDtext

    ----


    FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM

    RS_SELFIELD TYPE SLIS_SELFIELD.

    CASE R_UCOMM.

    WHEN '&IC1'.

    READ TABLE IT_EKKO INTO WA_EKKO INDEX RS_SELFIELD-TABINDEX.

    PERFORM BUILD_FIELDCATLOG_EKPO.

    PERFORM EVENT_CALL_EKPO.

    PERFORM POPULATE_EVENT_EKPO.

    PERFORM DATA_RETRIEVAL_EKPO.

    PERFORM BUILD_LISTHEADER_EKPO USING IT_LISTHEADER.

    PERFORM DISPLAY_ALV_EKPO.

    ENDCASE.

    ENDFORM. "user_command

    &----


    *& Form BUILD_FIELDCATLOG_EKPO

    &----


    • text

    ----


    FORM BUILD_FIELDCATLOG_EKPO.

    WA_FIELDCAT-TABNAME = 'IT_EKPO'.

    WA_FIELDCAT-FIELDNAME = 'EBELN'.

    WA_FIELDCAT-SELTEXT_M = 'PO NO.'.

    APPEND WA_FIELDCAT TO I_FIELDCAT.

    CLEAR WA_FIELDCAT.

    WA_FIELDCAT-TABNAME = 'IT_EKPO'.

    WA_FIELDCAT-FIELDNAME = 'EBELP'.

    WA_FIELDCAT-SELTEXT_M = 'LINE NO'.

    APPEND WA_FIELDCAT TO I_FIELDCAT.

    CLEAR WA_FIELDCAT.

    WA_FIELDCAT-TABNAME = 'I_EKPO'.

    WA_FIELDCAT-FIELDNAME = 'MATNR'.

    WA_FIELDCAT-SELTEXT_M = 'MATERIAL NO.'.

    APPEND WA_FIELDCAT TO I_FIELDCAT.

    CLEAR WA_FIELDCAT.

    WA_FIELDCAT-TABNAME = 'I_EKPO'.

    WA_FIELDCAT-FIELDNAME = 'MENGE'.

    WA_FIELDCAT-SELTEXT_M = 'QUANTITY'.

    APPEND WA_FIELDCAT TO I_FIELDCAT.

    CLEAR WA_FIELDCAT.

    WA_FIELDCAT-TABNAME = 'I_EKPO'.

    WA_FIELDCAT-FIELDNAME = 'MEINS'.

    WA_FIELDCAT-SELTEXT_M = 'UOM'.

    APPEND WA_FIELDCAT TO I_FIELDCAT.

    CLEAR WA_FIELDCAT.

    WA_FIELDCAT-TABNAME = 'I_EKPO'.

    WA_FIELDCAT-FIELDNAME = 'NETPR'.

    WA_FIELDCAT-SELTEXT_M = 'PRICE'.

    APPEND WA_FIELDCAT TO I_FIELDCAT.

    CLEAR WA_FIELDCAT.

    ENDFORM. "BUILD_FIELDCATLOG_EKPO

    &----


    *& Form event_call_ekpo

    &----


    • we get all events - TOP OF PAGE or USER COMMAND in table v_events

    ----


    FORM EVENT_CALL_EKPO.

    CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

    EXPORTING

    I_LIST_TYPE = 0

    IMPORTING

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

    ENDFORM. "event_call_ekpo

    &----


    *& Form POPULATE_EVENT

    &----


    • Events populated for TOP OF PAGE & USER COMAND

    ----


    FORM POPULATE_EVENT_EKPO.

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

    IF SY-SUBRC EQ 0.

    WA_EVENT-FORM = 'TOP_OF_PAGE'.

    MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =

    WA_EVENT-FORM.

    ENDIF.

    ENDFORM. "POPULATE_EVENT

    &----


    *& Form TOP_OF_PAGE

    &----


    • text

    ----


    FORM F_TOP_OF_PAGE.

    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

    EXPORTING

    IT_LIST_COMMENTARY = IT_LISTHEADER

    • i_logo =

    • I_END_OF_LIST_GRID =

    .

    ENDFORM. "TOP_OF_PAGE

    &----


    *& Form USER_COMMAND

    &----


    • text

    ----


    • -->R_UCOMM text

    • -->, text

    • -->RS_SLEFIELDtext

    ----


    *retreiving values from the database table ekko

    FORM DATA_RETRIEVAL_EKPO.

    SELECT EBELN EBELP MATNR MENGE MEINS NETPR FROM EKPO INTO TABLE IT_EKPO.

    ENDFORM.

    FORM BUILD_LISTHEADER_EKPO USING I_LISTHEADER TYPE SLIS_T_LISTHEADER.

    DATA: HLINE1 TYPE SLIS_LISTHEADER.

    HLINE1-TYP = 'H'.

    HLINE1-INFO = 'CHECKING PGM'.

    ENDFORM.

    FORM DISPLAY_ALV_EKPO.

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    • I_INTERFACE_CHECK = ' '

    • I_BYPASSING_BUFFER = ' '

    • I_BUFFER_ACTIVE = ' '

    I_CALLBACK_PROGRAM = V_REPID

    • I_CALLBACK_PF_STATUS_SET = ' '

    • I_CALLBACK_USER_COMMAND = 'F_USER_COMMAND'

    I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'

    • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

    • I_CALLBACK_HTML_END_OF_LIST = ' '

    • I_STRUCTURE_NAME =

    • I_BACKGROUND_ID = ' '

    I_GRID_TITLE = I_TITLE_EKPO

    • I_GRID_SETTINGS =

    • IS_LAYOUT =

    IT_FIELDCAT = I_FIELDCAT[]

    • IT_EXCLUDING =

    • IT_SPECIAL_GROUPS =

    • IT_SORT =

    • IT_FILTER =

    • IS_SEL_HIDE =

    • I_DEFAULT =

    I_SAVE = 'A'

    • IS_VARIANT =

    IT_EVENTS = V_EVENTS

    TABLES

    T_OUTTAB = IT_EKPO

    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.

    Regards,

    Bhaskar

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.