Reuse_alv_grid_diaplay

i am not able to get the correct  report output. i cannot go back from this screen nor the regular sort options some up on the screen. can anyone let me know what is wrong with the code. Thanks in advance.
REPORT  ZSAMPLEALV                              .
TYPE-POOLS: SLIS.
TABLES: LFA1.
DATA: Begin of itab occurs 0,
        lifnr like lfa1-lifnr,
        name1 like lfa1-name1,
      end of itab.
DATA: alv_fieldcat TYPE slis_t_fieldcat_alv,
        alv_layout   TYPE slis_layout_alv,
        fcat_wa TYPE slis_fieldcat_alv,
        col_pos TYPE i,
        lt_alv_event     TYPE slis_alv_event,
        lt_alv_event_tab TYPE slis_t_event.
SELECT LIFNR NAME1 FROM LFA1 INTO TABLE ITAB.
  CLEAR: lt_alv_event.
  lt_alv_event-name = 'PF_STATUS_SET'.
  lt_alv_event-form = 'PF_STATUS_SET'.
  APPEND lt_alv_event TO lt_alv_event_tab.
  alv_layout-info_fieldname = 'LINECOLOR'.
  CLEAR: alv_fieldcat.
  REFRESH: alv_fieldcat.
  fcat_wa-key = 'X'.
  fcat_wa-col_pos = col_pos.
  fcat_wa-fieldname = 'LIFNR'.
  fcat_wa-ref_tabname = 'LFA1'.
  fcat_wa-ref_fieldname = 'LIFNR'.
  APPEND fcat_wa TO alv_fieldcat.
  CLEAR: fcat_wa.
  ADD 1 TO col_pos.
  fcat_wa-key = 'X'.
  fcat_wa-col_pos = col_pos.
  fcat_wa-fieldname = 'NAME1'.
  fcat_wa-ref_tabname = 'LFA1'.
  fcat_wa-ref_fieldname = 'NAME1'.
  APPEND fcat_wa TO alv_fieldcat.
  CLEAR: fcat_wa.
  ADD 1 TO col_pos.
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
   I_CALLBACK_PROGRAM                = 'ZSAMPLEALV'
   IS_LAYOUT                         = alv_layout
   IT_FIELDCAT                       = ALV_FIELDCAT
   IT_EVENTS                         = lt_alv_event_tab
   i_save                            = 'A'
  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.

Deepali,
Take a look at the below code. Hope this will be helpful.
DATA:
  gs_layout   TYPE slis_layout_alv,
  gs_fieldcat TYPE slis_fieldcat_alv.
DATA:
  gt_fieldcat_fir     TYPE slis_t_fieldcat_alv,
  gt_events           TYPE slis_t_event,
    PERFORM prepare_alv.
*&      Form  prepare_alv
      text
-->  p1        text
<--  p2        text
FORM prepare_alv.
Field Cat
  PERFORM alv_get_field_cat TABLES gt_fieldcat_fir
                            USING 'GT_FIRF'.
Events
  PERFORM alv_eventtab_build USING gt_events[].
Layout
  PERFORM alv_build_layout CHANGING gs_layout.
ENDFORM.                    " prepare_alv
*&      Form  alv_get_field_cat
      text
-->  p1        text
<--  p2        text
FORM alv_get_field_cat
                 TABLES pt_fieldcat TYPE slis_t_fieldcat_alv
                 USING pv_itab_name TYPE slis_tabname.
  DATA ls_fieldcat TYPE slis_fieldcat_alv.
  CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
       EXPORTING
            i_program_name         = gv_reort_id
            i_internal_tabname     = pv_itab_name
            i_inclname             = gv_reort_id
            i_bypassing_buffer     = 'X'
       CHANGING
            ct_fieldcat            = pt_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.
  LOOP AT pt_fieldcat INTO ls_fieldcat.
    ls_fieldcat-seltext_l =  ls_fieldcat-seltext_m   =
    ls_fieldcat-seltext_s = ls_fieldcat-reptext_ddic =
    ls_fieldcat-fieldname.
    MODIFY pt_fieldcat FROM ls_fieldcat.
  ENDLOOP.
ENDFORM.                    " alv_get_field_cat
*&      Form  alv_eventtab_build
      text
     -->P_GT_EVENTS[]  text
FORM alv_eventtab_build USING lt_events TYPE slis_t_event.
  DATA: ls_event TYPE slis_alv_event.
  CONSTANTS:
    lc_top_of_page   TYPE slis_formname VALUE 'TOP_OF_PAGE',
    lc_pf_status_set TYPE slis_formname VALUE 'PF_STATUS_SET',
    lc_user_command  TYPE slis_formname VALUE 'USER_COMMAND'.
  CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
       EXPORTING
            i_list_type = 0
       IMPORTING
            et_events   = lt_events.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.
  LOOP AT lt_events INTO ls_event.
    CASE ls_event-name.
      WHEN lc_top_of_page.
        MOVE lc_top_of_page TO ls_event-form.
        MODIFY lt_events FROM ls_event.
      WHEN lc_pf_status_set.
        MOVE lc_pf_status_set TO ls_event-form.
        MODIFY lt_events FROM ls_event.
      WHEN lc_user_command.
        MOVE lc_user_command TO ls_event-form.
        MODIFY lt_events FROM ls_event.
    ENDCASE.
  ENDLOOP.
ENDFORM.                    " alv_eventtab_build
*&      Form  alv_build_layout
      text
     <--P_GS_LAYOUT  text
FORM alv_build_layout CHANGING ls_layout LIKE gs_layout.
  ls_layout-no_vline          = ' '.
  ls_layout-reprep            = 'X'.
  ls_layout-detail_popup      = 'X'.
  ls_layout-window_titlebar   = text-a00.
  ls_layout-no_scrolling      = ' '.
  ls_layout-detail_titlebar   = text-a01.
  ls_layout-colwidth_optimize = 'X'.
ENDFORM.                    " alv_build_layout
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
            i_callback_program     = gv_reort_id
            is_layout              = gs_layout
            it_fieldcat            = gt_fieldcat_fir[]
            i_save                 = 'A'
            it_events              = gt_events[]
       IMPORTING
            es_exit_caused_by_user = ps_exit_caused_by_user
       TABLES
            t_outtab               = gt_firf
       EXCEPTIONS
            program_error          = 1
            OTHERS                 = 2.
Good luck.

Similar Messages

  • It_event_exit  in REUSE_ALV_GRID_DIAPLAY

    Hi,
    I am trying to change the PRINT functionality of REUSE_ALV_GRID_DISPLAY. I am using 'it_event_exit' to capture print button press action in User_Command..
    My problem is that after my work is done, it is still triggering the standard SAP print functionality. I want to stop the standard code from triggering.

    my work is that I am calling my own Smartform in the user command.
    I am using this code for populating IT_EVENT_EXIT
    is_event_exit-ucomm = '&RNT'.
    is_event_exit-before = 'X'.
    APPEND is_event_exit TO it_event_exit.
    So when pressing the print button in the ALV the user_command form is getting triggered. there i am call my own smartform. Till here it is ok. but after this the standard sap print window is getting displayed.
    I just dont want to show this standard print screen.
    any help would be appreciated...
    Edited by: Sukriti Saha on Oct 15, 2008 7:29 AM

  • HIDE in ALV Reports

    hi friends,
    could any one of u clear about -- how to HIDE the content of basic list (ALV) after an event occured.
    in function module <b>REUSE_ALV_GRID_DIAPLAY</b> there is a parameter <b>is_hide</b>  what is the use of this parameter.
    expecting reply.
    jai.

    hi ravi,
    let me Rephrase my qtn,
    in normal report after write statement we use HIDE command
    like
    loop at itab.
    write : itab.
    hide : itab.
    endloop.
    how can we Achieve the same in ALV reports.
    jai.

Maybe you are looking for