Monday, August 23, 2010

Interactive ALV report

Sample code for Interactive ALV reports( Fetch records from VBAK, on clicking any output record, navigate to Sales Doc Tcode)


*&---------------------------------------------------------------------*
*&      Form  ALV_DISPLAY
*&---------------------------------------------------------------------*
FORM alv_display .

  PERFORM build_fieldcatalog.

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_bypassing_buffer      = 'X'
      i_callback_program       = sy-repid
      i_callback_user_command = 'USER_COMMAND'
*      i_grid_title            = 'Interactive ALV'
      it_fieldcat             = i_fieldcatalog[]
      is_layout               = w_layout
      it_sort                 = i_sort
      i_default               = 'X'
      i_save                  = 'A'
      is_variant              = w_variant
      it_events               = i_grid_event
    TABLES
      t_outtab                = i_vbak[]
    EXCEPTIONS
      program_error           = 1
      OTHERS                  = 2.
ENDFORM.                    " ALV_DISPLAY
*&---------------------------------------------------------------------*
*&      Form  USER_COMMAND
*&---------------------------------------------------------------------*
FORM user_command USING u_com LIKE sy-ucomm sel_field TYPE slis_selfield.

*  CLEAR fcat1.
  DATA: t_doc TYPE vbeln.
  CLEAR: w_vbak.
  CASE u_com.
    WHEN '&IC1'.
      READ TABLE i_vbak INTO w_vbak INDEX sel_field-tabindex.
      IF sy-subrc = 0.
        t_doc = w_vbak-vbeln.
        SET PARAMETER ID 'AUN' FIELD t_doc.
        CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.
      ENDIF.
  ENDCASE.
ENDFORM"user_command

1 comment:

  1. Here's a ALV report example to display sales header details and item details..

    http://learnabaponline.blogspot.in/2013/06/interactive-alv-report.html

    Thanks!

    ReplyDelete