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

ALV REPORT

Hi,

Can any one send example program in ALV report to diaplay top-of-page with some basic list value

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Posted on Nov 21, 2007 at 11:18 AM
    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 21, 2007 at 11:18 AM

    hi,

    REPORT zalv_prds.

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

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

    *--


    Simple ALV Grid with Header-Footer(Interactive)--

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

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

    TYPE-POOLS : slis.

    TABLES : mara,

    makt,

    marc.

    DATA : BEGIN OF itab OCCURS 0,

    matnr LIKE mara-matnr,

    maktx LIKE makt-maktx,

    werks LIKE marc-werks,

    END OF itab.

    DATA : t_fcat TYPE slis_t_fieldcat_alv,

    t_eve TYPE slis_t_event,

    st_line TYPE slis_listheader,

    t_list_top_page TYPE slis_t_listheader,

    t_list_end_page TYPE slis_t_listheader.

    DATA : t_mat LIKE mara-matnr.

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

    SELECT-OPTIONS : mat FOR mara-matnr.

    SELECTION-SCREEN : END OF BLOCK blk1.

    INITIALIZATION.

    PERFORM build_cat USING t_fcat.

    PERFORM build_eve.

    START-OF-SELECTION.

    PERFORM get_data.

    PERFORM build_header USING t_list_top_page[].

    PERFORM build_footer USING t_list_end_page[].

    PERFORM dis_data.

    &----


    *& Form buils_cat

    &----


    • text

    ----


    • -->TEMP_FCAT text

    ----


    FORM build_cat USING temp_fcat TYPE slis_t_fieldcat_alv.

    DATA : wa_fcat TYPE slis_fieldcat_alv.

    wa_fcat-tabname = 'ITAB'.

    wa_fcat-fieldname = 'MATNR'.

    wa_fcat-seltext_m = 'Material'.

    APPEND wa_fcat TO temp_fcat.

    CLEAR wa_fcat.

    wa_fcat-tabname = 'ITAB'.

    wa_fcat-fieldname = 'MAKTX'.

    wa_fcat-seltext_m = 'Material Description'.

    APPEND wa_fcat TO temp_fcat.

    CLEAR wa_fcat.

    wa_fcat-tabname = 'ITAB'.

    wa_fcat-fieldname = 'WERKS'.

    wa_fcat-seltext_m = 'Plant'.

    APPEND wa_fcat TO temp_fcat.

    CLEAR wa_fcat.

    ENDFORM. "build_cat

    &----


    *& Form build_eve

    &----


    • text

    ----


    FORM build_eve.

    DATA : wa_eve TYPE slis_alv_event.

    CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

    EXPORTING

    i_list_type = 0

    IMPORTING

    et_events = t_eve

    • 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 t_eve INTO wa_eve WITH KEY name = 'END_OF_LIST'.

    IF sy-subrc = 0.

    wa_eve-form = 'END_OF_PAGE'.

    MODIFY t_eve FROM wa_eve INDEX sy-tabix.

    ENDIF.

    ENDFORM. "build_eve

    &----


    *& Form get_data

    &----


    • text

    ----


    FORM get_data.

    SELECT maramatnr maktmaktx marc~werks INTO CORRESPONDING FIELDS OF TABLE itab

    FROM mara INNER JOIN makt ON

    maramatnr = maktmatnr

    INNER JOIN marc ON

    maramatnr = marcmatnr

    WHERE mara~matnr IN mat.

    ENDFORM. "get_data

    &----


    *& Form dis_data

    &----


    • text

    ----


    FORM dis_data.

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    i_callback_program = 'ZALV_PRDS'

    i_callback_user_command = 'USER_COMMAND'

    i_callback_top_of_page = 'TOP_OF_PAGE'

    it_fieldcat = t_fcat

    i_save = 'A'

    it_events = t_eve

    TABLES

    t_outtab = itab

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

    &----


    *& Form build_header

    &----


    • text

    ----


    • -->TEMP_LIST text

    • -->TTYPE text

    • -->SLIS_T_LISTHEADER text

    ----


    FORM build_header USING temp_list TYPE slis_t_listheader.

    CLEAR st_line.

    st_line-typ = 'H'.

    st_line-info = 'Material Info'.

    APPEND st_line TO temp_list.

    ENDFORM. "build_header

    &----


    *& Form build_footer

    &----


    • text

    ----


    • -->TEMP_LIST text

    ----


    FORM build_footer USING temp_list TYPE slis_t_listheader.

    CLEAR st_line.

    st_line-typ = 'H'.

    st_line-info = 'Dhwani Shah'.

    APPEND st_line TO temp_list.

    ENDFORM. "build_header

    &----


    *& Form top_Of_page

    &----


    • text

    ----


    FORM top_of_page.

    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

    EXPORTING

    it_list_commentary = t_list_top_page.

    ENDFORM. "top_Of_page

    &----


    *& Form end_of_page

    &----


    • text

    ----


    FORM end_of_page.

    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

    EXPORTING

    it_list_commentary = t_list_end_page.

    ENDFORM. "end_of_page

    &----


    *& Form user_command

    &----


    • text

    ----


    FORM user_command USING u_com LIKE sy-ucomm sel_field TYPE slis_selfield.

    CASE u_com.

    WHEN '&IC1'.

    IF sel_field-fieldname = 'MATNR'.

    READ TABLE itab INDEX sel_field-tabindex.

    IF sy-subrc = 0.

    t_mat = itab-matnr.

    SET PARAMETER ID 'MAT' FIELD t_mat.

    CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.

    ENDIF.

    ENDIF.

    ENDCASE.

    ENDFORM. "user_command

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Nov 21, 2007 at 11:19 AM

    Hi,

    Refer this code

    data : it_fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE,

    it_fieldcat2 TYPE slis_t_fieldcat_alv WITH HEADER LINE,

    it_events TYPE slis_t_event,

    it_event1 TYPE slis_t_event,

    it_event2 TYPE slis_t_event,

    it_header TYPE slis_t_listheader.

    &----


    *& Form sub_create_events *

    &----


    • This form will display the ALV Events *

    ----


    FORM sub_create_events .

    *--Local Work Area

    DATA: lwa_event TYPE slis_alv_event. "Work area for Events

    *--Call Function to display the events for the ALV

    CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

    EXPORTING

    i_list_type = 1

    IMPORTING

    et_events = it_events.

    *--Sort by Name

    SORT it_events BY name.

    *--Clear

    CLEAR lwa_event.

    READ TABLE it_events INTO lwa_event WITH KEY name =

    slis_ev_top_of_page

    BINARY SEARCH.

    IF sy-subrc = 0.

    MOVE c_top_of_page TO lwa_event-form.

    MODIFY it_events FROM lwa_event TRANSPORTING form WHERE

    name = slis_ev_top_of_page.

    ENDIF.

    *--Clear

    CLEAR : lwa_event.

    ENDFORM. "sub_create_events

    &----


    *& Form sub_top_of_page *

    &----


    • This form is to build the Page Header *

    ----


    FORM sub_top_of_page .

    *--Local Variable

    DATA : lv_title(120) TYPE c, " Title

    lv_month(30) TYPE c,

    lv_mont(30) TYPE c,

    lv_bud(16) TYPE c.

    *--Local Work Area

    DATA : lwa_line TYPE slis_listheader. " Hold list header

    • CONCATENATE p_month 'to' s_hmonth INTO lv_month SEPARATED BY space.

    • IF NOT s_hmonth IS INITIAL.

    • lv_mont = lv_month.

    • ELSE.

    lv_mont = p_month.

    • ENDIF.

    *--Title Display

    lwa_line-typ = 'H'. " header

    lv_title = sy-title.

    lwa_line-info = lv_title.

    APPEND lwa_line TO it_header.

    CLEAR lwa_line.

    *--Month Display

    lwa_line-typ = 'S'. " Item

    WRITE: lv_mont TO lv_month.

    lwa_line-key = text-024.

    lwa_line-info = lv_month.

    APPEND lwa_line TO it_header.

    *--Budget Display

    lwa_line-typ = 'S'. " Item

    WRITE: p_bud TO lv_bud.

    lwa_line-key = text-025.

    lwa_line-info = lv_bud.

    APPEND lwa_line TO it_header.

    CLEAR: lwa_line,

    lv_mont.

    *--This funcation module will display the top of the page

    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

    EXPORTING

    it_list_commentary = it_header.

    *--Free

    FREE : it_header.

    ENDFORM. "sub_top_of_page

    Reward Points

    Reagrds,

    Prashant

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 21, 2007 at 11:19 AM
    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.