Skip to Content
author's profile photo Former Member
Former Member

'REUSE _ALV_COMMENTRY_WRITE'

Hi,

Can anybody explain me the use of

'REUSE ALVCOMMENTRY_WRITE' FUCTION

with an example.

thanks

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

8 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Mar 20, 2008 at 12:24 PM

    Hi,

    That function module is used to print the Heading(Top of page) on ALV list.

    Regards,

    Kumar.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 20, 2008 at 12:25 PM

    HI,

    Its used to display the logo and header.

    FORM top_of_page.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
    *     i_logo             = <<If you want to set a logo, please,
    *                          uncomment and edit this line>>
          it_list_commentary = t_heading.
    ENDFORM.                    " alv_top_of_page

    Regards,

    S.Nehru

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 20, 2008 at 12:26 PM

    Hi,

    It will print your company logo in the header of the report.

    Thanks & Regards,

    Harsha.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 20, 2008 at 12:29 PM

    hi,

    it is use to make header and footer into ALV...

    here is the example

    
    TYPE-POOLS : slis.
    
    TABLES : mara,
             makt,
             marc.
    
    DATA : BEGIN OF itab OCCURS 0,
            matnr LIKE mara-matnr,
            maktx LIKE makt-maktx,
            werks LIKE marc-werks,
           END OF itab.
    
    DATA : t_fcat TYPE slis_t_fieldcat_alv,
           t_eve TYPE slis_t_event,
           st_line TYPE slis_listheader,
           t_list_top_page TYPE slis_t_listheader,
           t_list_end_page TYPE slis_t_listheader.
    
    DATA : t_mat LIKE mara-matnr.
    
    SELECTION-SCREEN : BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS : mat FOR mara-matnr.
    SELECTION-SCREEN : END OF BLOCK blk1.
    
    INITIALIZATION.
    
      PERFORM build_cat USING t_fcat.
      PERFORM build_eve.
    
    
    START-OF-SELECTION.
      PERFORM get_data.
      PERFORM build_header USING t_list_top_page[].
      PERFORM build_footer USING t_list_end_page[].
      PERFORM dis_data.
    
    *&---------------------------------------------------------------------*
    *&      Form  buils_cat
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *      -->TEMP_FCAT  text
    *----------------------------------------------------------------------*
    FORM build_cat USING temp_fcat TYPE slis_t_fieldcat_alv.
    
      DATA : wa_fcat TYPE slis_fieldcat_alv.
    
      wa_fcat-tabname = 'ITAB'.
      wa_fcat-fieldname = 'MATNR'.
      wa_fcat-seltext_m = 'Material'.
      APPEND wa_fcat TO temp_fcat.
      CLEAR wa_fcat.
    
      wa_fcat-tabname = 'ITAB'.
      wa_fcat-fieldname = 'MAKTX'.
      wa_fcat-seltext_m = 'Material Description'.
      APPEND wa_fcat TO temp_fcat.
      CLEAR wa_fcat.
    
      wa_fcat-tabname = 'ITAB'.
      wa_fcat-fieldname = 'WERKS'.
      wa_fcat-seltext_m = 'Plant'.
    *  wa_fcat-row_pos = 2.
      APPEND wa_fcat TO temp_fcat.
      CLEAR wa_fcat.
    
    ENDFORM.                    "build_cat
    
    *&---------------------------------------------------------------------*
    *&      Form  build_eve
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    FORM build_eve.
    
      DATA : wa_eve TYPE slis_alv_event.
    
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
       EXPORTING
         i_list_type           = 0
       IMPORTING
         et_events             = t_eve
    * 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 t_eve INTO wa_eve WITH KEY name = 'END_OF_LIST'.
      IF sy-subrc = 0.
        wa_eve-form = 'END_OF_PAGE'.
        MODIFY t_eve FROM wa_eve INDEX sy-tabix.
      ENDIF.
    
    ENDFORM.                    "build_eve
    
    *&---------------------------------------------------------------------*
    *&      Form  get_data
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    FORM get_data.
    
      SELECT mara~matnr makt~maktx marc~werks INTO CORRESPONDING FIELDS OF TABLE itab
      FROM mara INNER JOIN makt ON
      mara~matnr = makt~matnr
      INNER JOIN marc ON
      mara~matnr = marc~matnr
      WHERE mara~matnr IN mat.
    
    ENDFORM.                    "get_data
    
    *&---------------------------------------------------------------------*
    *&      Form  dis_data
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    FORM dis_data.
    
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
         i_callback_program                = 'ZALV_PRDS'
         i_callback_top_of_page            = 'TOP_OF_PAGE'
         it_fieldcat                       = t_fcat
         i_save                            = 'A'
         it_events                         = t_eve
       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.
    
    
    ENDFORM.                    "dis_data
    
    *&---------------------------------------------------------------------*
    *&      Form  build_header
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *      -->TEMP_LIST          text
    *      -->TTYPE              text
    *      -->SLIS_T_LISTHEADER  text
    *----------------------------------------------------------------------*
    FORM build_header USING temp_list TYPE slis_t_listheader.
    
    
      CLEAR st_line.
      st_line-typ = 'H'.
      st_line-info = 'Material Info'.
      APPEND st_line TO temp_list.
    
      CLEAR st_line.
    
    
    ENDFORM.                    "build_header
    
    *&---------------------------------------------------------------------*
    *&      Form  build_footer
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *      -->TEMP_LIST  text
    *----------------------------------------------------------------------*
    FORM build_footer USING temp_list TYPE slis_t_listheader.
    
      CLEAR st_line.
      st_line-typ = 'H'.
      st_line-info = 'Dhwani Shah'.
      APPEND st_line TO temp_list.
    
    ENDFORM.                    "build_header
    
    *&---------------------------------------------------------------------*
    *&      Form  top_Of_page
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    FORM top_of_page.
    
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary = t_list_top_page.
    
    ENDFORM.                    "top_Of_page
    
    *&---------------------------------------------------------------------*
    *&      Form  end_of_page
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    FORM end_of_page.
    
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary = t_list_end_page.
    
    ENDFORM.                    "end_of_page
    
    
    

    reward if usefull....

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 20, 2008 at 12:30 PM

    hi check this prog...

    REPORT ZTEST_ALV123.

    TABLES VBAK.

    TYPE-POOLS SLIS.

    TYPES: BEGIN OF T_VBAK,

    VBELN TYPE VBAK-VBELN,

    ERDAT TYPE VBAK-ERDAT,

    ERNAM TYPE VBAK-ERNAM,

    AUDAT TYPE VBAK-AUDAT,

    VBTYP TYPE VBAK-VBTYP,

    NETWR TYPE VBAK-NETWR,

    VKORG TYPE VBAK-VKORG,

    VKGRP TYPE VBAK-VKGRP,

    END OF T_VBAK.

    DATA IT_VBAK TYPE STANDARD TABLE OF T_VBAK INITIAL SIZE 0.

    DATA: FLDCAT TYPE SLIS_T_FIELDCAT_ALV,

    W_FLDCAT TYPE SLIS_FIELDCAT_ALV,

    GD_LAYOUT TYPE SLIS_LAYOUT_ALV,

    GD_REPID TYPE SY-REPID.

    START-OF-SELECTION.

    PERFORM DATA_RETRIEVAL.

    PERFORM BLD_FLDCAT.

    PERFORM BLD_LAYOUT.

    PERFORM DISPLAY_ALV_REPORT.

    FORM BLD_FLDCAT.

    W_FLDCAT-FIELDNAME = 'VBELN'.

    W_FLDCAT-SELTEXT_M = 'Sales Document'.

    W_FLDCAT-COL_POS = 0.

    *W_FLDCAT-EMPHASIZE = 'C411'.

    W_FLDCAT-OUTPUTLEN = 20.

    W_FLDCAT-KEY = 'X'.

    W_FLDCAT-ICON = 'X'.

    APPEND W_FLDCAT TO FLDCAT.

    CLEAR W_FLDCAT.

    W_FLDCAT-FIELDNAME = 'ERDAT'.

    W_FLDCAT-SELTEXT_L = 'Record Date created'.

    W_FLDCAT-COL_POS = 1.

    W_FLDCAT-KEY = 'X'.

    APPEND W_FLDCAT TO FLDCAT.

    CLEAR W_FLDCAT.

    W_FLDCAT-FIELDNAME = 'ERNAM'.

    W_FLDCAT-SELTEXT_L = 'Cteated Object Person Name'.

    APPEND W_FLDCAT TO FLDCAT.

    CLEAR W_FLDCAT.

    W_FLDCAT-FIELDNAME = 'AUDAT'.

    W_FLDCAT-SELTEXT_M = 'Document Date'.

    W_FLDCAT-COL_POS = 3.

    W_FLDCAT-EMPHASIZE = 'C110'.

    APPEND W_FLDCAT TO FLDCAT.

    CLEAR W_FLDCAT.

    W_FLDCAT-FIELDNAME = 'VBTYP'.

    W_FLDCAT-SELTEXT_L = 'SD Document category'.

    W_FLDCAT-COL_POS = 4.

    APPEND W_FLDCAT TO FLDCAT.

    CLEAR W_FLDCAT.

    W_FLDCAT-FIELDNAME = 'NETWR'.

    W_FLDCAT-SELTEXT_L = 'Net Value of the SO in Document Currency'.

    W_FLDCAT-COL_POS = 5.

    W_FLDCAT-OUTPUTLEN = 60.

    W_FLDCAT-DO_SUM = 'X'.

    W_FLDCAT-DATATYPE = 'CURR'.

    APPEND W_FLDCAT TO FLDCAT.

    CLEAR W_FLDCAT.

    W_FLDCAT-FIELDNAME = 'VKORG'.

    W_FLDCAT-SELTEXT_L = 'Sales Organization'.

    W_FLDCAT-COL_POS = 6.

    APPEND W_FLDCAT TO FLDCAT.

    CLEAR W_FLDCAT.

    W_FLDCAT-FIELDNAME = 'VKGRP'.

    W_FLDCAT-SELTEXT_M = 'Sales Group'.

    W_FLDCAT-COL_POS = 7.

    W_FLDCAT-EMPHASIZE = 'C801'.

    APPEND W_FLDCAT TO FLDCAT.

    CLEAR W_FLDCAT.

    ENDFORM.

    FORM BLD_LAYOUT.

    GD_LAYOUT-NO_INPUT = 'X'.

    GD_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.

    GD_LAYOUT-BOX_FIELDNAME = 'VBELN'.

    ENDFORM.

    FORM DISPLAY_ALV_REPORT.

    GD_REPID = SY-REPID.

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    I_CALLBACK_PROGRAM = GD_REPID

    IS_LAYOUT = GD_LAYOUT

    I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'

    IT_FIELDCAT = FLDCAT[]

    I_SAVE = 'X'

    I_GRID_TITLE = 'WELCOME TO ALV'

    TABLES

    T_OUTTAB = IT_VBAK

    EXCEPTIONS

    PROGRAM_ERROR = 1

    OTHERS = 2.

    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.

    ENDFORM.

    FORM DATA_RETRIEVAL.

    SELECT VBELN ERDAT ERNAM AUDAT VBTYP NETWR VKORG

    UP TO 50 ROWS

    FROM VBAK

    INTO TABLE IT_VBAK.

    ENDFORM.

    FORM TOP_OF_PAGE.

    DATA: T_HEADER TYPE SLIS_T_LISTHEADER,

    W_HEADER TYPE SLIS_LISTHEADER.

    W_HEADER-TYP = 'H'.

    W_HEADER-INFO = 'WELCOME HEADER LIST'.

    APPEND W_HEADER TO T_HEADER.

    W_HEADER-TYP = 'S'.

    W_HEADER-KEY = 'REPORT:'.

    W_HEADER-INFO = SY-REPID.

    APPEND W_HEADER TO T_HEADER.

    W_HEADER-TYP = 'S'.

    W_HEADER-KEY = 'DATE:'.

    CONCATENATE SY-DATUM4(2) ' / ' SY-DATUM6(2) ' / ' SY-DATUM(4) INTO W_HEADER-INFO.

    APPEND W_HEADER TO T_HEADER.

    CLEAR W_HEADER.

    W_HEADER-TYP = 'S'.

    W_HEADER-KEY = 'Page No:'.

    W_HEADER-INFO = SY-PAGNO.

    APPEND W_HEADER TO T_HEADER.

    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

    EXPORTING

    IT_LIST_COMMENTARY = T_HEADER.

    ENDFORM.

    regards,

    venkat.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 20, 2008 at 12:32 PM

    hi

    The Fm "REUSE_ALV_COMMENTARY_WRITE"

    IS USED FOR

    This is used in the Top-of-page event to print the headings and other comments for the list.

    1. It_list_commentary : Internal table with the headings of the type slis_t_listheader.

    This internal table has three fields:

    Typ : ‘H’ - header, ‘S’ - selection, ‘A’ - action

    Key : only when typ is ‘S’.

    Info : the text to be printed

    EXAMPLE IS

    program for hierarchial list display WITH top of page event

    report balvhd01 no standard page heading.

    • ALV

    type-pools: slis.

    • DB-Table

    tables: scarr, spfli.

    • Includes

    include .

    *

    constants:

    gc_formname_top_of_page type slis_formname value 'TOP_OF_PAGE'.

    data: gt_fieldcat type slis_t_fieldcat_alv,

    gs_layout type slis_layout_alv,

    gs_keyinfo type slis_keyinfo_alv,

    gt_sp_group type slis_t_sp_group_alv,

    gt_events type slis_t_event.

    • Data to be displayed

    data: begin of gt_spfli occurs 0.

    include structure spfli.

    data:

    box,

    wert(4) type p,

    lights.

    data: end of gt_spfli.

    data: begin of gt_scarr occurs 0.

    include structure scarr.

    data: box,

    lights.

    data: end of gt_scarr.

    *

    data: g_repid like sy-repid.

    data: gt_list_top_of_page type slis_t_listheader.

    • Report Selections

    select-options carrid for scarr-carrid.

    selection-screen skip 1.

    • Parameters

    parameters: p_maxrow type i default 50.

    selection-screen skip 1.

    • Variante

    selection-screen begin of block 0 with frame title text-064.

    parameters: p_vari like disvariant-variant.

    selection-screen end of block 0.

    • Layout

    selection-screen begin of block a with frame title text-060.

    parameters:

    p_zebra as checkbox default ' ',

    p_nocolh as checkbox default ' ',

    p_colopt as checkbox default ' ',

    p_keyhot as checkbox default ' ',

    p_noinpt as checkbox default ' '.

    selection-screen end of block a.

    selection-screen begin of block b with frame title text-061.

    parameters:

    p_lightn radiobutton group lig ,

    p_lighth radiobutton group lig ,

    p_lighti radiobutton group lig ,

    p_lightc as checkbox default ' '.

    selection-screen end of block b.

    selection-screen begin of block c with frame title text-062.

    parameters:

    p_totonl as checkbox default ' ',

    p_totext(60),

    p_sttext(60).

    selection-screen end of block c.

    selection-screen begin of block d with frame title text-063.

    parameters:

    chckboxn radiobutton group box ,

    chckboxh radiobutton group box ,

    chckboxi radiobutton group box ,

    • P_GROUPB AS CHECKBOX DEFAULT ' ',

    p_detpop as checkbox default 'X',

    p_groups as checkbox default ' '.

    selection-screen end of block d.

    data: g_boxnam type slis_fieldname value 'BOX',

    p_f2code like sy-ucomm value '&ETA',

    p_lignam type slis_fieldname value 'LIGHTS',

    g_save(1) type c,

    g_tabname_header type slis_tabname,

    g_tabname_item type slis_tabname,

    g_default(1) type c,

    g_exit(1) type c,

    gx_variant like disvariant,

    g_variant like disvariant.

    *----


    *

    initialization.

    g_repid = sy-repid.

    g_tabname_header = 'GT_SCARR'.

    g_tabname_item = 'GT_SPFLI'.

    • define keyinfo

    clear gs_keyinfo.

    gs_keyinfo-header01 = 'CARRID'.

    gs_keyinfo-item01 = 'CARRID'.

    gs_keyinfo-header02 = space.

    gs_keyinfo-item02 = 'CONNID'.

    *

    perform e01_fieldcat_init using gt_fieldcat[].

    perform e03_eventtab_build using gt_events[].

    perform e04_comment_build using gt_list_top_of_page[].

    perform e07_sp_group_build using gt_sp_group[].

    • Schalter Varianten benutzerspezifisch/allgemein speicherbar setzen

    • Set Options: save variants userspecific or general

    g_save = 'A'.

    perform variant_init.

    • Get default variant

    gx_variant = g_variant.

    call function 'REUSE_ALV_VARIANT_DEFAULT_GET'

    exporting

    i_save = g_save

    changing

    cs_variant = gx_variant

    exceptions

    not_found = 2.

    if sy-subrc = 0.

    p_vari = gx_variant-variant.

    endif.

    • Process on value request

    at selection-screen on value-request for p_vari.

    perform f4_for_variant.

    • PAI

    at selection-screen.

    perform pai_of_selection_screen.

    start-of-selection.

    perform selection.

    end-of-selection.

    perform e05_layout_build using gs_layout. "wg. Parameters

    • Call ABAP/4 List Viewer

    call function 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'

    exporting

    i_callback_program = g_repid

    • I_CALLBACK_PF_STATUS_SET = ' '

    • I_CALLBACK_USER_COMMAND = ' '

    is_layout = gs_layout

    it_fieldcat = gt_fieldcat[]

    • IT_EXCLUDING =

    it_special_groups = gt_sp_group[]

    • IT_SORT =

    • IT_FILTER =

    • IS_SEL_HIDE =

    • I_SCREEN_START_COLUMN = 0

    • I_SCREEN_START_LINE = 0

    • I_SCREEN_END_COLUMN = 0

    • I_SCREEN_END_LINE = 0

    • i_default = g_default

    i_save = g_save

    is_variant = g_variant

    it_events = gt_events[]

    • IT_EVENT_EXIT =

    i_tabname_header = g_tabname_header

    i_tabname_item = g_tabname_item

    is_keyinfo = gs_keyinfo

    • IS_PRINT =

    • IMPORTING

    • E_EXIT_CAUSED_BY_CALLER =

    tables

    t_outtab_header = gt_scarr

    t_outtab_item = gt_spfli.

    *----


    *

    • FORM E01_FIELDCAT_INIT *

    *----


    *

    • ........ *

    *----


    *

    • --> E01_LT_FIELDCAT *

    *----


    *

    form e01_fieldcat_init using e01_lt_fieldcat type slis_t_fieldcat_alv.

    data: ls_fieldcat type slis_fieldcat_alv.

    *

    clear ls_fieldcat.

    ls_fieldcat-fieldname = 'DISTANCE'.

    ls_fieldcat-tabname = g_tabname_item.

    ls_fieldcat-no_out = 'X'.

    ls_fieldcat-no_sum = 'X'.

    ls_fieldcat-sp_group = 'A'.

    append ls_fieldcat to e01_lt_fieldcat.

    *

    clear ls_fieldcat.

    ls_fieldcat-fieldname = 'DISTID'.

    ls_fieldcat-tabname = g_tabname_item.

    ls_fieldcat-no_out = 'X'.

    ls_fieldcat-no_sum = 'X'.

    ls_fieldcat-sp_group = 'A'.

    append ls_fieldcat to e01_lt_fieldcat.

    *

    clear ls_fieldcat.

    ls_fieldcat-fieldname = 'CARRID'.

    ls_fieldcat-tabname = g_tabname_item.

    ls_fieldcat-tech = 'X'.

    append ls_fieldcat to e01_lt_fieldcat.

    *

    clear ls_fieldcat.

    ls_fieldcat-fieldname = 'FLTYPE'.

    ls_fieldcat-tabname = g_tabname_item.

    ls_fieldcat-no_out = 'X'.

    append ls_fieldcat to e01_lt_fieldcat.

    *

    call function 'REUSE_ALV_FIELDCATALOG_MERGE'

    exporting

    • I_PROGRAM_NAME =

    i_internal_tabname = g_tabname_header

    i_structure_name = 'SCARR'

    • I_CLIENT_NEVER_DISPLAY = 'X'

    changing

    ct_fieldcat = e01_lt_fieldcat[].

    call function 'REUSE_ALV_FIELDCATALOG_MERGE'

    exporting

    • I_PROGRAM_NAME =

    i_internal_tabname = g_tabname_item

    i_structure_name = 'SPFLI'

    • I_CLIENT_NEVER_DISPLAY = 'X'

    changing

    ct_fieldcat = e01_lt_fieldcat[].

    • Nachbessern!!!

    • CLEAR LS_FIELDCAT.

    • LS_FIELDCAT-FIELDNAME = 'CARRID'.

    • LS_FIELDCAT-TABNAME = G_TABNAME_HEADER.

    • LS_FIELDCAT-REF_FIELDNAME = 'CARRID'.

    • LS_FIELDCAT-REF_TABNAME = 'SCARR'.

    • LS_FIELDCAT-KEY = 'X'.

    • APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.

    • geht am Anfang nicht !!!!

    clear ls_fieldcat.

    ls_fieldcat-col_pos = 99.

    ls_fieldcat-fieldname = 'WERT'.

    ls_fieldcat-tabname = g_tabname_item.

    ls_fieldcat-reptext_ddic = 'Wert'(070).

    ls_fieldcat-outputlen = 4.

    ls_fieldcat-datatype = 'CURR'.

    append ls_fieldcat to e01_lt_fieldcat.

    endform.

    *----


    *

    • FORM E02_DATA_ADD *

    *----


    *

    • ........ *

    *----


    *

    form e02_data_add tables e02_lt_spfli structure gt_spfli

    e02_lt_scarr structure gt_scarr.

    loop at e02_lt_spfli.

    if sy-tabix > 10.

    e02_lt_spfli-box = 'X'.

    e02_lt_spfli-lights = '3'.

    else.

    if sy-tabix = 1.

    e02_lt_spfli-lights = '2'.

    else.

    e02_lt_spfli-lights = '1'.

    endif.

    endif.

    e02_lt_spfli-wert = sy-tabix mod 5.

    modify e02_lt_spfli.

    endloop.

    *

    loop at e02_lt_scarr.

    if sy-tabix > 10.

    e02_lt_scarr-box = 'X'.

    e02_lt_scarr-lights = '3'.

    else.

    if sy-tabix = 1.

    e02_lt_scarr-lights = '2'.

    else.

    e02_lt_scarr-lights = '1'.

    endif.

    endif.

    modify e02_lt_scarr.

    endloop.

    endform.

    *----


    *

    • FORM E03_EVENTTAB_BUILD *

    *----


    *

    • ........ *

    *----


    *

    • --> E03_LT_EVENTS *

    *----


    *

    form e03_eventtab_build using e03_lt_events type slis_t_event.

    data: ls_event type slis_alv_event.

    *

    call function 'REUSE_ALV_EVENTS_GET'

    exporting

    i_list_type = 0

    importing

    et_events = e03_lt_events.

    read table e03_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 e03_lt_events.

    endif.

    endform.

    *----


    *

    • FORM E04_COMMENT_BUILD *

    *----


    *

    • ........ *

    *----


    *

    • --> E04_LT_TOP_OF_PAGE *

    *----


    *

    form e04_comment_build using e04_lt_top_of_page type slis_t_listheader.

    data: ls_line type slis_listheader.

    *

    • Listenüberschrift: Typ H

    clear ls_line.

    ls_line-typ = 'H'.

    • LS_LINE-KEY: not used for this type

    ls_line-info = text-001.

    append ls_line to e04_lt_top_of_page.

    • Kopfinfo: Typ S

    clear ls_line.

    ls_line-typ = 'S'.

    ls_line-key = text-050.

    ls_line-info = text-010.

    append ls_line to e04_lt_top_of_page.

    ls_line-key = text-051.

    append ls_line to e04_lt_top_of_page.

    • Aktionsinfo: Typ A

    clear ls_line.

    ls_line-typ = 'A'.

    • LS_LINE-KEY: not used for this type

    ls_line-info = text-002.

    append ls_line to e04_lt_top_of_page.

    endform.

    *----


    *

    • FORM E05_LAYOUT_BUILD *

    *----


    *

    • ........ *

    *----


    *

    • <-> E05_LS_LAYOUT *

    *----


    *

    form e05_layout_build using e05_ls_layout type slis_layout_alv.

    if p_lighti = 'X'.

    e05_ls_layout-lights_fieldname = p_lignam.

    e05_ls_layout-lights_tabname = g_tabname_item.

    e05_ls_layout-lights_condense = p_lightc.

    endif.

    if p_lighth = 'X'.

    e05_ls_layout-lights_fieldname = p_lignam.

    e05_ls_layout-lights_tabname = g_tabname_header.

    e05_ls_layout-lights_condense = p_lightc.

    endif.

    if p_lightn = 'X'.

    clear e05_ls_layout-lights_fieldname.

    clear e05_ls_layout-lights_tabname.

    clear e05_ls_layout-lights_condense.

    endif.

    if chckboxn = 'X'.

    e05_ls_layout-box_fieldname = space.

    e05_ls_layout-box_tabname = space.

    endif.

    if chckboxh = 'X'.

    e05_ls_layout-box_fieldname = g_boxnam.

    e05_ls_layout-box_tabname = g_tabname_header.

    endif.

    if chckboxi = 'X'.

    e05_ls_layout-box_fieldname = g_boxnam.

    e05_ls_layout-box_tabname = g_tabname_item.

    endif.

    e05_ls_layout-header_text = text-071.

    e05_ls_layout-item_text = text-072.

    e05_ls_layout-default_item = 'X'.

    e05_ls_layout-f2code = p_f2code.

    e05_ls_layout-zebra = p_zebra.

    e05_ls_layout-colwidth_optimize = p_colopt.

    e05_ls_layout-no_input = p_noinpt.

    e05_ls_layout-no_colhead = p_nocolh.

    e05_ls_layout-totals_text = p_totext.

    e05_ls_layout-subtotals_text = p_sttext.

    e05_ls_layout-totals_only = p_totonl.

    e05_ls_layout-key_hotspot = p_keyhot.

    e05_ls_layout-detail_popup = p_detpop.

    e05_ls_layout-group_change_edit = p_groups.

    • E05_LS_LAYOUT-GROUP_BUTTONS = P_GROUPB.

    e05_ls_layout-group_buttons = space.

    endform.

    *----


    *

    • FORM E07_SP_GROUP_BUILD *

    *----


    *

    • ........ *

    *----


    *

    • --> E07_LT_SP_GROUP *

    *----


    *

    form e07_sp_group_build using e07_lt_sp_group type slis_t_sp_group_alv.

    data: ls_sp_group type slis_sp_group_alv.

    *

    clear ls_sp_group.

    ls_sp_group-sp_group = 'A'.

    ls_sp_group-text = text-005.

    append ls_sp_group to e07_lt_sp_group.

    endform.

    *----


    *

    • FORM SELECTION *

    *----


    *

    • ........ *

    *----


    *

    form selection.

    select * from scarr into corresponding fields of table gt_scarr

    where carrid in carrid.

    select * from spfli into corresponding fields of table gt_spfli

    up to p_maxrow rows

    where carrid in carrid.

    loop at gt_scarr.

    read table gt_spfli with key carrid = gt_scarr-carrid.

    if sy-subrc ne 0.

    delete gt_scarr.

    endif.

    endloop.

    *

    perform e02_data_add tables gt_spfli gt_scarr.

    endform.

    *----


    *

    • FORM TOP_OF_PAGE *

    *----


    *

    • ........ *

    *----


    *

    form top_of_page.

    *

    call function 'REUSE_ALV_COMMENTARY_WRITE'

    exporting

    it_list_commentary = gt_list_top_of_page.

    endform.

    *----


    *

    • FORM F4_FOR_VARIANT *

    *----


    *

    • ........ *

    *----


    *

    form f4_for_variant.

    *

    call function 'REUSE_ALV_VARIANT_F4'

    exporting

    is_variant = g_variant

    i_save = g_save

    i_tabname_header = g_tabname_header

    i_tabname_item = g_tabname_item

    • it_default_fieldcat =

    importing

    e_exit = g_exit

    es_variant = gx_variant

    exceptions

    not_found = 2.

    if sy-subrc = 2.

    message id sy-msgid type 'S' number sy-msgno

    with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

    else.

    if g_exit = space.

    p_vari = gx_variant-variant.

    endif.

    endif.

    endform.

    *&----


    *

    *& Form PAI_OF_SELECTION_SCREEN

    *&----


    *

    • text

    *----


    *

    form pai_of_selection_screen.

    *

    if not p_vari is initial.

    move g_variant to gx_variant.

    move p_vari to gx_variant-variant.

    call function 'REUSE_ALV_VARIANT_EXISTENCE'

    exporting

    i_save = g_save

    changing

    cs_variant = gx_variant.

    g_variant = gx_variant.

    else.

    perform variant_init.

    endif.

    endform. " PAI_OF_SELECTION_SCREEN

    *&----


    *

    *& Form VARIANT_INIT

    *&----


    *

    • text

    *----


    *

    • --> p1 text

    • <-- p2 text

    *----


    *

    form variant_init.

    *

    clear g_variant.

    g_variant-report = g_repid.

    endform. " VARIANT_INIT

    hope usefull to u, please remember to reward points

    Regards

    Fareedas

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 20, 2008 at 12:41 PM

    Hi,

    Using the function module ‘REUSE_ALV_COMMENTARY_WRITE’, the internal table containing the headings for top of page event can be passed to the list output. Also, any logo specific to the report can be passed to the function module.

    Regards,

    Bhaskar

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 20, 2008 at 12:43 PM

    Hi,

    This is to display the header data(text & logo) in ALV reports.

    Have a look on the following example,

    IT ALSO DISPLAYS THE LINE NUMBERS.

    TABLES VBAK.

    TYPE-POOLS SLIS.

    • Data Declaration

    TYPES: BEGIN OF T_VBAK,

    VBELN TYPE VBAK-VBELN,

    ERDAT TYPE VBAK-ERDAT,

    ERNAM TYPE VBAK-ERNAM,

    AUDAT TYPE VBAK-AUDAT,

    VBTYP TYPE VBAK-VBTYP,

    NETWR TYPE VBAK-NETWR,

    VKORG TYPE VBAK-VKORG,

    VKGRP TYPE VBAK-VKGRP,

    RN TYPE I,

    END OF T_VBAK.

    DATA IT_VBAK TYPE STANDARD TABLE OF T_VBAK INITIAL SIZE 0 WITH HEADER LINE.

    • ALV Data Declaration

    DATA: FLDCAT TYPE SLIS_T_FIELDCAT_ALV,

    W_FLDCAT TYPE SLIS_FIELDCAT_ALV,

    GD_LAYOUT TYPE SLIS_LAYOUT_ALV,

    GD_REPID TYPE SY-REPID.

    SELECT-OPTIONS: VBELN FOR VBAK-VBELN.

    START-OF-SELECTION.

    PERFORM DATA_RETRIEVAL.

    END-OF-SELECTION.

    PERFORM BLD_FLDCAT.

    PERFORM BLD_LAYOUT.

    PERFORM DISPLAY_ALV_REPORT.

    • Build Field Catalog for ALV Report

    FORM BLD_FLDCAT.

    W_FLDCAT-FIELDNAME = 'VBELN'.

    W_FLDCAT-SELTEXT_M = 'Sales_Document'.

    W_FLDCAT-COL_POS = 1.

    *W_FLDCAT-EMPHASIZE = 'C411'.

    *CXYZ: C=COLOR,X=COLOR NUMBER(1-9),Y=BOLD(0/1),Z=INVERSE(0/1)

    W_FLDCAT-OUTPUTLEN = 15.

    W_FLDCAT-KEY = 'X'.

    W_FLDCAT-ICON = 'X'.

    APPEND W_FLDCAT TO FLDCAT.

    CLEAR W_FLDCAT.

    W_FLDCAT-FIELDNAME = 'ERDAT'.

    W_FLDCAT-SELTEXT_L = 'Record_Date_created'.

    W_FLDCAT-COL_POS = 2.

    W_FLDCAT-KEY = 'X'.

    APPEND W_FLDCAT TO FLDCAT.

    CLEAR W_FLDCAT.

    W_FLDCAT-FIELDNAME = 'ERNAM'.

    W_FLDCAT-SELTEXT_L = 'Cteated_Person_Name'.

    W_FLDCAT-COL_POS = 3.

    W_FLDCAT-EMPHASIZE = 'C011'.

    APPEND W_FLDCAT TO FLDCAT.

    CLEAR W_FLDCAT.

    W_FLDCAT-FIELDNAME = 'AUDAT'.

    W_FLDCAT-SELTEXT_M = 'Document_Date'.

    W_FLDCAT-COL_POS = 4.

    W_FLDCAT-EMPHASIZE = 'C110'.

    APPEND W_FLDCAT TO FLDCAT.

    CLEAR W_FLDCAT.

    W_FLDCAT-FIELDNAME = 'VBTYP'.

    W_FLDCAT-SELTEXT_L = 'SDDocument_category'.

    W_FLDCAT-COL_POS = 5.

    APPEND W_FLDCAT TO FLDCAT.

    CLEAR W_FLDCAT.

    W_FLDCAT-FIELDNAME = 'NETWR'.

    W_FLDCAT-SELTEXT_L = 'Net_Value'.

    W_FLDCAT-COL_POS = 6.

    W_FLDCAT-OUTPUTLEN = 10.

    W_FLDCAT-DO_SUM = 'X'.

    W_FLDCAT-DATATYPE = 'CURR'.

    APPEND W_FLDCAT TO FLDCAT.

    CLEAR W_FLDCAT.

    W_FLDCAT-FIELDNAME = 'VKORG'.

    W_FLDCAT-SELTEXT_L = 'Sales_Organization'.

    W_FLDCAT-COL_POS = 7.

    APPEND W_FLDCAT TO FLDCAT.

    CLEAR W_FLDCAT.

    W_FLDCAT-FIELDNAME = 'VKGRP'.

    W_FLDCAT-SELTEXT_M = 'Sales_Group'.

    W_FLDCAT-COL_POS = 8.

    W_FLDCAT-EMPHASIZE = 'C801'.

    APPEND W_FLDCAT TO FLDCAT.

    CLEAR W_FLDCAT.

    W_FLDCAT-FIELDNAME = 'RN'.

    W_FLDCAT-SELTEXT_S = 'RN'.

    W_FLDCAT-COL_POS = 0.

    APPEND W_FLDCAT TO FLDCAT.

    CLEAR W_FLDCAT.

    ENDFORM.

    • Build Layout for ALV Grid Report

    FORM BLD_LAYOUT.

    GD_LAYOUT-NO_INPUT = 'X'.

    *GD_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.

    *GD_LAYOUT-NO_SCROLLING = 'X'.

    *GD_LAYOUT-BOX_FIELDNAME = 'VBELN'.

    ENDFORM.

    • 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

    IS_LAYOUT = GD_LAYOUT

    I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'

    IT_FIELDCAT = FLDCAT[]

    I_SAVE = 'X'

    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.

    • Retrieve data from VBAK table and populate itab IT_VBAK

    FORM DATA_RETRIEVAL.

    SELECT VBELN ERDAT ERNAM AUDAT VBTYP NETWR VKORG

    FROM VBAK

    INTO TABLE IT_VBAK

    WHERE VBELN IN VBELN.

    LOOP AT IT_VBAK.

    IT_VBAK-RN = SY-TABIX.

    MODIFY IT_VBAK INDEX SY-TABIX.

    ENDLOOP.

    ENDFORM.

    FORM TOP_OF_PAGE.

    DATA: T_HEADER TYPE SLIS_T_LISTHEADER,

    W_HEADER TYPE SLIS_LISTHEADER.

    W_HEADER-TYP = 'H'.

    W_HEADER-INFO = 'WELCOME HEADER LIST'.

    APPEND W_HEADER TO T_HEADER.

    W_HEADER-TYP = 'S'.

    W_HEADER-KEY = 'REPORT:'.

    W_HEADER-INFO = SY-REPID.

    APPEND W_HEADER TO T_HEADER.

    W_HEADER-TYP = 'S'.

    W_HEADER-KEY = 'DATE:'.

    CONCATENATE SY-DATUM4(2) ' / ' SY-DATUM6(2) ' / ' SY-DATUM(4) INTO W_HEADER-INFO.

    APPEND W_HEADER TO T_HEADER.

    CLEAR W_HEADER.

    W_HEADER-TYP = 'S'.

    W_HEADER-KEY = 'Page_No:'.

    W_HEADER-INFO = SY-PAGNO.

    APPEND W_HEADER TO T_HEADER.

    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

    EXPORTING

    IT_LIST_COMMENTARY = T_HEADER.

    ENDFORM.

    Reward,if it is useful.

    Thanks,

    Chandu

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.