Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to place a push button on ALV Grid output

Former Member
0 Kudos

Can anyone help me in placing a push button on ALV grid Output

4 REPLIES 4

Former Member
0 Kudos

Refer the following code:

*&---------------------------------------------------------------------*
*& Report  Z_82235_ALV_OOPS_PUSTBUTTON                                 *
*&                                                                     *
*&---------------------------------------------------------------------*
*&                                                                     *
*&                                                                     *
*&---------------------------------------------------------------------*

report  z_82235_alv_oops_pustbutton             .

tables: mara.

types: begin of t_mara,
         matnr type matnr,
         mtart type mtart,
         matkl type matkl,
         meins type meins,
       end of t_mara.

data: gt_mara type standard table of t_mara,
      gs_mara like line of gt_mara.

class lcl_event_receiver definition deferred.

*-- Global Data defenation for ALV

*---Alv Grid instance referance
data : gr_alvgrid type ref to cl_gui_alv_grid,
       event_receiver type ref to lcl_event_receiver.

*---Name of the custom control added on the screen
data gc_custom_control_name type scrfname value 'CC_ALV'
.
*---Custom container instance referance
data: gr_ccontainer type ref to cl_gui_custom_container.

*---Field catalog table
data: gt_fieldcat type lvc_t_fcat,
      gs_fieldcat type lvc_s_fcat.

*---Layout structure
data: gs_layout type lvc_s_layo.

data: g_repid like sy-repid.

select matnr
       mtart
       matkl
       meins
       from mara into table gt_mara
       up to 25 rows.

g_repid = sy-repid.


include <icon>.
*********
* Predefine a local class for event handling to allow the
* declaration of a reference variable before the class is defined.


*
*********

* Set initial dynpro
set screen 100.

****************************************************************
* LOCAL CLASSES: Definition
****************************************************************
*===============================================================
* class lcl_event_receiver: local class to
*                         define and handle own functions.
*
* Definition:
* ~~~~~~~~~~~
class lcl_event_receiver definition.

  public section.

    methods:
    handle_toolbar
        for event toolbar of cl_gui_alv_grid
            importing e_object e_interactive,

    handle_user_command
        for event user_command of cl_gui_alv_grid
            importing e_ucomm.

  private section.

endclass.
*
* lcl_event_receiver (Definition)
*===============================================================

****************************************************************
* LOCAL CLASSES: Implementation
****************************************************************
*===============================================================
* class lcl_event_receiver (Implementation)
*
*
class lcl_event_receiver implementation.

  method handle_toolbar.
* § 2.In event handler method for event TOOLBAR: Append own functions
*   by using event parameter E_OBJECT.
    data: ls_toolbar  type stb_button.
*....................................................................
* E_OBJECT of event TOOLBAR is of type REF TO CL_ALV_EVENT_TOOLBAR_SET.
* This class has got one attribute, namly MT_TOOLBAR, which
* is a table of type TTB_BUTTON. One line of this table is
* defined by the Structure STB_BUTTON (see data deklaration above).
*

* A remark to the flag E_INTERACTIVE:
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*         'e_interactive' is set, if this event is raised due to
*         the call of 'set_toolbar_interactive' by the user.
*         You can distinguish this way if the event was raised
*         by yourself or by ALV
*         (e.g. in method 'refresh_table_display').
*         An application of this feature is still unknown... :-)

* append a separator to normal toolbar
    clear ls_toolbar.
    move 3 to ls_toolbar-butn_type.
    append ls_toolbar to e_object->mt_toolbar.
* append an icon to download
    clear ls_toolbar.
    ls_toolbar-function = 'DOWN'.
    ls_toolbar-icon = 'icon_generate'.
    ls_toolbar-quickinfo = 'DOWNLOAD FILE'.
    ls_toolbar-text = 'DOWNLOAD FILE'.

*    MOVE ' ' TO ls_toolbar-disabled.
    append ls_toolbar to e_object->mt_toolbar.

  endmethod.
*-------------------------------------------------------------------
  method handle_user_command.
* § 3.In event handler method for event USER_COMMAND: Query your
*   function codes defined in step 2 and react accordingly.

    data: lt_rows type lvc_t_row.

    case e_ucomm.
      when 'DOWN'.

      call function 'GUI_DOWNLOAD'
        exporting
*         BIN_FILESIZE                  =
          filename                      = 'D:a.txt'
*         FILETYPE                      = 'ASC'
*         APPEND                        = ' '
*         WRITE_FIELD_SEPARATOR         = ' '
*         HEADER                        = '00'
        tables
          data_tab                      = gt_mara
       exceptions
         file_write_error              = 1
         no_batch                      = 2
         gui_refuse_filetransfer       = 3
         invalid_type                  = 4
         no_authority                  = 5
         unknown_error                 = 6
         header_not_allowed            = 7
         separator_not_allowed         = 8
         filesize_not_allowed          = 9
         header_too_long               = 10
         dp_error_create               = 11
         dp_error_send                 = 12
         dp_error_write                = 13
         unknown_dp_error              = 14
         access_denied                 = 15
         dp_out_of_memory              = 16
         disk_full                     = 17
         dp_timeout                    = 18
         file_not_found                = 19
         dataprovider_exception        = 20
         control_flush_error           = 21
         others                        = 22
                .
      if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      endif.




   endcase.
  endmethod.                           "handle_user_command
*-----------------------------------------------------------------
endclass.
*
* lcl_event_receiver (Implementation)
*===================================================================





*--------------------------------------------------------------------
* S T A R T - O F - S E L E C T I O N.
*--------------------------------------------------------------------
start-of-selection.
  set screen '100'.


*&---------------------------------------------------------------------*
*&      Module  display_alv  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module display_alv output.

  if gr_alvgrid is initial.

*---Creating custom container instance
    create object gr_ccontainer
      exporting
        container_name              = gc_custom_control_name
      exceptions
        cntl_error                  = 1
        cntl_system_error           = 2
        create_error                = 3
        lifetime_error              = 4
        lifetime_dynpro_dynpro_link = 5
        others                      = 6
        .
    if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.


*---Creating ALV gris instance
    create object gr_alvgrid
      exporting
        i_parent          = gr_ccontainer
        i_appl_events     = 'X'
      exceptions
        error_cntl_create = 1
        error_cntl_init   = 2
        error_cntl_link   = 3
        error_dp_create   = 4
        others            = 5
        .
    if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.

*---Prepare field catalog
    perform prepare_field_catalog tables gt_fieldcat.

*---Prepare layout
    perform prepare_layout changing gs_layout.


*---Call ALV grid
    call method gr_alvgrid->set_table_for_first_display
      exporting
*    I_BUFFER_ACTIVE               =
*    I_BYPASSING_BUFFER            =
*    I_CONSISTENCY_CHECK           =
*    I_STRUCTURE_NAME              =
*    IS_VARIANT                    =
*    I_SAVE                        =
*    I_DEFAULT                     = 'X'
        is_layout                     = gs_layout
*    IS_PRINT                      =
*    IT_SPECIAL_GROUPS             =
*    IT_TOOLBAR_EXCLUDING          =
*    IT_HYPERLINK                  =
*    IT_ALV_GRAPHICS               =
*    IT_EXCEPT_QINFO               =
      changing
        it_outtab                     = gt_mara[]
        it_fieldcatalog               = gt_fieldcat
*    IT_SORT                       =
*    IT_FILTER                     =
      exceptions
        invalid_parameter_combination = 1
        program_error                 = 2
        too_many_lines                = 3
        others                        = 4
            .
    if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.




********
* ->Create Object to receive events and link them to handler methods.
* When the ALV Control raises the event for the specified instance
* the corresponding method is automatically called.
*
    create object event_receiver.
    set handler event_receiver->handle_user_command for gr_alvgrid.
    set handler event_receiver->handle_toolbar for gr_alvgrid.
*
********

* § 4.Call method 'set_toolbar_interactive' to raise event TOOLBAR.
    call method gr_alvgrid->set_toolbar_interactive.

*  endif.                               "IF grid1 IS INITIAL
*  call method cl_gui_control=>set_focus exporting control = gr_alvgrid.

*--- the instance is present
  else .

    call method gr_alvgrid->refresh_table_display
*      EXPORTING
*        IS_STABLE      =
*        I_SOFT_REFRESH =
      exceptions
        finished       = 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.

endmodule.                 " display_alv  OUTPUT

*&---------------------------------------------------------------------*
*&      Form  prepare_field_catalog
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      <--P_GT_FIELDCAT  text
*----------------------------------------------------------------------*
form prepare_field_catalog  tables gt_fieldcat.

  clear : gs_fieldcat.
  gs_fieldcat-fieldname = 'MATNR'.
  gs_fieldcat-col_pos   = 1.
  gs_fieldcat-emphasize = 'X'.
  gs_fieldcat-outputlen = 10.
  gs_fieldcat-coltext   = 'Material No'.
  gs_fieldcat-edit      = 'X'.
  append gs_fieldcat to gt_fieldcat.

  clear : gs_fieldcat.
  gs_fieldcat-fieldname = 'MTART'.
  gs_fieldcat-col_pos   = 2.
  gs_fieldcat-outputlen = 6.
  gs_fieldcat-coltext   = 'Material Type'.
  append gs_fieldcat to gt_fieldcat.

  clear : gs_fieldcat.
  gs_fieldcat-fieldname = 'MATKL'.
  gs_fieldcat-col_pos   = 3.
  gs_fieldcat-outputlen = 5.
  gs_fieldcat-coltext   = 'Material Grp'.
  append gs_fieldcat to gt_fieldcat.


  clear : gs_fieldcat.
  gs_fieldcat-fieldname = 'MEINS'.
  gs_fieldcat-col_pos   = 4.
  gs_fieldcat-outputlen = 4.
  gs_fieldcat-coltext   = 'Unit'.
  append gs_fieldcat to gt_fieldcat.





endform.                    " prepare_field_catalog

*&---------------------------------------------------------------------*
*&      Form  prepare_layout
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      <--P_GS_LAYOUT  text
*----------------------------------------------------------------------*
form prepare_layout  changing p_gs_layout type lvc_s_layo.

  p_gs_layout-zebra = 'X'.
  p_gs_layout-grid_title = 'Material'.
  p_gs_layout-smalltitle = 'X'.


endform.                    " prepare_layout
*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module status_0100 output.
  set pf-status 'STATUS1'.
*  SET TITLEBAR 'xxx'.

endmodule.                 " STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module user_command_0100 input.

  case sy-ucomm.

    when 'BACK' or 'UP' or 'CANCEL'.
      leave program.

        when '&DETAIL'.
      leave program.

  endcase.


endmodule.                 " USER_COMMAND_0100  INPUT

0 Kudos

Thanks Abishiek......I want the same for ALV using function module method not oops ALV..... Can you pls help me in that

former_member5472
Active Contributor
0 Kudos

Hi abhishek,

You can add a push button using following steps:

1. Add push button in the tool bar

2.Trigger subroutine when push button is clicked

3. execute the code


CLASS cl_event_receiver DEFINITION.
 PUBLIC SECTION.
    DATA: ucomm TYPE sy-ucomm.
*   toolbar
 METHODS handle_toolbar_set
      FOR EVENT toolbar OF cl_gui_alv_grid
      IMPORTING e_object e_interactive.
*   user command
METHODS handle_user_command
      FOR EVENT user_command OF cl_gui_alv_grid
      IMPORTING e_ucomm.

CLASS cl_event_receiver IMPLEMENTATION.
METHOD handle_user_command.
    CASE e_ucomm.
      WHEN text-024.
        PERFORM upload_id.
      WHEN OTHERS.
    ENDCASE.
  ENDMETHOD.     
METHOD handle_toolbar_set.
* append a separator to normal toolbar
    CLEAR ls_toolbar.
    MOVE 3 TO ls_toolbar-butn_type.
    APPEND ls_toolbar TO e_object->mt_toolbar.
CLEAR ls_toolbar.
    MOVE :text-032 TO ls_toolbar-function, 
*" function code of the push button

          text-033 TO ls_toolbar-text.
*"text that will be displayed on the push button
    APPEND ls_toolbar    TO e_object->mt_toolbar.
ENDMETHOD. 
ENDCLASS. 
*set even handlers
 SET HANDLER event_receiver1->handle_toolbar_set  FOR g_grid1.
  SET HANDLER event_receiver1->handle_user_command FOR g_grid1.

please award points if helpful

thanks

pratyush

prasanth_kasturi
Active Contributor
0 Kudos

hi,

double click on the status and write DISPLAY when you use the code as status cannot be copied

i highlited in the program for your refrence

&----


*& Report ZP_ALV10

*&

&----


*&

*&

&----


REPORT ZP_ALV10.

TYPE-POOLS : slis.

TABLES: kna1,vbak.

TYPES : BEGIN OF ty_kna1 ,

kunnr LIKE kna1-kunnr,

name1 LIKE kna1-name1,

land1 LIKE kna1-land1,

checkbox type checkbox,

END OF ty_kna1.

TYPES : BEGIN OF ty_vbak,

vbeln LIKE vbak-vbeln,

erdat LIKE vbak-erdat,

ernam LIKE vbak-ernam,

netwr LIKE vbak-netwr,

END OF ty_vbak.

DATA: it_kna1 TYPE TABLE OF ty_kna1,

wa_kna1 TYPE ty_kna1,

it_vbak TYPE TABLE OF ty_vbak,

wa_vbak TYPE ty_vbak.

DATA : it_fieldcat TYPE slis_t_fieldcat_alv,

wa_fieldcat TYPE slis_fieldcat_alv,

wa_layout TYPE slis_layout_alv ,

wa_layout1 TYPE slis_layout_alv .

DATA : it_events TYPE slis_t_event ,

wa_events TYPE slis_alv_event,

it_events_vbak TYPE slis_t_event ,

wa_events_vbak TYPE slis_alv_event.

DATA : it_listheader TYPE slis_t_listheader,

wa_listheader TYPE slis_listheader,

it_sort TYPE slis_t_sortinfo_alv,

wa_sort TYPE slis_sortinfo_alv.

DATA: i_title_kna1 TYPE lvc_title VALUE 'FIRST LIST DISPLAYED',

i_title_vbak TYPE lvc_title VALUE 'SECOND LIST DISPLAYED'.

SELECT-OPTIONS : s_kunnr FOR kna1-kunnr DEFAULT 1000 TO 1100.

INITIALIZATION.

PERFORM getevents.

PERFORM desinlayout.

PERFORM populateevents.

PERFORM desinfieldcat.

START-OF-SELECTION.

PERFORM datafetching.

PERFORM display.

&----


*& Form desinfieldcat

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM desinfieldcat .

  • wa_fieldcat-row_pos = 1.

wa_fieldcat-col_pos = 2.

wa_fieldcat-fieldname = 'KUNNR'.

wa_fieldcat-seltext_l = 'Cust Num'.

wa_fieldcat-datatype = 'CHAR'.

wa_fieldcat-outputlen = 10.

wa_fieldcat-tabname = 'IT_KNA1'.

wa_fieldcat-key = 'X'.

wa_fieldcat-key = 'X'.

wa_fieldcat-hotspot = 'X'.

  • wa_fieldcat-icon = 'X'.

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

  • wa_fieldcat-row_pos = 2.

wa_fieldcat-col_pos = 3.

wa_fieldcat-fieldname = 'NAME1'.

wa_fieldcat-seltext_l = 'Name'.

wa_fieldcat-datatype = 'CHAR'.

wa_fieldcat-outputlen = 35.

wa_fieldcat-tabname = 'IT_KNA1'.

  • wa_fieldcat-emphasize = 'C110'.

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

  • wa_fieldcat-row_pos = 3.

wa_fieldcat-col_pos = 4.

wa_fieldcat-fieldname = 'LAND1'.

wa_fieldcat-seltext_l = 'Country'.

wa_fieldcat-datatype = 'CHAR'.

wa_fieldcat-outputlen = 10.

wa_fieldcat-tabname = 'IT_KNA1'.

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

*

wa_fieldcat-col_pos = 1 .

wa_fieldcat-fieldname = 'CHECKBOX'.

wa_fieldcat-seltext_l = 'Choose'.

wa_fieldcat-datatype = 'CHAR'.

wa_fieldcat-outputlen = 10.

wa_fieldcat-tabname = 'IT_KNA1'.

wa_fieldcat-checkbox = 'X'.

wa_fieldcat-input = 'X'.

wa_fieldcat-key = 'X'.

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

ENDFORM. " desinfieldcat

&----


*& Form datafetching

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM datafetching .

SELECT kunnr name1 land1

FROM kna1

INTO TABLE it_kna1

WHERE kunnr IN s_kunnr.

  • up to 30 rows.

ENDFORM. " datafetching

&----


*& Form display

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM display .

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = sy-repid

i_callback_pf_status_set = 'PF_STATUS_SET'

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

  • I_GRID_SETTINGS =

is_layout = wa_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_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

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

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

&----


*& Form desinlayout

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM desinlayout .

wa_layout-zebra = 'X'.

wa_layout-colwidth_optimize = 'X'.

wa_layout-edit = 'X'.

  • wa_layout-box_fieldname = 'CHOOSE'.

  • wa_layout-box_tabname = 'IT_KNA1'.

  • wa_layout-box_rollname = 'CHECKBOX'.

wa_layout-Get_selinfos = 'X'.

ENDFORM. " desinlayout

&----


*& Form getevents

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM getevents .

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

  • EXPORTING

  • I_LIST_TYPE = 0

IMPORTING

et_events = it_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. " getevents

&----


*& Form populateevents

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM populateevents .

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

wa_events-form = 'TOP_OF_PAGE'.

MODIFY it_events FROM wa_events TRANSPORTING form WHERE name = wa_events-name.

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

wa_events-form = 'USER_COMMAND'.

MODIFY it_events FROM wa_events TRANSPORTING form WHERE name = wa_events-name.

READ TABLE it_events INTO wa_events WITH KEY name = 'PF_STATUS_SET'.

wa_events-form = 'PF_STATUS_SET'.

MODIFY it_events FROM wa_events TRANSPORTING form WHERE name = wa_events-name.

endform.

&----


*& Form top-of-page

&----


  • text

----


FORM top_of_page.

wa_listheader-typ = 'H'.

wa_listheader-info = 'Customer Details'.

APPEND wa_listheader TO it_listheader.

CLEAR wa_listheader.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = it_listheader

i_logo = 'ENJOYSAP_LOGO'

  • I_END_OF_LIST_GRID =

  • I_ALV_FORM =

.

REFRESH it_listheader.

ENDFORM. "top-of-page

&----


*& Form user_command

&----


  • text

----


FORM user_command

USING u_comm TYPE sy-ucomm

r_selfield TYPE slis_selfield.

CASE u_comm.

WHEN 'DISPLAY'.

if r_selfield-value = '1'.

read table it_kna1 into wa_kna1 index r_selfield-tabindex.

SELECT vbeln erdat ernam netwr

FROM vbak

INTO CORRESPONDING FIELDS OF TABLE it_vbak

WHERE kunnr = wa_kna1-kunnr.

PERFORM fieldcat_vbak.

PERFORM desinlayout1.

PERFORM getevents_vbak.

PERFORM populateevents_vbak.

PERFORM sort.

PERFORM display_vbak.

endif.

ENDCASE.

ENDFORM. "user_command

&----


*& Form fieldcat_vbak

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM fieldcat_vbak .

REFRESH it_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-col_pos = 1.

wa_fieldcat-fieldname = 'VBELN'.

wa_fieldcat-seltext_l = 'SALES DOCU'.

wa_fieldcat-datatype = 'CHAR'.

wa_fieldcat-outputlen = 10.

wa_fieldcat-tabname = 'IT_VBAK'.

wa_fieldcat-key = 'X'.

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-col_pos = 2.

wa_fieldcat-fieldname = 'ERDAT'.

wa_fieldcat-seltext_l = 'DATE'.

wa_fieldcat-datatype = 'DATS'.

wa_fieldcat-outputlen = 10.

wa_fieldcat-tabname = 'IT_VBAK'.

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-col_pos = 3.

wa_fieldcat-fieldname = 'ERNAM'.

wa_fieldcat-seltext_l = 'NAME'.

wa_fieldcat-datatype = 'CHAR'.

wa_fieldcat-outputlen = 10.

wa_fieldcat-tabname = 'IT_VBAK'.

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-col_pos = 4.

wa_fieldcat-fieldname = 'NETWR'.

wa_fieldcat-seltext_l = 'VALUE'.

wa_fieldcat-datatype = 'CURR'.

wa_fieldcat-outputlen = 10.

wa_fieldcat-tabname = 'IT_VBAK'.

wa_fieldcat-do_sum = 'X'.

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

ENDFORM. " fieldcat_vbak

&----


*& Form display_vbak

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM display_vbak .

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = sy-repid

  • I_CALLBACK_PF_STATUS_SET = ' '

  • i_callback_user_command = 'USER_COMMAND'

i_callback_top_of_page = 'TOP-OF-PAGE_VBAK'

  • I_CALLBACK_HTML_TOP_OF_PAGE = ''

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

i_grid_title = i_title_vbak

  • I_GRID_SETTINGS =

is_layout = wa_layout1

it_fieldcat = it_fieldcat

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

it_sort = it_sort

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

it_events = it_events_vbak

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

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_vbak

*&----


**& Form pf_status_set

*&----


    • text

*----


    • --> p1 text

    • <-- p2 text

*----


FORM pf_status_set USING rt_extab TYPE slis_t_extab.

SET PF-STATUS 'STATUS'.

ENDFORM. " pf_status_set

&----


*& Form sort

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM sort .

wa_sort-fieldname = 'NETWR'.

wa_sort-tabname = 'IT_VBAK'.

wa_sort-subtot = 'X'.

APPEND wa_sort TO it_sort.

CLEAR wa_sort.

ENDFORM. " sort

&----


*& Form getevents_vbak

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM getevents_vbak .

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

  • EXPORTING

  • I_LIST_TYPE = 0

IMPORTING

et_events = it_events_vbak

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

&----


*& Form populateevents_vbak

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM populateevents_vbak .

READ TABLE it_events_vbak INTO wa_events_vbak WITH KEY name = 'TOP_OF_PAGE'.

wa_events_vbak-form = 'TOP_OF_PAGE_VBAK'.

MODIFY it_events_vbak FROM wa_events_vbak TRANSPORTING form WHERE name = wa_events_vbak-name.

READ TABLE it_events_vbak INTO wa_events_vbak WITH KEY name = 'SUBTOTAL_TEXT'.

wa_events-form = 'SUBTOTAL_TEXT'.

MODIFY it_events_vbak FROM wa_events_vbak TRANSPORTING form WHERE name = wa_events_vbak-name.

ENDFORM. " populateevents_vbak

&----


*& Form top_of_page_vbak

&----


  • text

----


FORM top_of_page_vbak.

wa_listheader-typ = 'H'.

wa_listheader-info = 'Customer Details'.

APPEND wa_listheader TO it_listheader.

CLEAR wa_listheader.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = it_listheader

i_logo = 'EDSLOGO'

  • I_END_OF_LIST_GRID =

  • I_ALV_FORM =

.

REFRESH it_listheader.

ENDFORM. "top_of_page_vbak

&----


*& Form SUBTOTAL_TEXT

&----


  • text

----


FORM subtotal_text .

WRITE : 'Subtotal'.

ENDFORM. "SUBTOTAL_TEXT

&----


*& Form desinlayout1

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM desinlayout1 .

wa_layout1-zebra = 'X'.

wa_layout1-colwidth_optimize = 'X'.

wa_layout1-totals_text = 'GRANDTOTAL'.

wa_layout1-subtotals_text = 'SUB TOTAL'.

ENDFORM. " desinlayout1

if any prob revert me back

regards

prasanth