Application Development and Automation 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: 
Read only

Alv GRID

Former Member
0 Likes
880

In the alv grid display how to display the end of list contents .

Example; my internal table is processing 100 entries of inter nal table out of which 20 are in error.

this info is to be displayed at the end of list.

like total processed 100

successful records 80

incorrect 20

how do i do that?

if possible and example program please.

Thanks in Advance.

In the alv grid display how to display the end of list contents .

Example; my internal table is processing 100 entries of inter nal table out of which 20 are in error.

this info is to be displayed at the end of list.

like total processed 100

successful records 80

incorrect 20

how do i do that?

if possible and example program please.

Thanks in Advance.

7 REPLIES 7
Read only

Former Member
0 Likes
809

You can do this in ALV "end-of-list" or "END-OF-PAGE" event.Fill the ALV event table with these events and in the subroutine "end-of-list" you can write your code

Read only

Former Member
0 Likes
809

hi anitha,

Instead of doing that you cango like this

message S001(ZE) with v_success 'successful records out of' v_totalrecords.

v_success --> variable to store no of successful records

v_totalrecords --> variable to store total no of records

Message was edited by: Chandrasekhar Jagarlamudi

Read only

Former Member
0 Likes
809

Hi,

I think u have to go for ALV list display.

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'

EXPORTING

i_callback_program = v_repid.

*Display Records.

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'

EXPORTING

is_layout = layout

it_fieldcat = t_fieldcat

i_tabname = 'T_MP_BIW'

it_events = t_event1

TABLES

t_outtab = t_mp_biw

EXCEPTIONS

program_error = 1

maximum_of_appends_reached = 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.

  • Display Error Records

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'

EXPORTING

is_layout = layout1

it_fieldcat = t_fieldcat1

i_tabname = 'T_ERROR'

it_events = t_event

TABLES

t_outtab = t_error

EXCEPTIONS

program_error = 1

maximum_of_appends_reached = 2

OTHERS = 3.

  • Display

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'.

Regrds

Divakar

Read only

Former Member
0 Likes
809

then you can use END_OF_LIST event of ALV. as you are using GRID display, to display the text at the end of the report,we cant just use WRITE statement(as we do in LIST DIPSLAY),instead you have to call 'REUSE_ALV_COMMENTARY_WRITE' function module and pass all the text to be displayed to this FM.

it will be displayed automatically at runtime.

check this code,

1. i am populating ALV EVENTS to the IT_EVENTS internal table.

2. for END OF LIST event i am populating the FORM name

3. i defined the FORM FOOTER and added my code there.

4. i given IT_EVENTS internal table name to the GRID DISPLAY function module.

*&---------------------------------------------------------------------*
*&      Form  SET_EVENTS
*&---------------------------------------------------------------------*
*       text : Assign form names to the Events
*----------------------------------------------------------------------*
FORM SET_EVENTS .

  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.

*--Text To be displayed at TOP OF LIST
 <b> CLEAR WA_EVENT.
  READ TABLE IT_EVENTS INTO WA_EVENT WITH KEY NAME = 'END_OF_LIST'.  <--this event will be triggered at the end of the list output.
  WA_EVENT-FORM = 'FOOTER'.</b> <--this FORM will be called at runtime.we should create a FORM with this name and what ever we want to display at the end of the list we have to write them here.
  MODIFY IT_EVENTS FROM WA_EVENT INDEX SY-TABIX.

ENDFORM.                    " SET_EVENTS

*&---------------------------------------------------------------------*
*&      Form  FOOTER
*&---------------------------------------------------------------------*
*       text :Text to be displyed at the END OF LIST
*----------------------------------------------------------------------*
FORM FOOTER .
*-- Standard end of report
WRITE YOUR brief footer here.
<b>
YOU should use 'REUSE_ALV_COMMENTARY_WRITE' function module to display the text as FOOTER in the GRID display.In LIST display,you can use WRITE to display the same.
  data: t_header type slis_t_listheader,
        wa_header type slis_listheader.
 wa_header-typ  = 'A'.
  wa_header-info = 'END OF REPORT'.
  append wa_header to t_header.
  clear: wa_header.
  call function 'REUSE_ALV_COMMENTARY_WRITE'
       exporting
       it_list_commentary = t_header.
*       i_logo             = 'GANESH_LOGO'.</b>
ENDFORM.                    " FOOTER

and finally you should pass this EVENTS internal table to the GRID Function module.here i used LIST display,but even you can use the same to GRID also.

 CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
       EXPORTING
            I_CALLBACK_PROGRAM = V_REPID
            IS_LAYOUT          = WA_LAYOUT
            IT_FIELDCAT        = IT_FIELDCAT[]
            IT_SORT            = IT_SORT[]
<b>            IT_EVENTS          = IT_EVENTS[]</b>
       TABLES
            T_OUTTAB           = IT_MLGT[]
       EXCEPTIONS
            PROGRAM_ERROR      = 1
            OTHERS             = 2.

Regards,

Srikanth

Message was edited by: Srikanth Kidambi

Read only

dani_mn
Active Contributor
0 Likes
809

HI,

instead of using 'REUSE_ALV_GRID_DISPLAY' use

'RESUE_ALV_LIST_DISPLAY'

It will work perfectly for your requirment.

check the sample program.

REPORT ZWA_ALV_EDITABLE_FM .

type-pools: slis.

data it_fieldcat type slis_fieldcat_alv occurs 0 with header line.
data: gs_layout type slis_layout_alv.
data: it_events type SLIS_T_EVENT.
data: wa_event like line of it_events.
data v_repid like sy-repid.

DATA: BEGIN OF itab OCCURS 0.
        INCLUDE STRUCTURE CSKT.
DATA: end of itab.


START-OF-SELECTION.

  v_repid = sy-repid.

*--- selection form cost center master table

  SELECT * FROM CSKT
  INTO TABLE itab.

  PERFORM field_catalog.
  PERFORM set_events.

  SET PF-STATUS 'ZBC'.

  call function 'REUSE_ALV_LIST_DISPLAY'
       EXPORTING
            i_callback_program      = v_repid
            i_callback_user_command = 'USER_COMMAND'
            it_fieldcat             = it_fieldcat[]
            it_events               = it_events[]
            is_layout               = gs_layout
            I_SAVE                  = 'X'
       TABLES
            t_outtab                = itab.


*&---------------------------------------------------------------------*
*&      Form  field_catalog
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM field_catalog.

  call function 'REUSE_ALV_FIELDCATALOG_MERGE'
       EXPORTING
            i_program_name     = v_repid
            i_internal_tabname = 'ITAB'
            i_inclname         = v_repid
       CHANGING
            ct_fieldcat        = it_fieldcat[].


ENDFORM.                 
*---------------------------------------------------------------------*
*       FORM SET_EVENTS                                               *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM SET_EVENTS .

  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.

*--Text To be displayed at TOP OF LIST
  CLEAR WA_EVENT.
<b>  READ TABLE IT_EVENTS INTO WA_EVENT WITH KEY NAME = 'END_OF_LIST'.</b>
<b>  WA_EVENT-FORM = 'FOOTER'.</b>
  MODIFY IT_EVENTS FROM WA_EVENT INDEX SY-TABIX.
ENDFORM. 

*---------------------------------------------------------------------*
*       FORM FOOTER                                                   *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM FOOTER .
*-- Standard end of report

<b>write:/ 'THIS IS FOOTER AT END OF LIST'.</b>

ENDFORM. 

regards,

Read only

Former Member
0 Likes
809

If you are using OO ALV, and not the function module 'REUSE_ALV_GRID_DISPLAY', you can splid down your container, and use the event END_OF_LIST to do this.

Alexandre

Read only

Former Member
0 Likes
809

Thank you very much.