End of Page event in ALV report using SALV class[cl_salv_hierseq_table]

Hi ,
have been working on a ALV report using the class SALV cl_salv_hierseq_table
I am facing few issues pertaining to two things:
1. Displaying some subtotal text along with the subtotals.
Example refer the standard demo example: SALV_DEMO_HIERSEQ_FORM_EVENTS
Now instead of A 17 and A26 I would like to show text like Subtotal for the Carrid.for subtotals and grand totals
Like   Subtotal for A 17 is :      XXXXXXX
          GrandTotal is         :      YYYYYY
2. We have a page break and a new page for every purchasing group as in the standard example SALV_DEMO_HIERSEQ_FORM_EVENTS for CARRID.
I need to display some variable values as number of documents ,total number of records etc at the end of each CARRID group before a new page starts for the next CARRID.Please note i do not want it on every page.it should only be diaplyed at the end of page whose next page would be for next CARRID.[basically at end of every carrid]Example:after displaying all details for AA need to display the number of records for that carrid at the end of the page[as page break is based on CARRID]/
Thanks
Jyotsna

at end of page event, for CL_SALV_EVENTS_HIERSEQ, has some useful parameters allowing to know where you are at the time of event
parameter VALUE is of type CL_SALV_FORM which contains public attribute IF_SALV_FORM~ACCDESCRIPTION; you can slo get contents of it
about text of total/subtotal, this is normally set in the layout

Similar Messages

  • End-of-page event in alv report

    Hi all,
    I want to create end-of-page in alv report i have used event also
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' * "
       EXPORTING *
         i_callback_program                = sy-repid * "
         i_callback_user_command           = 'USER_COMMAND' * "
         i_callback_top_of_page            = 'TOP_OF_PAGE' * "
       I_STRUCTURE_NAME                  = * "
         it_fieldcat                       = fcat[] * "
         it_events                         = it_event[] * "
        TABLES
          t_outtab                          = gtbl_pohead * "
       EXCEPTIONS
         program_error                     = 1 * "
         OTHERS                            = 2 "
    FORM end_of_page.  *
      DATA:   listwidth TYPE i, *
              ld_pagepos(10) TYPE c, *
              ld_page(10)    TYPE c. *
      WRITE: sy-uline(50). "
      SKIP 3.
      WRITE:/40 'Page No',sy-pagno. "
    ENDFORM.                    "END_OF_PAGE "

    hi
    Search in SDN.You can find the solution for this.Before posting please search in SDN.
    You have to use this  FM 'REUSE_ALV_EVENTS_GET'
    [End-Of-Page|http://www.sapdev.co.uk/reporting/alv/alvgrid_events.htm]
    [Endo Of Page|http://www.sdn.sap.com/irj/scn/advancedsearch?query=alvend-of-pageevent+]

  • How to display 3 level hierarchy alv report using SALV

    Hi ,
          I need to display a Hierarchy ALV report with 3 level.I thought of trying CL_SALV_HIERSEQ_TABLE but i am able to display only two level report.
          How can i display the 3 - level heirarchy report using SALV. I don't want to use SALV_TREE.
          Regards,
          Aditya Tanguturi.

    Hi Aditya,
    Please check this thread
    Is it possible to display more than 2 levels us... | SCN
    Thanks !
    Amit

  • Create frozen alv grid using salv* classes

    Hi Experts,
    I want to create a frozen alv grid i.e the row selections are defined in the code and should not be able to modify on the screen . Please let me know if it is possible ? I am using salv* class for alv.
    Thanks,
    Kiran A.

    Hi,
    You mean "preventing" the user to change the selection set or just not allowing him to change some rows content?
    If you speak about selection only, I don't think this is feasible... (or a silly idea: highlight the rows instead of selecting them
    Kr,
    Manu.

  • END_OF_PAGE in alv report using oops

    Experts,
    Could you please give me the solution for the below issue?
    Requirement is like this:
    I have to display two grids in my report, and in that one grid will have top-of-page and other one will
    have end-of-page. Here, I am able to display the data in the top-of-page but not able to display the data in
    end of page. (Here I am using cl_gui_alv_grid : Class and Event is: END_OF_LIST.).
    I gone through the BCALV_TEST_GRID_EVENTS, but that is not helpful to me.
    Please anyone can you send the code snippet for the above one.
    Thanks...
    Sridhar..

    Hi,
    In the class cl_salv_table you have method get_event get the event from the method.
    Pass u r end of page iver here .it raises the event end of page
    thanks

  • Editable ALV Using SALV Class.

    Hi Experts,
    I need to make ALV Editable using SALV Class only.
    Thanks in Advance
    Regards,
    Ankit.
    Moderator message: please do some research before asking.
    Edited by: Thomas Zloch on Feb 25, 2011 1:47 PM

    Hi Aniket,
    This is a restriction and not provided in SALV class.
    Please have look at the earlier posts in SCN .
    Thanks.

  • End of Page event not triggering in ALV report

    Hello,
    I am developing an ALV report using REUSE_ALV_LIST_DISPLAY. Whatever I write in top_of_page, it will be displayed in the header portion of the output.
    But I want to display some footer text at the end of the page. The problem I am facing is, the WRITE statements within end_of_page are not displayed when the report is run.
    I have populated the i_events as follows :
    FORM f_events CHANGING p_i_events TYPE slis_t_event.
    CONSTANTS : l_c_top_of_page TYPE slis_formname VALUE 'TOP_OF_PAGE',
                l_c_end_of_page TYPE slis_formname VALUE 'END_OF_PAGE'.
    DATA : l_wa_event TYPE slis_alv_event.
    Returns table of possible events
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type = 0
        IMPORTING
          et_events   = p_i_events.
    To append internal table holding event names with event 'TOP OF PAGE'
      READ TABLE  p_i_events INTO l_wa_event
      WITH KEY name = slis_ev_top_of_page.
      IF sy-subrc = 0.
          MOVE   l_c_top_of_page TO l_wa_event-form.
          APPEND l_wa_event      TO p_i_events.
      ENDIF.
    To append internal table holding event names with event 'END OF PAGE'
      READ TABLE  p_i_events INTO l_wa_event
      WITH KEY name = slis_ev_end_of_page.
      IF sy-subrc = 0.
          MOVE   l_c_end_of_page TO l_wa_event-form.
          APPEND l_wa_event      TO p_i_events.
      ENDIF.
    ENDFORM.                               "f_events
    Regds
    Rajesh

    Hi have a look at the following code, and change ur code for end of page accordingly. this will resolve ur problem.
    This is a basic ALV with the followings:-
    - Page Heading
    - Page No
    - Sub-Total
    - Grand Total
    REPORT ZALV.
    TYPE-POOLS: SLIS.
    DATA: G_REPID LIKE SY-REPID,
    GS_PRINT            TYPE SLIS_PRINT_ALV,
    GT_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER,
    GT_EVENTS           TYPE SLIS_T_EVENT,
    GT_SORT             TYPE SLIS_T_SORTINFO_ALV,
    GS_LAYOUT           TYPE SLIS_LAYOUT_ALV,
    GT_FIELDCAT         TYPE SLIS_T_FIELDCAT_ALV,
    FIELDCAT_LN LIKE LINE OF GT_FIELDCAT,
    COL_POS TYPE I.
    DATA: BEGIN OF ITAB,
      FIELD1(5) TYPE C,
      FIELD2(5) TYPE C,
      FIELD3(5) TYPE P DECIMALS 2,
    END OF ITAB.
    DATA: BEGIN OF ITAB1 OCCURS 0.
      INCLUDE STRUCTURE ITAB.
    DATA: END OF ITAB1.
    DATA: BEGIN OF ITAB_FIELDCAT OCCURS 0.
      INCLUDE STRUCTURE ITAB.
    DATA: END OF ITAB_FIELDCAT.
    Print Parameters
    PARAMETERS:
                P_PRINT  AS CHECKBOX DEFAULT ' ', "PRINT IMMEDIATE
                P_NOSINF AS CHECKBOX DEFAULT 'X', "NO SELECTION INFO
                P_NOCOVE AS CHECKBOX DEFAULT ' ', "NO COVER PAGE
                P_NONEWP AS CHECKBOX DEFAULT ' ', "NO NEW PAGE
                P_NOLINF AS CHECKBOX DEFAULT 'X', "NO PRINT LIST INFO
                P_RESERV TYPE I.                  "NO OF FOOTER LINE
    INITIALIZATION.
    G_REPID = SY-REPID.
    PERFORM PRINT_BUILD    USING GS_PRINT.      "Print PARAMETERS
    START-OF-SELECTION.
    TEST DATA
    MOVE 'TEST1' TO ITAB1-FIELD1.
    MOVE 'TEST1' TO ITAB1-FIELD2.
    MOVE '10.00' TO ITAB1-FIELD3.
    APPEND ITAB1.
    MOVE 'TEST2' TO ITAB1-FIELD1.
    MOVE 'TEST2' TO ITAB1-FIELD2.
    MOVE '20.00' TO ITAB1-FIELD3.
    APPEND ITAB1.
    DO 50 TIMES.
      APPEND ITAB1.
    ENDDO.
    END-OF-SELECTION.
    PERFORM BUILD.
    PERFORM EVENTTAB_BUILD CHANGING GT_EVENTS.
    PERFORM COMMENT_BUILD  CHANGING GT_LIST_TOP_OF_PAGE.
    PERFORM CALL_ALV.
    FORM BUILD.
    DATA FIELD CATALOG
    Explain Field Description to ALV
    DATA: FIELDCAT_IN TYPE SLIS_FIELDCAT_ALV.
    CLEAR FIELDCAT_IN.
    FIELDCAT_LN-FIELDNAME = 'FIELD1'.
    FIELDCAT_LN-TABNAME   = 'ITAB1'.
    *FIELDCAT_LN-NO_OUT    = 'X'.  "FIELD NOT DISPLAY, CHOOSE FROM LAYOUT
    FIELDCAT_LN-KEY       = ' '.   "SUBTOTAL KEY
    FIELDCAT_LN-NO_OUT    = ' '.
    FIELDCAT_LN-SELTEXT_L = 'HEAD1'.
    APPEND FIELDCAT_LN TO GT_FIELDCAT.
    CLEAR FIELDCAT_IN.
    FIELDCAT_LN-FIELDNAME = 'FIELD2'.
    FIELDCAT_LN-TABNAME   = 'ITAB1'.
    FIELDCAT_LN-NO_OUT    = 'X'.
    FIELDCAT_LN-SELTEXT_L = 'HEAD2'.
    APPEND FIELDCAT_LN TO GT_FIELDCAT.
    CLEAR FIELDCAT_IN.
    FIELDCAT_LN-FIELDNAME     = 'FIELD3'.
    FIELDCAT_LN-TABNAME       = 'ITAB1'.
    FIELDCAT_LN-REF_FIELDNAME = 'MENGE'. "<- REF FIELD IN THE DICTIONNARY
    FIELDCAT_LN-REF_TABNAME   = 'MSEG'.  "<- REF TABLE IN THE DICTIONNARY
    FIELDCAT_LN-NO_OUT        = ' '.
    FIELDCAT_LN-DO_SUM        = 'X'.   "SUM UPON DISPLAY
    APPEND FIELDCAT_LN TO GT_FIELDCAT.
    DATA SORTING AND SUBTOTAL
    DATA: GS_SORT TYPE SLIS_SORTINFO_ALV.
    CLEAR GS_SORT.
    GS_SORT-FIELDNAME = 'FIELD1'.
    GS_SORT-SPOS      = 1.
    GS_SORT-UP        = 'X'.
    GS_SORT-SUBTOT    = 'X'.
    APPEND GS_SORT TO GT_SORT.
    CLEAR GS_SORT.
    GS_SORT-FIELDNAME = 'FIELD2'.
    GS_SORT-SPOS      = 2.
    GS_SORT-UP        = 'X'.
    *GS_SORT-SUBTOT    = 'X'.
    APPEND GS_SORT TO GT_SORT.
    ENDFORM.
    FORM CALL_ALV.
    ABAP List Viewer
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
    I_INTERFACE_CHECK = ' '
    I_BYPASSING_BUFFER =
    I_BUFFER_ACTIVE = ' '
    I_CALLBACK_PROGRAM = G_REPID
    I_CALLBACK_PF_STATUS_SET = ' '
    I_CALLBACK_USER_COMMAND = ' '
    I_STRUCTURE_NAME = 'ITAB1'
    IS_LAYOUT =  GS_LAYOUT
    IT_FIELDCAT = GT_FIELDCAT[]
    IT_EXCLUDING =
    IT_SPECIAL_GROUPS =
      IT_SORT = GT_SORT[]
    IT_FILTER =
    IS_SEL_HIDE =
    I_DEFAULT = 'X'
    I_SAVE = ' '
    IS_VARIANT =
      IT_EVENTS = GT_EVENTS[]
    IT_EVENT_EXIT =
      IS_PRINT = GS_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 = ITAB1
    EXCEPTIONS
    PROGRAM_ERROR = 1
    OTHERS = 2.
    ENDFORM.
    HEADER FORM
    FORM EVENTTAB_BUILD CHANGING LT_EVENTS TYPE SLIS_T_EVENT.
    CONSTANTS:
    GC_FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE'.
    *GC_FORMNAME_END_OF_PAGE TYPE SLIS_FORMNAME VALUE 'END_OF_PAGE'.
      DATA: LS_EVENT TYPE SLIS_ALV_EVENT.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
           EXPORTING
                I_LIST_TYPE = 0
           IMPORTING
                ET_EVENTS   = LT_EVENTS.
      READ TABLE LT_EVENTS WITH KEY NAME =  SLIS_EV_TOP_OF_PAGE
                               INTO LS_EVENT.
      IF SY-SUBRC = 0.
        MOVE GC_FORMNAME_TOP_OF_PAGE TO LS_EVENT-FORM.
        APPEND LS_EVENT TO LT_EVENTS.
      ENDIF.
    define END_OF_PAGE event
    READ TABLE LT_EVENTS WITH KEY NAME =  SLIS_EV_END_OF_PAGE
                             INTO LS_EVENT.
    IF SY-SUBRC = 0.
      MOVE GC_FORMNAME_END_OF_PAGE TO LS_EVENT-FORM.
      APPEND LS_EVENT TO LT_EVENTS.
    ENDIF.
    ENDFORM.
    FORM COMMENT_BUILD CHANGING GT_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER.
      DATA: GS_LINE TYPE SLIS_LISTHEADER.
      CLEAR GS_LINE.
      GS_LINE-TYP  = 'H'.
      GS_LINE-INFO = 'HEADER 1'.
      APPEND GS_LINE TO GT_TOP_OF_PAGE.
      CLEAR GS_LINE.
      GS_LINE-TYP  = 'S'.
      GS_LINE-KEY  = 'STATUS 1'.
      GS_LINE-INFO = 'INFO 1'.
      APPEND GS_LINE TO GT_TOP_OF_PAGE.
      GS_LINE-KEY  = 'STATUS 2'.
      GS_LINE-INFO = 'INFO 2'.
      APPEND GS_LINE TO GT_TOP_OF_PAGE.
    CLEAR GS_LINE.
    GS_LINE-TYP  = 'A'.
    GS_LINE-INFO = 'ACTION'.
    APPEND GS_LINE TO  GT_TOP_OF_PAGE.
    ENDFORM.
    FORM TOP_OF_PAGE.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
           EXPORTING
                IT_LIST_COMMENTARY = GT_LIST_TOP_OF_PAGE.
      WRITE: SY-DATUM, 'Page No', SY-PAGNO LEFT-JUSTIFIED.
    ENDFORM.
    FORM END_OF_PAGE.
      WRITE at (sy-linsz) sy-pagno CENTERED.
    ENDFORM.
    PRINT SETTINGS
    FORM PRINT_BUILD USING LS_PRINT TYPE SLIS_PRINT_ALV.
      LS_PRINT-PRINT              = P_PRINT.  "PRINT IMMEDIATE
      LS_PRINT-NO_PRINT_SELINFOS  = P_NOSINF. "NO SELECTION INFO
      LS_PRINT-NO_COVERPAGE       = P_NOCOVE. "NO COVER PAGE
      LS_PRINT-NO_NEW_PAGE        = P_NONEWP.
      LS_PRINT-NO_PRINT_LISTINFOS = P_NOLINF. "NO PRINT LIST INFO
      LS_PRINT-RESERVE_LINES      = P_RESERV.
    ENDFORM.
    *END OF ZALV PROGRAM
    Satish

  • How to Display Page Numbers in ALV Report HTML End of page Event

    hai Gurus
    Greetings
    Please tell me how to get current page noumber and total number of pages in ALV Report (in HTML End of Page Event)
    i tried with sy-pagno system field but it is not working
    so please guide me
    Thanks
    Ramesh

    check below code....
    *Work area for Layout
         gf_layout       type  slis_layout_alv,
    *Work area for HEADER FOOTER    
         gf_header type slis_listheader,
    *Work area for Field catalogue    
         gf_fieldcat     type  slis_fieldcat_alv.
         it_top_page type slis_t_listheader,
    *Internal table for Field catalogue    
         it_fcat      type slis_t_fieldcat_alv.
    perform:fill_layout,
                  prepare_header,
                  field_catlog,
                  display_report.
         Form  fill_layout
    form fill_layout .
      gf_layout-colwidth_optimize = 'X'.
    endform.                    " fill_layout
         Form  field_catlog
    form field_catlog .
      data : lf_fcat type line of slis_t_fieldcat_alv,
             l_cnt type i.
      clear : lf_fcat, l_cnt.
    Employee Number
      add 1 to l_cnt.
      lf_fcat-fieldname   = 'EMPLID'.
      lf_fcat-tabname     = 'IT_EMPLOYEE'.
      lf_fcat-col_pos     = l_cnt.
      lf_fcat-emphasize   = 'X'.
      lf_fcat-outputlen   = 8.
      lf_fcat-seltext_l   = text-003.
      append lf_fcat to it_fcat.
      clear  lf_fcat.
    *Last Name
      add 1 to l_cnt.
      lf_fcat-fieldname   = 'USERNAME'.
      lf_fcat-tabname     = 'IT_EMPLOYEE'.
      lf_fcat-col_pos     = l_cnt.
      lf_fcat-emphasize   = 'X'.
      lf_fcat-outputlen   = 20.
      lf_fcat-seltext_l   = text-004.
      append lf_fcat to it_fcat.
    *First Name
      add 1 to l_cnt.
      lf_fcat-fieldname   = 'EMPMAIL'.
      lf_fcat-tabname     = 'IT_EMPLOYEE'.
      lf_fcat-col_pos     = l_cnt.
      lf_fcat-emphasize   = 'X'.
      lf_fcat-outputlen   = 40.
      lf_fcat-seltext_l   = text-005.
      append lf_fcat to it_fcat.
    *Known As
      clear  lf_fcat.
      add 1 to l_cnt.
      lf_fcat-fieldname   = 'EMPSTATUS'.
      lf_fcat-tabname     = 'IT_EMPLOYEE'.
      lf_fcat-col_pos     = l_cnt.
      lf_fcat-emphasize   = 'X'.
      lf_fcat-outputlen   = 10.
      lf_fcat-seltext_l   = text-006.
      append lf_fcat to it_fcat.
      clear  lf_fcat.
    *System UserID
      add 1 to l_cnt.
      lf_fcat-fieldname   = 'COSTCENTER'.
      lf_fcat-tabname     = 'IT_EMPLOYEE'.
      lf_fcat-col_pos     = l_cnt.
      lf_fcat-emphasize   = 'X'.
      lf_fcat-outputlen   = 10.
      lf_fcat-seltext_l   = text-007.
      append lf_fcat to it_fcat.
      clear  lf_fcat.
    *EMail ID
      add 1 to l_cnt.
      lf_fcat-fieldname   = 'DEPTDESC'.
      lf_fcat-tabname     = 'IT_EMPLOYEE'.
      lf_fcat-col_pos     = l_cnt.
      lf_fcat-emphasize   = 'X'.
      lf_fcat-outputlen   = 8.
      lf_fcat-seltext_l   = text-008.
      append lf_fcat to it_fcat.
      clear  lf_fcat.
    *Employment Status
      add 1 to l_cnt.
      lf_fcat-fieldname   = 'LOC'.
      lf_fcat-tabname     = 'IT_EMPLOYEE'.
      lf_fcat-col_pos     = l_cnt.
      lf_fcat-emphasize   = 'X'.
      lf_fcat-outputlen   = 20.
      lf_fcat-seltext_l   = text-009.
      append lf_fcat to it_fcat.
      clear  lf_fcat.
    *Personnel Area
      add 1 to l_cnt.
      lf_fcat-fieldname   = 'TITLE'.
      lf_fcat-tabname     = 'IT_EMPLOYEE'.
      lf_fcat-col_pos     = l_cnt.
      lf_fcat-emphasize   = 'X'.
      lf_fcat-outputlen   = 40.
      lf_fcat-seltext_l   = text-010.
      append lf_fcat to it_fcat.
      clear  lf_fcat.
    *Personnel Area Text
      clear  lf_fcat.
      add 1 to l_cnt.
      lf_fcat-fieldname   = 'HDATE'.
      lf_fcat-tabname     = 'IT_EMPLOYEE'.
      lf_fcat-col_pos     = l_cnt.
      lf_fcat-emphasize   = 'X'.
      lf_fcat-outputlen   = 10.
      lf_fcat-seltext_l   = text-011.
      append lf_fcat to it_fcat.
      clear  lf_fcat.
    *Country Grouping text
      add 1 to l_cnt.
      lf_fcat-fieldname   = 'MGRID'.
      lf_fcat-tabname     = 'IT_EMPLOYEE'.
      lf_fcat-col_pos     = l_cnt.
      lf_fcat-emphasize   = 'X'.
      lf_fcat-outputlen   = 10.
      lf_fcat-seltext_l   = text-012.
      append lf_fcat to it_fcat.
      clear  lf_fcat.
    *Cost Center
      add 1 to l_cnt.
      lf_fcat-fieldname   = 'MGRNAME'.
      lf_fcat-tabname     = 'IT_EMPLOYEE'.
      lf_fcat-col_pos     = l_cnt.
      lf_fcat-emphasize   = 'X'.
      lf_fcat-outputlen   = 20.
      lf_fcat-seltext_l   = text-013.
      append lf_fcat to it_fcat.
      clear  lf_fcat.
    *Employee Group
      add 1 to l_cnt.
      lf_fcat-fieldname   = 'MGMAIL'.
      lf_fcat-tabname     = 'IT_EMPLOYEE'.
      lf_fcat-col_pos     = l_cnt.
      lf_fcat-emphasize   = 'X'.
      lf_fcat-outputlen   = 40.
      lf_fcat-seltext_l   = text-014.
      append lf_fcat to it_fcat.
      clear  lf_fcat.
    *Organizational Unit
      add 1 to l_cnt.
      lf_fcat-fieldname   = 'DIV'.
      lf_fcat-tabname     = 'IT_EMPLOYEE'.
      lf_fcat-col_pos     = l_cnt.
      lf_fcat-emphasize   = 'X'.
      lf_fcat-outputlen   = 25.
      lf_fcat-seltext_l   = text-015.
      append lf_fcat to it_fcat.
      clear  lf_fcat.
    *Supervisor
      add 1 to l_cnt.
      lf_fcat-fieldname   = 'BUSUNIT'.
      lf_fcat-tabname     = 'IT_EMPLOYEE'.
      lf_fcat-col_pos     = l_cnt.
      lf_fcat-emphasize   = 'X'.
      lf_fcat-outputlen   = 25.
      lf_fcat-seltext_l   = text-016.
      append lf_fcat to it_fcat.
      clear  lf_fcat.
    endform.                    " field_catlog
         Form  display_report
    form display_report .
      data : l_repid type sy-repid.
      clear l_repid.
      l_repid = sy-repid.
      call function 'REUSE_ALV_GRID_DISPLAY'
        exporting
          i_callback_program          = l_repid
          is_layout                   = gf_layout
          it_fieldcat                 = it_fcat
          i_callback_top_of_page      = 'TOP-OF-PAGE'
        tables
          t_outtab           = it_employee
        exceptions
          program_error      = 1
          others             = 2.
    endform.                    " display_report
         Form  PREPARE_HEADER
    form prepare_header.
      data:l_header1(20),
           l_header2(60).
      data:l_header3(20),
         l_header4(60).
      l_header1       = 'Met Life Census Data'.
      l_header2+40(8) = 'Run Date'.
      write sy-datum to l_header2+50(10).
    header
      gf_header-typ  = 'S'.
      gf_header-key  = l_header1.
      gf_header-info = l_header2.
      append gf_header to it_top_page.
      clear gf_header.
    endform.                    " PREPARE_HEADER
    form top-of-page.
      call function 'REUSE_ALV_COMMENTARY_WRITE'
        exporting
          it_list_commentary = it_top_page.
    endform.                    "TOP-OF-PAGE
    *& Form end_of_list_html
    output at the end of the list - not in printed output *
    FORM END_OF_LIST_HTML USING END TYPE REF TO CL_DD_DOCUMENT.
    DATA: LS_TEXT TYPE SDYDO_TEXT_ELEMENT,
    L_GRID TYPE REF TO CL_GUI_ALV_GRID,
    F(14) TYPE C VALUE 'SET_ROW_HEIGHT'.
    LS_TEXT+0(20) = 'Total Employees'.
    LS_TEXT+40(10) = g_count.
    CALL METHOD END->ADD_TEXT
    EXPORTING
    TEXT = LS_TEXT
    SAP_EMPHASIS = 'STRONG'.
    *adds new line (start new line)
    CALL METHOD END->NEW_LINE.
    CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
    IMPORTING
    e_grid = l_grid.
    CALL METHOD l_grid->parent->parent->(f)
    EXPORTING
    id = 3
    height = 10.
    ENDFORM.

  • Example of  a Simple ALV Report using Function Modules (not OO)

    Hi,
    I am new to ABAP. Where can I get a proper Example of  a Simple ALV Report using Function Modules?  I searched the forum but did not find a proper solution. Kindly help.
    Smruthi.
    Edited by: Smruthi Acharya on Jan 29, 2009 7:13 PM

    Hi,
    Use this demo code:-
    REPORT  z_alv01 MESSAGE-ID zmsg.
    *          TABLES
    TABLES : ekpo.
    *          TYPE POOLS
    TYPE-POOLS : slis.
    *          TYPE DECLARATION
    TYPES : BEGIN OF t_ekpo,
              ebeln TYPE ekpo-ebeln,
              ebelp TYPE ekpo-ebelp,
              matnr TYPE ekpo-matnr,
              werks TYPE ekpo-werks,
              menge TYPE ekpo-menge,
            END OF t_ekpo.
    *          PARAMETERS
    PARAMETERS : s_var TYPE disvariant-variant.
    *          DATA DECLARATION
    *VARIABLES
    DATA : check(1),
           rep_id TYPE sy-repid.
    *INTERNAL TABLE TYPE OF ZEKPO
    DATA : it_ekpo TYPE STANDARD TABLE OF t_ekpo WITH HEADER LINE.
    *FIELD CATALOG
    DATA : it_field TYPE slis_t_fieldcat_alv,
           wa_field TYPE slis_fieldcat_alv.
    *SORTING
    DATA : it_sort TYPE slis_t_sortinfo_alv,
           wa_sort TYPE slis_sortinfo_alv.
    *FOR TOP OF THE PAGE
    DATA : it_top TYPE slis_t_listheader,
           wa_top TYPE slis_listheader.
    *FOR END OF THE PAGE
    DATA : it_end TYPE slis_t_listheader,
           wa_end TYPE slis_listheader.
    *TO CAPTURE EVENTS AND HANDLE
    DATA : it_event TYPE slis_t_event,
           wa_event TYPE slis_alv_event.
    *FOR GRID TITLE
    DATA : wa_title TYPE lvc_title.
    *FOR LAYOUT
    DATA : wa_layout TYPE slis_layout_alv.
    *FOR EXCLUDING STANDARD BUTTON FROM ALV TOOLBAR
    DATA : it_exclude TYPE slis_t_extab,
           wa_exclude TYPE slis_extab.
    *FOR VARIANT
    DATA : wa_variant TYPE disvariant.
    *          INITIALIZATION
    INITIALIZATION.
      check = 'X'.
      rep_id = sy-repid.
      wa_variant-report = sy-repid.
    *GET DEFUALT ON THE SELECTION SCREEN FOR DEFAULT DISPLAY
      CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
        EXPORTING
          i_save        = 'A'
        CHANGING
          cs_variant    = wa_variant
        EXCEPTIONS
          wrong_input   = 1
          not_found     = 2
          program_error = 3
          OTHERS        = 4.
      IF sy-subrc = 0.               " IF DEFAULT VARIANT FOUND
        s_var = wa_variant-variant.  " PASS THE DEFAULT VARIANT TO THE SELECTION SCREEN FIELD
      ENDIF.
    *          AT-SELECTION SCREEN ON VALUE REQUEST
    *          TO GET THE F4 HELP FOR VARIANT
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_var.
      CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
        EXPORTING
          is_variant                = wa_variant
    *   I_TABNAME_HEADER          =
    *   I_TABNAME_ITEM            =
    *   IT_DEFAULT_FIELDCAT       =
         i_save                    = 'A'
    *   I_DISPLAY_VIA_GRID        = ' '
       IMPORTING
    *   E_EXIT                    =
         es_variant                = wa_variant
       EXCEPTIONS
         not_found                 = 1
         program_error             = 2
         OTHERS                    = 3.
      IF sy-subrc = 0.
        s_var = wa_variant-variant. " PASS THE SELECTED VARIANT TO THE SELECTION SCREEN FIELD
      ENDIF.
    *          AT-SELECTION SCREEN
    *          TO CHECK THE EXISTENCE FOR VARIANT
    AT SELECTION-SCREEN.
      wa_variant-variant = s_var.
      CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
        EXPORTING
          i_save        = 'A'
        CHANGING
          cs_variant    = wa_variant
        EXCEPTIONS
          wrong_input   = 1
          not_found     = 2
          program_error = 3
          OTHERS        = 4.
      IF sy-subrc <> 0.
        MESSAGE w001.
      ENDIF.
    *          START OF SELECTION
    START-OF-SELECTION.
      SELECT ebeln
             ebelp
             matnr
             werks
             menge
             FROM ekpo
             INTO TABLE it_ekpo.
    *          FIELD CATALOG
      wa_field-fieldname = 'EBELN'.
      wa_field-tabname = 'IT_TAB'.
      wa_field-outputlen = 10.
      wa_field-seltext_l = 'PO #'.
      APPEND wa_field TO it_field.
      CLEAR wa_field.
      wa_field-fieldname = 'EBELP'.
      wa_field-tabname = 'IT_TAB'.
      wa_field-outputlen = 10.
      wa_field-seltext_l = 'Line Item'.
      APPEND wa_field TO it_field.
      CLEAR wa_field.
      wa_field-fieldname = 'MATNR'.
      wa_field-tabname = 'IT_TAB'.
      wa_field-outputlen = 15.
      wa_field-seltext_l = 'Material'.
    *  wa_field-input = check.
    *  wa_field-edit = check.
      APPEND wa_field TO it_field.
      CLEAR wa_field.
      wa_field-fieldname = 'WERKS'.
      wa_field-tabname = 'IT_TAB'.
      wa_field-outputlen = 6.
      wa_field-seltext_l = 'Plant'.
    *  wa_field-input = check.
    *  wa_field-edit = check.
      APPEND wa_field TO it_field.
      CLEAR wa_field.
      wa_field-fieldname = 'MENGE'.
      wa_field-tabname = 'IT_TAB'.
      wa_field-outputlen = 10.
      wa_field-seltext_l = 'Qty.'.
    *  wa_field-input = check.
    *  wa_field-edit = check.
      wa_field-do_sum = check.
      APPEND wa_field TO it_field.
      CLEAR wa_field.
    *          SORT W.R.T. PURCHASE ORDER NUMBER
      wa_sort-spos = 1.
      wa_sort-fieldname = 'EBELN'.
      wa_sort-tabname = 'IT_EKPO'.
      wa_sort-up = check.
      wa_sort-subtot = check.
      APPEND wa_sort TO it_sort.
      CLEAR wa_sort.
    *          FOR GRID TITLE
      wa_title = 'Hello'.
    *          FOR LAYOUT
      wa_layout-zebra = check.
    *          FOR EXCLUDING STANDARD BUTTONS FROM ALV TOOLBAR
      wa_exclude-fcode = '&OUP'.
      APPEND wa_exclude TO it_exclude.
      CLEAR wa_exclude.
      wa_exclude-fcode = '&ODN'.
      APPEND wa_exclude TO it_exclude.
      CLEAR wa_exclude.
      wa_exclude-fcode = '&OAD'.
      APPEND wa_exclude TO it_exclude.
      CLEAR wa_exclude.
    *  wa_exclude-fcode = '&AVE'.
    *  APPEND wa_exclude TO it_exclude.
    *  CLEAR wa_exclude.
      wa_exclude-fcode = '&INFO'.
      APPEND wa_exclude TO it_exclude.
      CLEAR wa_exclude.
    *          POPULATE ALL EVENTS INTO INTERNAL TABLE
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type     = 0
        IMPORTING
          et_events       = it_event
        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 it_event INTO wa_event WITH KEY name = 'END_OF_LIST'.
      wa_event-form = 'END'.
      MODIFY it_event FROM wa_event INDEX sy-tabix.
      CLEAR wa_event.
    *          DISPLAY RECORDS IN ALV GRID
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
    *   I_INTERFACE_CHECK                 = ' '
    *   I_BYPASSING_BUFFER                = ' '
    *   I_BUFFER_ACTIVE                   = ' '
       i_callback_program                = rep_id
    *   i_callback_pf_status_set          = 'PF'
       i_callback_user_command           = '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                      = wa_title
    *   I_GRID_SETTINGS                   =
       is_layout                         = wa_layout
       it_fieldcat                       = it_field
       it_excluding                      = it_exclude
    *   IT_SPECIAL_GROUPS                 =
       it_sort                           = it_sort
    *   IT_FILTER                         =
    *   IS_SEL_HIDE                       =
    *   I_DEFAULT                         = 'X'
       i_save                            = 'A'
       is_variant                        = wa_variant
       it_events                         = it_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                          = it_ekpo
    EXCEPTIONS
       program_error                     = 1
       OTHERS                            = 2.
      IF sy-subrc <> 0.
      ENDIF.
    *&      Form  top
    *       TO WRITE THE HEADER
    FORM top.
      REFRESH it_top.
      wa_top-typ = 'S'.
      wa_top-key = text-001.
      wa_top-info = rep_id.
      APPEND wa_top TO it_top.
      CLEAR wa_top.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary       = it_top
    *   I_LOGO                   =
    *   I_END_OF_LIST_GRID       =
    *   I_ALV_FORM               =
    ENDFORM.                    "top
    *&      Form  end
    *       TO WRITE THE FOOTER
    FORM end.
      REFRESH it_end.
      wa_end-typ = 'S'.
      wa_end-key = text-001.
      wa_end-info = rep_id.
      APPEND wa_end TO it_end.
      CLEAR wa_end.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary       = it_end
    *   I_LOGO                   =
    *   I_END_OF_LIST_GRID       =
    *   I_ALV_FORM               =
    ENDFORM.                    "end
    *&      Form  pf
    *       FOR PF-STATUS WITH USER DEFINED BUTTONS
    *      -->RT_EXTAB   text
    FORM pf USING rt_extab TYPE slis_t_extab.
      SET PF-STATUS 'ZTG_PF_ALV'.
    ENDFORM.                    "pf
    *&      Form  command
    *       TO HANDLE USER ACTIONS AGAINST PF-STATUS
    *      -->UCOMM      text
    *      -->SELFIELD   text
    FORM command USING ucomm LIKE sy-ucomm selfield TYPE slis_selfield.
      DATA : ok_code TYPE sy-ucomm.
      ok_code = ucomm.
      CASE ok_code.
        WHEN 'T_DOWN'.
          CALL FUNCTION 'POPUP_TO_INFORM'
            EXPORTING
              titel = 'HELLO'
              txt1  = 'USER COMMAND'
              txt2  = 'TOTAL DOWN'.
        WHEN 'DOWN'.
          CALL FUNCTION 'POPUP_TO_INFORM'
            EXPORTING
              titel = 'HELLO'
              txt1  = 'USER COMMAND'
              txt2  = 'DOWN'.
        WHEN 'UP'.
          CALL FUNCTION 'POPUP_TO_INFORM'
            EXPORTING
              titel = 'HELLO'
              txt1  = 'USER COMMAND'
              txt2  = 'UP'.
        WHEN 'T_UP'.
          CALL FUNCTION 'POPUP_TO_INFORM'
            EXPORTING
              titel = 'HELLO'
              txt1  = 'USER COMMAND'
              txt2  = 'TOTAL UP'.
      ENDCASE.
    ENDFORM.                    "command
    Hope this helps you.
    Thanks & Regards,
    Tarun Gambhir

  • ALV report using the field catalog

    which is the quickest way to generate an ALV report using the field catalog merge.  without needing to build the field catalog manually .
    is it easier to create a structure and passe it in the field catalog merge .  if yes can i have an example plzzzz

    hI
    Supports the creation of the field catalog for the ALV function modules
    based either on a structure or table defined in the ABAP Data
    Dictionary, or a program-internal table.
    The program-internal table must either be in a TOP Include or its
    Include must be specified explicitly in the interface.
    The variant based on a program-internal table should only be used for
    rapid prototyping since the following restrictions apply:
    o Performance is affected since the code of the table definition must
    always be read and interpreted at runtime.
    o Dictionary references are only considered if the keywords LIKE or
    INCLUDE STRUCTURE (not TYPE) are used.
    If the field catalog contains more than 90 fields, the first 90 fields
    are output in the list by default whereas the remaining fields are only
    available in the field selection.
    If the field catalog is passed with values, they are merged with the
    'automatically' found information.
    Below is an example ABAP program which will populate a simple internal table(it_ekpo) with data and
    display it using the basic ALV grid functionality(including column total). The example details the main
    sections of coding required to implement the ALV grid functionality:
                             Data declaration
                             Data retrieval
                             Build fieldcatalog
                             Build layout setup
    *& Report  ZDEMO_ALVGRID                                               *
    *& Example of a simple ALV Grid Report                                 *
    *& The basic requirement for this demo is to display a number of       *
    *& fields from the EKKO table.                                         *
    REPORT  zdemo_alvgrid                 .
    TABLES:     ekko.
    type-pools: slis.                                 "ALV Declarations
    *Data Declaration
    TYPES: BEGIN OF t_ekko,
      ebeln TYPE ekpo-ebeln,
      ebelp TYPE ekpo-ebelp,
      statu TYPE ekpo-statu,
      aedat TYPE ekpo-aedat,
      matnr TYPE ekpo-matnr,
      menge TYPE ekpo-menge,
      meins TYPE ekpo-meins,
      netpr TYPE ekpo-netpr,
      peinh TYPE ekpo-peinh,
    END OF t_ekko.
    DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
          wa_ekko TYPE t_ekko.
    *ALV data declarations
    data: fieldcatalog type slis_t_fieldcat_alv with header line,
          gd_tab_group type slis_t_sp_group_alv,
          gd_layout    type slis_layout_alv,
          gd_repid     like sy-repid.
    *Start-of-selection.
    START-OF-SELECTION.
    perform data_retrieval.
    perform build_fieldcatalog.
    perform build_layout.
    perform display_alv_report.
    *&      Form  BUILD_FIELDCATALOG
    *       Build Fieldcatalog for ALV Report
    form build_fieldcatalog.
    * There are a number of ways to create a fieldcat.
    * For the purpose of this example i will build the fieldcatalog manualy
    * by populating the internal table fields individually and then
    * appending the rows. This method can be the most time consuming but can
    * also allow you  more control of the final product.
    * Beware though, you need to ensure that all fields required are
    * populated. When using some of functionality available via ALV, such as
    * total. You may need to provide more information than if you were
    * simply displaying the result
    *               I.e. Field type may be required in-order for
    *                    the 'TOTAL' function to work.
      fieldcatalog-fieldname   = 'EBELN'.
      fieldcatalog-seltext_m   = 'Purchase Order'.
      fieldcatalog-col_pos     = 0.
      fieldcatalog-outputlen   = 10.
      fieldcatalog-emphasize   = 'X'.
      fieldcatalog-key         = 'X'.
    *  fieldcatalog-do_sum      = 'X'.
    *  fieldcatalog-no_zero     = 'X'.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'EBELP'.
      fieldcatalog-seltext_m   = 'PO Item'.
      fieldcatalog-col_pos     = 1.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'STATU'.
      fieldcatalog-seltext_m   = 'Status'.
      fieldcatalog-col_pos     = 2.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'AEDAT'.
      fieldcatalog-seltext_m   = 'Item change date'.
      fieldcatalog-col_pos     = 3.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MATNR'.
      fieldcatalog-seltext_m   = 'Material Number'.
      fieldcatalog-col_pos     = 4.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MENGE'.
      fieldcatalog-seltext_m   = 'PO quantity'.
      fieldcatalog-col_pos     = 5.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MEINS'.
      fieldcatalog-seltext_m   = 'Order Unit'.
      fieldcatalog-col_pos     = 6.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'NETPR'.
      fieldcatalog-seltext_m   = 'Net Price'.
      fieldcatalog-col_pos     = 7.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-do_sum      = 'X'.        "Display column total
      fieldcatalog-datatype     = 'CURR'.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'PEINH'.
      fieldcatalog-seltext_m   = 'Price Unit'.
      fieldcatalog-col_pos     = 8.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
    endform.                    " BUILD_FIELDCATALOG
    *&      Form  BUILD_LAYOUT
    *       Build layout for ALV grid report
    form build_layout.
      gd_layout-no_input          = 'X'.
      gd_layout-colwidth_optimize = 'X'.
      gd_layout-totals_text       = 'Totals'(201).
    *  gd_layout-totals_only        = 'X'.
    *  gd_layout-f2code            = 'DISP'.  "Sets fcode for when double
    *                                         "click(press f2)
    *  gd_layout-zebra             = 'X'.
    *  gd_layout-group_change_edit = 'X'.
    *  gd_layout-header_text       = 'helllllo'.
    endform.                    " BUILD_LAYOUT
    *&      Form  DISPLAY_ALV_REPORT
    *       Display report using ALV grid
    form display_alv_report.
      gd_repid = sy-repid.
      call function 'REUSE_ALV_GRID_DISPLAY'
           exporting
                i_callback_program      = gd_repid
    *            i_callback_top_of_page   = 'TOP-OF-PAGE'  "see FORM
    *            i_callback_user_command = 'USER_COMMAND'
    *            i_grid_title           = outtext
                is_layout               = gd_layout
                it_fieldcat             = fieldcatalog[]
    *            it_special_groups       = gd_tabgroup
    *            IT_EVENTS                = GT_XEVENTS
                i_save                  = 'X'
    *            is_variant              = z_template
           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  DATA_RETRIEVAL
    *       Retrieve data form EKPO table and populate itab it_ekko
    form data_retrieval.
    select ebeln ebelp statu aedat matnr menge meins netpr peinh
    up to 10 rows
      from ekpo
      into table it_ekko.
    endform.                    " DATA_RETRIEVAL

  • Reg. Events in ALV Reports

    Hi all,
    Can anybody send me the sample program, related to Events on ALV Reports.
    Use ful answers rewards more.

    Hi Raj,
    Here I'm sending 2 programs with user command on grid and list.
    along with interaction and commentory boxes and all.
    separate box ****************
    TABLES: KNA1,VBAK,VBAP.
    TYPE-POOLS: SLIS.
    SELECT-OPTIONS: CUST FOR KNA1-KUNNR.
    DATA: BEGIN OF ITAB OCCURS 0,
          KUNNR LIKE KNA1-KUNNR,
          NAME LIKE KNA1-NAME1,
          LAND1 LIKE KNA1-LAND1,
          END OF ITAB.
    DATA: BEGIN OF JTAB OCCURS 0,
          VBELN LIKE VBAK-VBELN,
          NETWR LIKE VBAK-NETWR,
          END OF JTAB.
    DATA: BEGIN OF KTAB OCCURS 0,
          POSNR LIKE VBAP-POSNR,
          MATNR LIKE VBAP-MATNR,
          END OF KTAB.
    DATA: REPID LIKE SY-REPID,
    *INTERNAL TABLE AND STRUCTURE.
    *SLIS_T_FIELDCAT_ALV IS AN INTERNAL TABLE.
    *SLIS_FIELDCAT_ALV   IS AN STRUCTURE.
          F_KNA11 TYPE SLIS_T_FIELDCAT_ALV,
          F_KNA1 TYPE SLIS_FIELDCAT_ALV,
          F_VBAK1 TYPE SLIS_T_FIELDCAT_ALV,
          F_VBAK TYPE SLIS_FIELDCAT_ALV,
          F_VBAP1 TYPE SLIS_T_FIELDCAT_ALV,
          F_VBAP TYPE SLIS_FIELDCAT_ALV,
          I_EVENTS TYPE SLIS_T_EVENT,
          S_EVENTS TYPE SLIS_ALV_EVENT.
      PERFORM GET-VAL.
      REPID = SY-REPID.
      SELECT KUNNR NAME1 LAND1 FROM KNA1 INTO TABLE ITAB WHERE KUNNR IN
    CUST
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
      EXPORTING
         I_CALLBACK_PROGRAM             = REPID
         IT_FIELDCAT                    = F_KNA11
         IT_EVENTS                      = I_EVENTS
        TABLES
          T_OUTTAB                       = ITAB.
    GET VAL
    FORM GET-VAL.
          F_KNA1-FIELDNAME = 'KUNNR'.
          F_KNA1-REF_TABNAME = 'KNA1'.
          F_KNA1-REF_FIELDNAME = 'KUNNR'.
          APPEND F_KNA1 TO F_KNA11.
          F_KNA1-FIELDNAME = 'NAME'.
          F_KNA1-REF_TABNAME = 'KNA1'.
          F_KNA1-REF_FIELDNAME = 'NAME1'.
          APPEND F_KNA1 TO F_KNA11.
          F_KNA1-FIELDNAME = 'LAND1'.
          F_KNA1-REF_TABNAME = 'KNA1'.
          F_KNA1-REF_FIELDNAME = 'LAND1'.
          APPEND F_KNA1 TO F_KNA11.
          F_VBAK-FIELDNAME = 'VBELN'.
          F_VBAK-REF_TABNAME = 'VBAK'.
          F_VBAK-REF_FIELDNAME = 'VBELN'.
          APPEND F_VBAK TO F_VBAK1.
          F_VBAK-FIELDNAME = 'NETWR'.
          F_VBAK-REF_TABNAME = 'VBAK'.
          F_VBAK-REF_FIELDNAME = 'NETWR'.
          F_VBAK-DO_SUM = 'X'.
          APPEND F_VBAK TO F_VBAK1.
          F_VBAP-FIELDNAME = 'POSNR'.
          F_VBAP-REF_TABNAME = 'VBAP'.
          F_VBAP-REF_FIELDNAME = 'POSNR'.
          APPEND F_VBAP TO F_VBAP1.
          F_VBAP-FIELDNAME = 'MATNR'.
          F_VBAP-REF_TABNAME = 'VBAP'.
          F_VBAP-REF_FIELDNAME = 'MATNR'.
          APPEND F_VBAP TO F_VBAP1.
          S_EVENTS-NAME = 'USER_COMMAND'.
          S_EVENTS-FORM = 'VAL'.
          APPEND S_EVENTS TO I_EVENTS.
    ENDFORM.
    FORM VAL USING USER_COMMAND LIKE SY-UCOMM SEL TYPE SLIS_SELFIELD.
    DATA: CUS(10) TYPE N,
          SALNO(10) TYPE N,
          MAT(10) TYPE C.
    display lists
    IF SEL-FIELDNAME = 'KUNNR'.
        CUS = SEL-VALUE.
        SELECT VBELN NETWR FROM VBAK INTO TABLE JTAB WHERE KUNNR = CUS.
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
         I_CALLBACK_PROGRAM             = REPID
         IT_FIELDCAT                    = F_VBAK1
         IT_EVENTS                      = I_EVENTS
        TABLES
          T_OUTTAB                       = JTAB.
    ENDIF.
    IF SEL-FIELDNAME = 'VBELN'.
        SALNO = SEL-VALUE.
        SELECT POSNR MATNR FROM VBAP INTO TABLE KTAB WHERE VBELN = SALNO.
    CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'
      EXPORTING
       I_TITLE                       = ' ITEM DETAILS'
        I_TABNAME                     = VBAP
       IT_FIELDCAT                   = F_VBAP1
       I_CALLBACK_PROGRAM            = REPID
    IMPORTING
       ES_SELFIELD                   = SEL
      TABLES
        T_OUTTAB                      = KTAB.
    ENDIF.
    IF SEL-FIELDNAME = 'MATNR'.
    MAT = SEL-VALUE.
    SET PARAMETER ID 'MAT' FIELD MAT.
    CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.
    ENDIF.
    ENDFORM.
    Grid Display ***************
    TYPE-POOLS: SLIS.
    TABLES: KNA1.
    *DATA: ITAB TYPE STANDARD TABLE OF ZJKNA1 WITH HEADER LINE.
    DATA: BEGIN OF ITAB OCCURS 0,
          KUNNR TYPE KUNNR,
          NAME1 TYPE KNA1-NAME1,
          END OF ITAB.
    DATA: JTAB LIKE ITAB OCCURS 0 WITH HEADER LINE.
    DATA: IT_TOP TYPE SLIS_T_LISTHEADER.
    DATA: W_TOP TYPE SLIS_LISTHEADER.
    DATA: IT_EVENT TYPE SLIS_T_EVENT.
    DATA: W_EVENT TYPE SLIS_ALV_EVENT.
    W_EVENT-NAME = 'TOP_OF_PAGE'.
    W_EVENT-FORM = 'TOPS'.
    APPEND W_EVENT TO IT_EVENT.
    W_EVENT-NAME = 'USER_COMMAND'.
    W_EVENT-FORM = 'UCOM'.
    APPEND W_EVENT TO IT_EVENT.
    DATA: S_LAYOUT TYPE SLIS_LAYOUT_ALV.
    *S_LAYOUT-NO_VLINE = 'X'.
    S_LAYOUT-ZEBRA = 'X'.
    S_LAYOUT-NO_COLHEAD = ''.
    S_LAYOUT-TOTALS_ONLY = 'TL'.
    DATA: IT_LISTHEADER TYPE SLIS_T_LISTHEADER.
    DATA: W_LISTHEADER TYPE SLIS_LISTHEADER.
    W_LISTHEADER-TYP = 'H'.
    W_LISTHEADER-KEY = 'THIS IS LIST'.
    APPEND W_LISTHEADER TO IT_LISTHEADER.
    DATA: IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
    DATA: W_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
    W_FIELDCAT-COL_POS = 1.
    W_FIELDCAT-FIELDNAME = 'KUNNR'.
    W_FIELDCAT-TABNAME = 'ITAB'.
    W_FIELDCAT-SELTEXT_M = 'CUST. NO'.
    W_FIELDCAT-HOTSPOT = 'X'.
    APPEND W_FIELDCAT TO IT_FIELDCAT.
    CLEAR W_FIELDCAT.
    W_FIELDCAT-COL_POS = 2.
    W_FIELDCAT-FIELDNAME = 'NAME1'.
    W_FIELDCAT-TABNAME = 'ITAB'.
    W_FIELDCAT-SELTEXT_M = 'CUST. NAME'.
    W_FIELDCAT-OUTPUTLEN = 30.
    APPEND W_FIELDCAT TO IT_FIELDCAT.
    CLEAR W_FIELDCAT.
    SELECT KUNNR NAME1 FROM KNA1 INTO CORRESPONDING FIELDS OF TABLE ITAB
    UP TO 50 ROWS.
    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            = W_LISTHEADER
      I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
      I_CALLBACK_HTML_END_OF_LIST       = ' '
      I_STRUCTURE_NAME                  =
      I_BACKGROUND_ID                   = 'ENJOY.BMP'
      I_GRID_TITLE                      = 'THIS IS MY FIRST ALV REPORT'
      I_GRID_SETTINGS                   = W_LISTHEADER
       IS_LAYOUT                         = S_LAYOUT
       IT_FIELDCAT                       = IT_FIELDCAT
      IT_EXCLUDING                      =
      IT_SPECIAL_GROUPS                 =
      IT_SORT                           =
      IT_FILTER                         =
      IS_SEL_HIDE                       =
      I_DEFAULT                         = 'X'
      I_SAVE                            = ' '
      IS_VARIANT                        =
       IT_EVENTS                         = IT_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
      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                          = 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.
    **&      Form  TOPS
          text
    -->  p1        text
    <--  p2        text
    FORM TOPS .
    REFRESH IT_TOP.
    W_TOP-TYP = 'H'.
    *W_TOP-KEY = 'JAGAN'.
    W_TOP-INFO = 'THIS IS SAMPLE HEADER'.
    APPEND W_TOP TO IT_TOP.
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
      EXPORTING
       IT_LIST_COMMENTARY       = IT_TOP
       I_LOGO                   = 'IDLOGO1'
      I_END_OF_LIST_GRID       =
    ENDFORM.                    " TOPS
    *&      Form  UCOM
          text
    -->  p1        text
    <--  p2        text
    FORM UCOM USING USER_COMMAND LIKE SY-UCOMM SEL TYPE SLIS_SELFIELD.
    DATA: CUS(10) TYPE N VALUE '0000000000'.
    CUS = SEL-VALUE.
    REFRESH ITAB.
    SELECT KUNNR NAME1 FROM KNA1 INTO TABLE ITAB WHERE KUNNR = CUS.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
         I_CALLBACK_PROGRAM             = SY-REPID
         IT_FIELDCAT                    = IT_FIELDCAT
        IT_EVENTS                      = IT_EVENTS
        TABLES
          T_OUTTAB                       = ITAB.
    ENDFORM.                    " UCOM

  • ALV report using OOPS concept.

    Hi,
    Please help me in writing ALV report using OOPS concept as i have never used this concept before.Please post a clear picture for this.
    Thanks in advance.

    Hi
    Refer this code:
    REPORT zcls_alv_oops MESSAGE-ID z1.
    TABLES : mara.
    Types Declaration..\
    TYPES :
    BEGIN OF t_mara,
    matnr TYPE matnr,
    mtart TYPE mtart,
    maktx TYPE maktx,
    END OF t_mara,
    BEGIN OF t_marc,
    matnr TYPE matnr,
    werks TYPE werks_d,
    mtart TYPE mtart,
    maktx TYPE maktx,
    END OF t_marc.
    Internal Tables Declaration..\
    DATA :
    i_mara TYPE TABLE OF t_mara,
    i_marc TYPE TABLE OF t_marc,
    i_fcat1 TYPE lvc_t_fcat,
    i_fcat2 TYPE lvc_t_fcat.
    Constants Declaration..\
    CONSTANTS :
    c_cont1 TYPE scrfname VALUE 'CONT1',
    c_cont2 TYPE scrfname VALUE 'CONT2'.
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
    SELECT-OPTIONS:
    s_matnr FOR mara-matnr NO INTERVALS.
    SELECTION-SCREEN SKIP 1.
    PARAMETERS :
    p_hotspt RADIOBUTTON GROUP r1 DEFAULT 'X',
    p_bttn RADIOBUTTON GROUP r1.
    SELECTION-SCREEN END OF BLOCK b1.
    \* Class forward referncing.
    CLASS lcl_rcvr_class DEFINITION DEFERRED.
    \* Pointers Declaration..
    DATA :
    lp_rcvr TYPE REF TO lcl_rcvr_class,
    lp_cont1 TYPE REF TO cl_gui_custom_container,
    lp_cont2 TYPE REF TO cl_gui_custom_container,
    lp_grid1 TYPE REF TO cl_gui_alv_grid,
    lp_grid2 TYPE REF TO cl_gui_alv_grid.
    \* Local Class Definiton.
    CLASS lcl_rcvr_class DEFINITION.
    PUBLIC SECTION.
    METHODS :
    hotspot_click FOR EVENT hotspot_click OF cl_gui_alv_grid
    IMPORTING e_row_id e_column_id es_row_no,
    handle_double_click FOR EVENT double_click OF cl_gui_alv_grid
    IMPORTING e_row e_column.
    ENDCLASS.
    \* Local Class Implementation.
    CLASS lcl_rcvr_class IMPLEMENTATION.
    METHOD hotspot_click.
    DATA :
    wa_mara TYPE t_mara,
    wa_marc TYPE t_marc.
    DATA :
    l_index TYPE sy-tabix.
    READ TABLE i_mara INTO wa_mara INDEX e_row_id-index.
    IF sy-subrc EQ 0.
    REFRESH i_marc.
    SELECT matnr
    werks
    INTO TABLE i_marc
    FROM marc
    WHERE matnr EQ wa_mara-matnr.
    IF sy-subrc EQ 0.
    LOOP AT i_marc INTO wa_marc.
    l_index = sy-tabix.
    wa_marc-mtart = wa_mara-mtart.
    wa_marc-maktx = wa_mara-maktx.
    MODIFY i_marc FROM wa_marc INDEX l_index
    TRANSPORTING mtart maktx.
    ENDLOOP.
    CALL SCREEN 200.
    ELSE.
    MESSAGE e121 WITH text-005 wa_mara-matnr.
    ENDIF.
    ENDIF.
    ENDMETHOD.
    METHOD handle_double_click.
    DATA :
    wa_mara TYPE t_mara,
    wa_marc TYPE t_marc.
    DATA :
    l_index TYPE sy-tabix.
    READ TABLE i_mara INTO wa_mara INDEX e_row-index.
    IF sy-subrc EQ 0.
    REFRESH i_marc.
    SELECT matnr
    werks
    INTO TABLE i_marc
    FROM marc
    WHERE matnr EQ wa_mara-matnr.
    IF sy-subrc EQ 0.
    LOOP AT i_marc INTO wa_marc.
    l_index = sy-tabix.
    wa_marc-mtart = wa_mara-mtart.
    wa_marc-maktx = wa_mara-maktx.
    MODIFY i_marc FROM wa_marc INDEX l_index
    TRANSPORTING mtart maktx.
    ENDLOOP.
    CALL SCREEN 200.
    ELSE.
    MESSAGE e121 WITH text-005 wa_mara-matnr.
    ENDIF.
    ENDIF.
    ENDMETHOD.
    ENDCLASS.
    \* Start of Selection
    START-OF-SELECTION.
    \* Extract the Material Master data for the Input Material.
    SELECT a~matnr
    a~mtart
    b~maktx
    INTO TABLE i_mara
    FROM mara AS a
    INNER JOIN makt AS b
    ON a~matnr EQ b~matnr
    WHERE a~matnr IN s_matnr
    AND b~spras EQ sy-langu.
    END-OF-SELECTION.
    IF NOT i_mara\[\] IS INITIAL.
    \* Call Screen to display the Material Master data.
    CALL SCREEN 100.
    ELSE.
    MESSAGE s121 WITH text-006.
    ENDIF.
    \*& Module DISP_GRID OUTPUT
    \* text
    MODULE disp_grid OUTPUT.
    \* Build the Field catelog for Material Master data.
    PERFORM build_fcat.
    \* Display the Material Master data using ALV.
    PERFORM disp_alv.
    ENDMODULE. " DISP_GRID OUTPUT
    \*& Module USER_COMMAND_0100 INPUT
    \* text
    MODULE user_command_0100 INPUT.
    \*when exit or cancel is clicked program has to come out
    CASE sy-ucomm.
    WHEN 'EXIT' OR 'CANC'.
    LEAVE PROGRAM.
    WHEN 'BACK'.
    LEAVE TO SCREEN 0.
    ENDCASE.
    ENDMODULE. " USER_COMMAND_0100 INPUT
    \*& Form build_fcat
    \* text
    \* \--> p1 text
    \* <-\- p2 text
    FORM build_fcat.
    DATA : ws_fcat TYPE lvc_s_fcat.
    ws_fcat-fieldname = 'MATNR'.
    ws_fcat-scrtext_m = text-001.
    ws_fcat-tabname = 'I_MARA'.
    IF p_hotspt EQ 'X'.
    ws_fcat-hotspot = 'X'.
    ENDIF.
    APPEND ws_fcat TO i_fcat1.
    CLEAR ws_fcat.
    ws_fcat-fieldname = 'MTART'.
    ws_fcat-scrtext_m = text-002.
    ws_fcat-tabname = 'I_MARA'.
    APPEND ws_fcat TO i_fcat1.
    CLEAR ws_fcat.
    ws_fcat-fieldname = 'MAKTX'.
    ws_fcat-scrtext_m = text-003.
    ws_fcat-tabname = 'I_MARA'.
    APPEND ws_fcat TO i_fcat1.
    CLEAR ws_fcat.
    ENDFORM. " build_fcat
    \*& Form disp_alv
    \* text
    \* \--> p1 text
    \* <-\- p2 text
    FORM disp_alv.
    IF lp_cont1 IS INITIAL.
    \* Create the Container Object of Material Master.
    CREATE OBJECT lp_cont1
    EXPORTING
    container_name = c_cont1
    EXCEPTIONS
    cntl_error = 1
    cntl_system_error = 2
    create_error = 3
    lifetime_error = 4
    lifetime_dynpro_dynpro_link = 5
    others = 6 .
    IF sy-subrc NE 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ELSE.
    \* Create the Object for Grid of Material Master.
    CREATE OBJECT lp_grid1
    EXPORTING
    i_parent = lp_cont1
    EXCEPTIONS
    error_cntl_create = 1
    error_cntl_init = 2
    error_cntl_link = 3
    error_dp_create = 4
    others = 5.
    IF sy-subrc NE 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ELSE.
    \* Dipslay Material Master data by calling method.
    CALL METHOD lp_grid1->set_table_for_first_display
    CHANGING
    it_outtab = i_mara
    it_fieldcatalog = i_fcat1
    EXCEPTIONS
    invalid_parameter_combination = 1
    program_error = 2
    too_many_lines = 3
    OTHERS = 4.
    IF sy-subrc NE 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ELSE.
    \* Set Handler for the Hot Spot Event.
    CREATE OBJECT lp_rcvr.
    IF p_hotspt EQ 'X'.
    SET HANDLER lp_rcvr->hotspot_click FOR lp_grid1.
    ELSE.
    SET HANDLER lp_rcvr->handle_double_click FOR lp_grid1.
    ENDIF.
    ENDIF.
    ENDIF.
    ENDIF.
    ENDIF.
    ENDFORM. " disp_alv
    \*& Module STATUS_0100 OUTPUT
    \* text
    MODULE status_0100 OUTPUT.
    SET PF-STATUS 'MAIN_STAT'.
    SET TITLEBAR 'T_100'.
    ENDMODULE. " STATUS_0100 OUTPUT
    \*& Module STATUS_0200 OUTPUT
    \* text
    MODULE status_0200 OUTPUT.
    SET PF-STATUS 'PLANT_STAT'.
    SET TITLEBAR 'T_200'.
    ENDMODULE. " STATUS_0200 OUTPUT
    \*& Module DISP_GRID_plant OUTPUT
    \* text
    MODULE disp_grid_plant OUTPUT.
    \* Build the Field catelog for Material Plant data.
    PERFORM build_fcat_plant.
    \* Display the Material Master Plant data using ALV.
    PERFORM disp_alv_plant.
    ENDMODULE. " DISP_GRID_plant OUTPUT
    \*& Module USER_COMMAND_0200 INPUT
    \* text
    MODULE user_command_0200 INPUT.
    \*when exit or cancel is clicked program has to come out
    CASE sy-ucomm.
    WHEN 'EXIT' OR 'CANC'.
    LEAVE PROGRAM.
    WHEN 'BACK'.
    LEAVE TO SCREEN 0.
    ENDCASE.
    ENDMODULE. " USER_COMMAND_0200 INPUT
    \*& Form build_fcat_plant
    \* text
    \* \--> p1 text
    \* <-\- p2 text
    FORM build_fcat_plant.
    DATA : ws_fcat TYPE lvc_s_fcat.
    ws_fcat-fieldname = 'MATNR'.
    ws_fcat-scrtext_m = text-001.
    ws_fcat-tabname = 'I_MARC'.
    APPEND ws_fcat TO i_fcat2.
    CLEAR ws_fcat.
    ws_fcat-fieldname = 'WERKS'.
    ws_fcat-scrtext_m = text-004.
    ws_fcat-tabname = 'I_MARC'.
    APPEND ws_fcat TO i_fcat2.
    CLEAR ws_fcat.
    ws_fcat-fieldname = 'MTART'.
    ws_fcat-scrtext_m = text-002.
    ws_fcat-tabname = 'I_MARC'.
    APPEND ws_fcat TO i_fcat2.
    CLEAR ws_fcat.
    ws_fcat-fieldname = 'MAKTX'.
    ws_fcat-scrtext_m = text-003.
    ws_fcat-tabname = 'I_MARC'.
    APPEND ws_fcat TO i_fcat2.
    CLEAR ws_fcat.
    ENDFORM. " build_fcat_plant
    \*& Form disp_alv_plant
    \* text
    \* \--> p1 text
    \* <-\- p2 text
    FORM disp_alv_plant.
    IF lp_cont2 IS INITIAL.
    \* Create the Container Object of Material Plant data.
    CREATE OBJECT lp_cont2
    EXPORTING
    container_name = c_cont2
    EXCEPTIONS
    cntl_error = 1
    cntl_system_error = 2
    create_error = 3
    lifetime_error = 4
    lifetime_dynpro_dynpro_link = 5
    others = 6.
    IF sy-subrc NE 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ELSE.
    \* Create the Object for Grid of Material Plant data.
    CREATE OBJECT lp_grid2
    EXPORTING
    i_parent = lp_cont2
    EXCEPTIONS
    error_cntl_create = 1
    error_cntl_init = 2
    error_cntl_link = 3
    error_dp_create = 4
    others = 5.
    IF sy-subrc NE 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ELSE.
    \* Dipslay Material Plant data by calling method.
    CALL METHOD lp_grid2->set_table_for_first_display
    CHANGING
    it_outtab = i_marc
    it_fieldcatalog = i_fcat2
    EXCEPTIONS
    invalid_parameter_combination = 1
    program_error = 2
    too_many_lines = 3
    OTHERS = 4.
    IF sy-subrc NE 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    ENDIF.
    ENDIF.
    ELSE.
    \* Call method 'REFRESH_TABLE_DISPLAY' to refresh the grid data.
    CALL METHOD lp_grid2->refresh_table_display.
    ENDIF.
    ENDFORM. " disp_alv_plant
    Thanks
    Vasudha

  • Page number in ALV report

    Hi all,
    I use top of page to print page number for ALV report. When i run my report in backgrond and see the spool, the page is always started from page 2.
    These does not happen when I use non-ALV report, report prints the header starting from page 1 normally. It is weird.
    does anyone of you ever face such of that problem ?
    thanks alots
    Alia

    Hi Alia,
    Page number is usually not set in an ALV display, as compared to  List processing.
    r u sure this is a requirement?
    chk this:
    ALV Print page numbers
    Regards,
    Anjali

  • Alv report using oops ABAP

    hi friendz,
    can any one of u give an example, how to build alv report using oops abap ?
    thanks in advance.
    points for sure
    regards,
    Vijaya

    Hi Vijaya,
    I hope the following code upto your requirement.
    *& Report  ZMAT_ALV_GRID                                               *
    REPORT  ZCL_CLASS1.
    TYPES: BEGIN OF T_MARA,
             MATNR TYPE MARA-MATNR,
             MAKTX TYPE MAKT-MAKTX,
             WERKS TYPE MARD-WERKS,
             LGORT TYPE MARD-LGORT,
             LABST TYPE MARD-LABST,
           END OF T_MARA.
    *DATA: IT_MARA TYPE STANDARD TABLE OF T_MARA.
    DATA: IT_MARA TYPE T_MARA OCCURS 0.
    DATA: O_CONT TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
          O_GRID TYPE REF TO CL_GUI_ALV_GRID.
    DATA: X_FLDCAT TYPE LVC_S_FCAT.
    DATA: IT_FLDCAT TYPE LVC_T_FCAT.
    DATA: I_LAYOUT TYPE LVC_S_LAYO.
    DATA: X_SORT TYPE LVC_S_SORT.
    DATA: I_SORT TYPE LVC_T_SORT.
    TABLES: MARA.
    SELECT-OPTIONS: S_MATNR FOR MARA-MATNR.
    PARAMETERS: P_CHK AS CHECKBOX.
    START-OF-SELECTION.
      PERFORM GET_DATA.
      PERFORM GENERATE_FLDCAT.
      PERFORM GENERATE_LAYOUT.
      PERFORM DO_SORT.
      SET SCREEN 100.
    *&      Module  STATUS_0100  OUTPUT
          text
    MODULE STATUS_0100 OUTPUT.
       SET PF-STATUS 'MAIN'.
    SET TITLEBAR 'xxx'.
       PERFORM BUILD_ALV.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
          text
    MODULE USER_COMMAND_0100 INPUT.
      CASE SY-UCOMM.
        WHEN 'BACK'.
          LEAVE PROGRAM.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Form  BUILD_ALV
          text
    FORM BUILD_ALV .
    CREATE OBJECT O_CONT
       EXPORTING
          CONTAINER_NAME              = 'MAT_CONTAINER'
       EXCEPTIONS
         CNTL_ERROR                  = 1
         CNTL_SYSTEM_ERROR           = 2
         CREATE_ERROR                = 3
         LIFETIME_ERROR              = 4
         LIFETIME_DYNPRO_DYNPRO_LINK = 5
         others                      = 6.
         CREATE OBJECT O_GRID
           EXPORTING
              I_PARENT          = O_CONT
           EXCEPTIONS
             ERROR_CNTL_CREATE = 1
             ERROR_CNTL_INIT   = 2
             ERROR_CNTL_LINK   = 3
             ERROR_DP_CREATE   = 4
             others            = 5.
    CALL METHOD O_GRID->SET_TABLE_FOR_FIRST_DISPLAY
       EXPORTING
       I_BUFFER_ACTIVE               =
       I_BYPASSING_BUFFER            =
       I_CONSISTENCY_CHECK           =
       I_STRUCTURE_NAME              =
       IS_VARIANT                    =
       I_SAVE                        =
       I_DEFAULT                     = ' '
         IS_LAYOUT                     = I_LAYOUT
       IS_PRINT                      =
       IT_SPECIAL_GROUPS             =
       IT_TOOLBAR_EXCLUDING          =
       IT_HYPERLINK                  =
       IT_ALV_GRAPHICS               =
       IT_EXCEPT_QINFO               =
       CHANGING
         IT_OUTTAB                     = IT_MARA
         IT_FIELDCATALOG               = IT_FLDCAT[]
         IT_SORT                       = I_SORT
       IT_FILTER                     =
      EXCEPTIONS
        INVALID_PARAMETER_COMBINATION = 1
        PROGRAM_ERROR                 = 2
        TOO_MANY_LINES                = 3
        others                        = 4.
    ENDFORM.                    " BUILD_ALV
    *&      Form  GET_DATA
          text
    FORM GET_DATA .
    SELECT A~MATNR
          B~MAKTX
          C~WERKS
          C~LGORT
          C~LABST
    INTO TABLE IT_MARA
    FROM MARA AS A
    INNER JOIN MAKT AS B
    ON BMATNR = AMATNR
    INNER JOIN MARD AS C
    ON CMATNR = AMATNR
    WHERE A~MATNR IN S_MATNR
    AND   B~SPRAS = SY-LANGU.
    ENDFORM.                    " GET_DATA
    *&      Form  GENERATE_FLDCAT
          text
    FORM GENERATE_FLDCAT .
    *CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
      EXPORTING
      I_BUFFER_ACTIVE              =
       I_STRUCTURE_NAME             = 'ZSMARA'
      I_CLIENT_NEVER_DISPLAY       = 'X'
      I_BYPASSING_BUFFER           =
      I_INTERNAL_TABNAME           = ' '
    CHANGING
       CT_FIELDCAT                  = IT_FLDCAT
    EXCEPTIONS
      INCONSISTENT_INTERFACE       = 1
      PROGRAM_ERROR                = 2
      OTHERS                       = 3.
    X_FLDCAT-COL_POS = 1.
    X_FLDCAT-FIELDNAME = 'MATNR'.
    X_FLDCAT-OUTPUTLEN = '18'.
    X_FLDCAT-REPTEXT = 'Material No'.
    APPEND X_FLDCAT TO IT_FLDCAT.
    X_FLDCAT-COL_POS = 2.
    X_FLDCAT-FIELDNAME = 'MAKTX'.
    X_FLDCAT-OUTPUTLEN = '48'.
    X_FLDCAT-REPTEXT = 'Material Desc'.
    X_FLDCAT-TOOLTIP = 'Material Desc'.
    APPEND X_FLDCAT TO IT_FLDCAT.
    X_FLDCAT-COL_POS = 3.
    X_FLDCAT-FIELDNAME = 'WERKS'.
    X_FLDCAT-OUTPUTLEN = '5'.
    X_FLDCAT-REPTEXT = 'Plant'.
    X_FLDCAT-TOOLTIP = 'Plant'.
    APPEND X_FLDCAT TO IT_FLDCAT.
    X_FLDCAT-COL_POS = 4.
    X_FLDCAT-FIELDNAME = 'LGORT'.
    X_FLDCAT-OUTPUTLEN = '5'.
    X_FLDCAT-REPTEXT = 'S.Loc'.
    X_FLDCAT-TOOLTIP = 'S.Loc'.
    APPEND X_FLDCAT TO IT_FLDCAT.
    X_FLDCAT-COL_POS = 5.
    X_FLDCAT-FIELDNAME = 'LABST'.
    X_FLDCAT-OUTPUTLEN = '20'.
    X_FLDCAT-REPTEXT = 'Quantity'.
    X_FLDCAT-TOOLTIP = 'Quantity'.
    X_FLDCAT-DO_SUM = 'X'.
    APPEND X_FLDCAT TO IT_FLDCAT.
    ENDFORM.                    " GENERATE_FLDCAT
    *&      Form  GENERATE_LAYOUT
          text
    FORM GENERATE_LAYOUT .
      I_LAYOUT-ZEBRA = 'X'.
      I_LAYOUT-FRONTEND = 'X'.
      I_LAYOUT-GRID_TITLE = 'ALV GRID USING OOPS'.
      I_LAYOUT-NUMC_TOTAL = 'X'.
    ENDFORM.                    " GENERATE_LAYOUT
    *&      Form  DO_SORT
          text
    FORM DO_SORT .
    X_SORT-FIELDNAME = 'MATNR'.
    X_SORT-UP = 'X'.
    X_SORT-SUBTOT = 'X'.
    IF P_CHK = 'X'.
       X_SORT-EXPA = SPACE.
    ELSE.
       X_SORT-EXPA = 'X'.
    ENDIF.
    APPEND X_SORT TO I_SORT.
    ENDFORM.                    " DO_SORT
    inorder to execute this code perfectly, do the following things.
    1. Create a Graphical Screen 100.
    2. Place a Custom Control on that screen and give name as MAT_CONTAINER.
    3. activate the screen.
    and execute the program.
      if this suits requirement award points.
    satish

  • ALV Reports using Class Methods

    Hi Experts,
    How can we generate ALV report using class and in that How can we define SLIS_EVENTS.
    Can I provide all the that functionality the way I used to by calling FM
    SLIS_ALV_REUSE_LIST_DISPLAY  ?
    - Like Header comment, event, data grouping , sort etc.
    You may please send any url or document or any example.
    Thanks in advance.
    Regards,
    Tushar Choksi

    Hi,
    The ALV object Grid methods allow the same functionality as ALV grid report function modules but are displayed within
    a screen (dialog program). SAP has provided a suit of programs which demonstrate how to For examples see standard SAP
    programs as detailed below:
    BCALV_EDIT_01 This report illustrates the simplest case of using an editable/noneditable ALV Grid Control.
    BCALV_EDIT_02 This report illustrates how to set chosen cells of an ALV Grid Control editable.
    BCALV_EDIT_03 In this example the user may change values of fields SEATSOCC (occupied seats) and/or PLANETYPE.
    The report checks the input value(s) semantically and provides protocol messages in case of error
    BCALV_EDIT_04 This report illustrates how to add and remove lines to a table using the ALV Grid Control and how to
    implement the saving of the new data.
    BCALV_EDIT_05 This example shows how to use checkboxes within an ALV Grid Control. You learn:
    (1) how to define a column for editable checkboxes for an attribute of your list
    (2) how to evaluate the checked checkboxes
    (3) how to switch between editable and non-editable checkboxes
    BCALV_EDIT_06 This example shows how to define a dropdown listbox for all cells of one column in an editable ALV
    Grid Control.
    BCALV_EDIT_07 This example shows how to define dropdown listboxes for particular cells of your output table.
    BCALV_EDIT_08 This report implements an ALV Grid Control with an application specific F4 help. The following aspects
    are dealt with:
    (1) how to replace the standard f4 help
    (2) how to pass the selected value to the ALV Grid Control
    (3) how to build an f4 help, whose value range depend on a value of another cell.
    some links.
    www.sapgenie.com
    www.abap4u.com
    http://help.sap.com/saphelp_nw2004s/helpdata/en/5e/88d440e14f8431e10000000a1550b0/frameset.htm
    download the PDF from following link.
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCSRVALV/BCSRVALV.pdf
    Regards,
    Satish

Maybe you are looking for

  • Problem with auvaltool Logic Pro 9 and Nexus2

    This is the message im getting the report from and no idea why or whats caused it. Anyone with suggestions. Still waiting for reply from refx. Process:         Logic Pro [2261] Path:            /Applications/Logic Pro.app/Contents/MacOS/Logic Pro Ide

  • OK_CODE of Double Click Event

    Hi all, I have created one module pool ... Now when i check OK_CODE of double click event ( By debugging /H ) ,its showing SV. So is this Fix? means all program having same OK_CODE for double click because in my second module pool also it showing SV

  • Recording on I Mac

    Hoe kan ik zelf een instrument (baritonsax in mijn geval) opnemen in Garageband. Moet je dan een microfoon aansluiten of wat? Ries van Dorst

  • OCI.DLL error

    My application install Oracle OLEDB and instant Client 11g, with "ODAC 11.2 Release 5 (11.2.0.3.20) with Xcopy Deployment" the connection work well in hundred of installations, except : On a single machine and only on it, with Win7 32 bit I have a pa

  • ISync (v2.3) with Siemens S56

    My phone is on the supported devices list, and I know I've used it with iSync in the past, with older computers and versions of iSync, but now I can't get it to work with the current version of iSync on my iMac. When I select "Add Device..." in iSync