Skip to Content
author's profile photo
Former Member

Regarding top of page, end of page in alv's

hi

how can i get the data in page wise in alv's?

like in normal reporting we use events like top of page and end of page...

but how in alv's

bye

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

3 Answers

  • author's profile photo
    Former Member
    Posted on Aug 23, 2007 at 08:33 AM

    Hi Sowjanya,

    There is an function module called REUSE_ALV_COMMENTARY_WRITE this is useful for header try it.

    All the best.

    Reward if useful.

    kishore

    Add comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 23, 2007 at 08:33 AM

    hi sowjanya,

    you have to create form routines like

    FORM TOP_OF_PAGE

    ... here you add your coding for your top pf page event

    ENDFORM

    and you have to pass the name of the subroutine to the ALV FM

    REUSE_ALV_LIST_DISPLAY:

    pass it in the EVENTS parameter

    REUSE_ALV_GRID_DISPLAY:

    pass it in i_callback_top_of_page parameter

    hope this helps

    ec

    Add comment
    10|10000 characters needed characters exceeded

    • Sowjanya,

      This report will let you know how to write top of page in ALV.But page wise? Even I don't know.Is it possible to show ALV page wise?

      REPORT zfluke7 LINE-SIZE 120 NO STANDARD PAGE HEADING.

      TYPE-POOLS:slis.

      TABLES: bsis.

      TYPES:BEGIN OF ibsis ,

      sl_no LIKE sy-tabix,

      bukrs LIKE bsis-bukrs,

      hkont LIKE bsis-hkont,

      gjahr LIKE bsis-gjahr,

      belnr LIKE bsis-belnr,

      waers LIKE bsis-waers,

      shkzg LIKE bsis-shkzg,

      dmbtr LIKE bsis-dmbtr,

      wrbtr LIKE bsis-wrbtr,

      werks LIKE bsis-werks,

      END OF ibsis.

      DATA:itfinal TYPE ibsis OCCURS 0 WITH HEADER LINE.

      *Declarations for ALV

      DATA:itfieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE.

      DATA:itrepid TYPE sy-repid.

      itrepid = sy-repid.

      DATA:itevent TYPE slis_t_event.

      DATA:itlistheader TYPE slis_t_listheader.

      DATA:walistheader LIKE LINE OF itlistheader.

      DATA:itlayout TYPE slis_layout_alv.

      DATA:top TYPE slis_formname.

      DATA:itsort TYPE slis_t_sortinfo_alv WITH HEADER LINE.

      DATA :itsort1 TYPE slis_sortinfo_alv.

      DATA:itprintparams TYPE slis_print_alv.

      DATA:itvariant TYPE disvariant.

      SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001."#EC *

      PARAMETERS: p_gjahr LIKE bsis-gjahr,

      p_bukrs LIKE bsis-bukrs.

      • P_hkont LIKE BSis-hkont.

      SELECTION-SCREEN END OF BLOCK b1.

      START-OF-SELECTION.

      PERFORM getdata.

      PERFORM filtering.

      PERFORM alv.

      &----


      *& Form getdata

      &----


      • Selecting the data from BSIS

      ----


      FORM getdata.

      SELECT bukrs hkont gjahr belnr waers shkzg dmbtr wrbtr werks FROM bsis

      INTO CORRESPONDING FIELDS OF TABLE itfinal

      WHERE gjahr = p_gjahr

      AND bukrs = p_bukrs.

      *AND HKONT = P_HKONT

      IF sy-subrc NE 0.

      MESSAGE 'No Values exist for the Selection.' TYPE 'S'.

      ENDIF.

      ENDFORM. "getdata

      &----


      *& Form filtering

      &----


      • Deleting the records where dmbtr NE wrbtr and waers NE INR

      ----


      FORM filtering.

      LOOP AT itfinal.

      IF ( itfinal-dmbtr EQ itfinal-wrbtr ) OR ( itfinal-waers NE 'INR' ).

      DELETE itfinal.

      ENDIF.

      ENDLOOP.

      ENDFORM. "filtering

      &----


      *& Form ALV

      &----


      • text

      ----


      • --> p1 text

      • <-- p2 text

      ----


      FORM alv .

      LOOP AT itfinal.

      itfinal-sl_no = sy-tabix.

      MODIFY itfinal.

      ENDLOOP.

      itlayout-zebra = 'X'.

      itlayout-colwidth_optimize = 'X'.

      itlayout-no_subtotals = ' '.

      IF itfinal[] IS INITIAL.

      MESSAGE 'No Values exist for the Selection.' TYPE 'S'.

      STOP.

      ENDIF.

      DEFINE m_fieldcat.

      itfieldcat-fieldname = &1.

      itfieldcat-col_pos = &2.

      itfieldcat-seltext_l = &3.

      itfieldcat-do_sum = &4.

      itfieldcat-outputlen = &5.

      append itfieldcat to itfieldcat.

      clear itfieldcat.

      END-OF-DEFINITION.

      m_fieldcat 'SL_NO' '' 'SL. NO' '' 03.

      m_fieldcat 'BUKRS' '' 'Company Code' '' 04.

      m_fieldcat 'HKONT' '' 'G/L Acccount' '' 10.

      m_fieldcat 'GJAHR' '' 'Fiscal Year' '' 04.

      m_fieldcat 'BELNR' '' 'Accounting Document No.' '' 10.

      m_fieldcat 'WAERS' '' 'Currency' '' 05.

      m_fieldcat 'SHKZG' '' 'Debit/Credit' '' 01.

      m_fieldcat 'DMBTR' '' 'Amount in Local Currency' '' 13.

      m_fieldcat 'WRBTR' '' 'Amount in Document Currency' '' 13.

      m_fieldcat 'WERKS' '' 'Plant.' '' 04.

      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

      EXPORTING

      • I_INTERFACE_CHECK = ' '

      • I_BYPASSING_BUFFER = ' '

      • I_BUFFER_ACTIVE = ' '

      i_callback_program = sy-repid

      • I_CALLBACK_PF_STATUS_SET = ' '

      i_callback_user_command = 'LIST1'

      i_callback_top_of_page = 'TOP'

      • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

      • I_CALLBACK_HTML_END_OF_LIST = ' '

      • I_STRUCTURE_NAME =

      • I_BACKGROUND_ID = ' '

      • I_GRID_TITLE =

      • I_GRID_SETTINGS =

      is_layout = itlayout

      it_fieldcat = itfieldcat[]

      • IT_EXCLUDING =

      • IT_SPECIAL_GROUPS =

      • IT_SORT =

      • IT_FILTER =

      • IS_SEL_HIDE =

      • I_DEFAULT = 'X'

      • I_SAVE = ' '

      • IS_VARIANT =

      it_events = itevent[]

      • 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

      • IT_ALV_GRAPHICS =

      • IT_HYPERLINK =

      • IT_ADD_FIELDCAT =

      • IT_EXCEPT_QINFO =

      • I_HTML_HEIGHT_TOP =

      • I_HTML_HEIGHT_END =

      • IMPORTING

      • E_EXIT_CAUSED_BY_CALLER =

      • ES_EXIT_CAUSED_BY_USER =

      TABLES

      t_outtab = itfinal

      • 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. " ALV

      &----


      *& Form LIST1

      &----


      • ALV Interactive

      ----


      • -->R_UCOMM text

      • -->RS_SELFIELDtext

      ----


      FORM list1 USING r_ucomm LIKE sy-ucomm

      rs_selfield TYPE slis_selfield.

      CASE r_ucomm.

      WHEN '&IC1'.

      IF rs_selfield-fieldname = 'BELNR' .

      READ TABLE itfinal INDEX rs_selfield-tabindex.

      SET PARAMETER ID: 'BLN' FIELD itfinal-belnr,

      'BUK' FIELD itfinal-bukrs,

      'GJR' FIELD itfinal-gjahr.

      CALL TRANSACTION 'FB03' AND SKIP FIRST SCREEN.

      ENDIF.

      ENDCASE.

      ENDFORM. "user_command

      &----


      *& Form TOP

      &----


      • ALV TOP OF PAGE

      ----


      FORM top.

      DATA: string1(45).

      DATA:title(45).

      string1 = 'Difference in Currencies in'.

      CONCATENATE string1 itfinal-bukrs INTO title SEPARATED BY space.

      walistheader-typ = 'H'.

      walistheader-info = title.

      APPEND walistheader TO itlistheader.

      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

      EXPORTING

      i_list_type = 0

      IMPORTING

      et_events = itevent

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

      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

      EXPORTING

      it_list_commentary = itlistheader

      • I_LOGO =

      • I_END_OF_LIST_GRID =

      .

      CLEAR itlistheader.

      ENDFORM. "top

      K.Kiran

  • author's profile photo
    Former Member
    Posted on Aug 23, 2007 at 08:37 AM

    check this one

    &----


    *& Report ZALV_FIELD_GRID1

    *&

    &----


    *&

    *&

    &----


    REPORT ZALV_FIELD_GRID1

    NO STANDARD PAGE HEADING.

    TABLES MARA.

    type-pools :slis.

    TYPES : BEGIN OF TMARA ,

    MATNR LIKE MARA-MATNR,

    MEINS LIKE MARA-MEINS,

    ERSDA LIKE MARA-ERSDA,

    color(4) type c,

    SEL type c,

    LIGHT TYPE C,

    END OF TMARA.

    TYPES: BEGIN OF TMAKT,

    MATNR LIKE MAKT-MATNR,

    MAKTX LIKE MAKT-MAKTX,

    MAKTG LIKE MAKT-MAKTG,

    SEL TYPE C,

    COLOR(4),

    END OF TMAKT.

    DATA: ITAB TYPE TMARA OCCURS 0 WITH HEADER LINE,

    ITAB1 TYPE TMAKT OCCURS 0 WITH HEADER LINE,

    wa_fieldcat type slis_fieldcat_alv,

    fieldcat type slis_fieldcat_alv occurs 0,

    i_layout type slis_layout_alv,

    WA_LISTHEADER TYPE SLIS_LISTHEADER,

    i_LISTHEADER TYPE SLIS_LISTHEADER OCCURS 0,

    V_EVENTS TYPE SLIS_T_EVENT ,

    WA_EVENT TYPE SLIS_ALV_EVENT,

    I_TITLE_MARA TYPE LVC_TITLE VALUE 'FIRST LIST DISPLAYED',

    I_TITLE_MAKT TYPE LVC_TITLE VALUE 'SECONDRY LIST DISPLAYED',

    SORT TYPE slis_t_sortinfo_alv WITH HEADER LINE,

    PRINT_CONT type slis_print_alv.

    *----


    • SELECTION SCREE

    *----


    selection-screen begin of block screen1 with frame title TEXT-001.

    SELECTION-SCREEN SKIP.

    SELECTION-SCREEN COMMENT /32(35) COMM1.

    SELECTION-SCREEN ULINE /27(35).

    SELECTION-SCREEN SKIP.

    SELECT-OPTIONS MATNR FOR MARA-MATNR.

    SELECTION-SCREEN SKIP.

    SELECTION-SCREEN ULINE.

    SELECTION-SCREEN COMMENT /30(50) COMM2.

    SELECTION-SCREEN ULINE /27(40).

    SELECTION-SCREEN SKIP.

    SELECT-OPTIONS ERSDA FOR MARA-ERSDA.

    SELECTION-SCREEN SKIP.

    selection-screen end of block screen1.

    *----


    • INITIALIZATION

    *----


    INITIALIZATION.

    MATNR-low = '23'.

    MATNR-high = '1000'.

    MATNR-option = 'BT'.

    MATNR-sign = 'I'.

    APPEND MATNR.

    ERSDA-low = '20030124'.

    ERSDA-high = '20050302' .

    APPEND ERSDA.

    PERFORM FILLFIELD.

    PERFORM FILLLAYOUT.

    PERFORM build_print_params.

    PERFORM FILL_SORT.

    PERFORM EVENT_CALL.

    PERFORM POPULATE_EVENT.

    *----


    • SELECTION-SCREEN OUTPUT

    *----


    AT SELECTION-SCREEN OUTPUT.

    comm1 ='SELECT MATERIAL NUMBER RANGE'.

    comm2 ='SELECT MATERIAL CREATION DATE'.

    *----


    • START-OF-SELECTION

    *----


    START-OF-SELECTION.

    PERFORM READDATA.

    PERFORM POPDATA.

    &----


    *& Form READDATA

    &----


    • text

    ----


    FORM READDATA .

    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

    EXPORTING

    INPUT = MATNR-LOW

    IMPORTING

    OUTPUT = MATNR-LOW.

    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

    EXPORTING

    INPUT = MATNR-HIGH

    IMPORTING

    OUTPUT = MATNR-HIGH.

    SELECT MATNR

    ERSDA

    MEINS

    FROM MARA

    INTO CORRESPONDING FIELDS OF

    TABLE ITAB

    WHERE MATNR IN MATNR AND ERSDA IN ERSDA.

    LOOP AT ITAB.

    data id_color type i VALUE 1.

    data id_colors(2) type c.

    IF ITAB-MATNR < '000000000000000100'.

    ITAB-LIGHT = '1'.

    ELSEIF ITAB-MATNR < '000000000000000150' AND ITAB-MATNR >

    '000000000000000100' .

    ITAB-LIGHT = '2'.

    ELSE.

    ITAB-LIGHT = '3'.

    ENDIF.

    id_color = id_color + 1.

    if id_color > 7.

    id_color = 1.

    endif.

    id_colors = id_color.

    concatenate 'C' id_colors '10' into itab-color.

    modify itab.

    CLEAR ITAB.

    endloop.

    ENDFORM. " READDATA

    ----


    • Form FILLFIELD

    ----


    FORM FILLFIELD .

    WA_FIELDCAT-FIELDNAME = 'MATNR'.

    WA_FIELDCAT-KEY = 'X'.

    WA_FIELDCAT-COL_POS = '1'.

    WA_FIELDCAT-outputlen = 20.

    WA_FIELDCAT-HOTSPOT = 'X'.

    wa_fieldcat-seltext_m = 'MATERIAL NUMBER'.

    *WA_FIELDCAT-EMPHASIZE = 'C210'.

    APPEND WA_FIELDCAT TO FIELDCAT.

    clear wa_fieldcat.

    WA_FIELDCAT-FIELDNAME = 'MEINS'.

    WA_FIELDCAT-COL_POS = '2'.

    *WA_FIELDCAT-EMPHASIZE = 'C510'.

    WA_FIELDCAT-outputlen = 10.

    wa_fieldcat-seltext_m = 'UNIT'.

    APPEND WA_FIELDCAT TO FIELDCAT.

    clear wa_fieldcat.

    WA_FIELDCAT-FIELDNAME = 'ERSDA'.

    WA_FIELDCAT-COL_POS = '3'.

    WA_FIELDCAT-outputlen = 15.

    *WA_FIELDCAT-EDIT_MASK = 'DD.MM.YYYY'.

    *WA_FIELDCAT-EMPHASIZE = 'C710'.

    wa_fieldcat-seltext_m = 'CREAT DATE'.

    APPEND WA_FIELDCAT TO FIELDCAT.

    clear wa_fieldcat.

    ENDFORM. "FILLFIELD

    &----


    • Setup print parameters

    ----


    form build_print_params.

    PRINT_CONT-reserve_lines = '3'. "Lines reserved for footer

    PRINT_CONT-no_coverpage = 'X'.

    endform. " BUILD_PRINT_PARAMS

    ----


    • Form POPDATA

    ----


    FORM POPDATA .

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    • I_INTERFACE_CHECK = ' '

    • I_BYPASSING_BUFFER = ' '

    • I_BUFFER_ACTIVE = ' '

    I_CALLBACK_PROGRAM = sy-repid

    • I_CALLBACK_PF_STATUS_SET = ' '

    I_CALLBACK_USER_COMMAND = 'USER-COMMAND'

    I_CALLBACK_TOP_OF_PAGE = 'TOPPAGE' -


    >use this one

    • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

    • I_CALLBACK_HTML_END_OF_LIST = ' '

    • I_STRUCTURE_NAME =

    • I_BACKGROUND_ID = ' '

    I_GRID_TITLE = I_TITLE_MARA

    • I_GRID_SETTINGS =

    IS_LAYOUT = I_LAYOUT

    IT_FIELDCAT = fieldcat

    • IT_EXCLUDING =

    • IT_SPECIAL_GROUPS =

    IT_SORT = SORT[]

    • IT_FILTER =

    • IS_SEL_HIDE =

    • I_DEFAULT = 'X'

    • I_SAVE = ' '

    • IS_VARIANT =

    IT_EVENTS = V_EVENTS -


    > pass u r events here end of page

    • IT_EVENT_EXIT =

    IS_PRINT = PRINT_CONT

    TABLES

    T_OUTTAB = ITAB

    EXCEPTIONS

    PROGRAM_ERROR = 1

    OTHERS = 2

    .

    ENDFORM. " POPDATA

    ----


    • Form TOPPAGE

    ----


    FORM TOPPAGE.

    REFRESH I_LISTHEADER.

    DATA: ld_lines type i,

    ld_linesc(10) type c,

    I_DATE(10) TYPE C,

    I_INFO LIKE WA_LISTHEADER-INFO.

    WA_LISTHEADER-TYP = 'H'.

    WA_LISTHEADER-INFO = 'MATERIAL DETAIL'.

    APPEND WA_LISTHEADER TO I_LISTHEADER.

    CLEAR WA_LISTHEADER.

    WA_LISTHEADER-TYP = 'S'.

    WA_LISTHEADER-KEY = 'DATE :'.

    CONCATENATE SY-DATUM+6(2) '.'

    SY-DATUM+4(2) '.'

    SY-DATUM(4) INTO I_DATE.

    WA_LISTHEADER-INFO = I_datE.

    APPEND WA_LISTHEADER TO I_LISTHEADER.

    CLEAR WA_LISTHEADER.

    describe table ITAB lines ld_lines.

    ld_linesc = ld_lines.

    concatenate 'TOTAL NUMBER OF RECORD SELECTED: ' ld_linesc

    into I_INFO separated by space.

    WA_LISTHEADER-TYP = 'A'.

    WA_LISTHEADER-INFO = I_INFO.

    append WA_LISTHEADER to I_LISTHEADER.

    clear: WA_LISTHEADER , I_INFO.

    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

    EXPORTING

    IT_LIST_COMMENTARY = I_LISTHEADER

    I_LOGO = 'ENJOYSAP_LOGO'.

    ENDFORM. "TOPPAGE

    ----


    • Form FILLLAYOUT

    ----


    FORM FILLLAYOUT .

    i_layout-zebra = 'X'.

    i_layout-info_fieldname = 'COLOR'.

    i_layout-box_fieldname = 'SEL'.

    I_LAYOUT-lights_fieldname = 'LIGHT'.

    I_LAYOUT-EDIT ='X'.

    I_LAYOUT-colwidth_optimize = 'X'.

    I_LAYOUT-window_titlebar = 'EXAMPLE FOR ALV GRID'.

    I_LAYOUT-no_totalline = 'X'.

    ENDFORM. "FILLLAYOUT

    ----


    • Form FILL_SORT

    ----


    FORM FILL_SORT .

    SORT-DOWN = 'X'.

    SORT-SPOS = 1.

    SORT-FIELDNAME = 'MATNR'.

    SORT-tabname = 'MARA'.

    APPEND SORT.

    ENDFORM. " FILL_SORT

    ----


    • Form EVENT_CALL

    ----


    FORM EVENT_CALL .

    DATA: I_EVENT LIKE V_EVENTS.

    CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

    EXPORTING

    I_LIST_TYPE = 0

    IMPORTING

    ET_EVENTS = V_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.

    ENDFORM. " EVENT_CALL

    ----


    • Form POPULATE_EVENT

    ----


    FORM POPULATE_EVENT .----


    > use events ........

    READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'USER_COMMAND'.

    IF SY-SUBRC EQ 0.

    WA_EVENT-FORM = 'USER_COMMAND'.

    MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =

    WA_EVENT-NAME.

    READ TABLE V_EVENTS WITH KEY NAME = SLIS_EV_END_OF_PAGE

    INTO WA_EVENT.

    IF SY-SUBRC = 0.

    move 'END_OF_PAGE' to WA_EVENT-FORM.

    MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =

    WA_EVENT-NAME.

    endif.

    ENDIF.

    ENDFORM. "POPULATE_EVENT

    *----


    FORM END_OF_PAGE. -


    > end of page

    write: sy-uline(50).

    skip.

    write:/40 'Page:', sy-pagno .

    ENDFORM.

    &----


    *& Form USER_COMMAND

    ----


    FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM

    RS_SELFIELD TYPE SLIS_SELFIELD.

    CASE R_UCOMM.

    WHEN '&IC1'.

    CASE RS_SELFIELD-FIELDNAME.

    when 'MATNR'.

    read table itab with key matnr = RS_SELFIELD-VALUE.

    if sy-subrc = 0.

    PERFORM DATA_RETRIEVAL_MAKT USING RS_SELFIELD-VALUE.

    PERFORM BUILD_FIELDCATLOG_MAKT.

    PERFORM FILLLAYOUT_MAKT.

    PERFORM DISPLAY_ALV_MAKT.

    CLEAR RS_SELFIELD.

    ENDIF.

    ENDCASE.

    ENDCASE.

    ENDFORM. "user_command

    ----


    • Form DATA_RETRIEVAL_MAKT

    ----


    FORM DATA_RETRIEVAL_MAKT USING TMATNR .

    SELECT MATNR

    MAKTX

    MAKTG

    UP TO 100 ROWS

    FROM MAKT

    INTO TABLE ITAB1

    WHERE SPRAS = 'EN' AND MATNR = TMATNR.

    LOOP AT ITAB1.

    data id_color type i VALUE 1.

    data id_colors(2) type c.

    id_color = id_color + 1.

    if id_color > 7.

    id_color = 1.

    endif.

    id_colors = id_color.

    concatenate 'C' id_colors '10' into itab1-color.

    modify itab1.

    CLEAR ITAB1.

    ENDLOOP.

    ENDFORM. "DATA_RETRIEVAL_MAKT

    ----


    • Form FILLLAYOUT_MAKT

    ----


    FORM FILLLAYOUT_MAKT .

    CLEAR I_LAYOUT.

    i_layout-zebra = 'X'.

    i_layout-info_fieldname = 'COLOR'.

    i_layout-box_fieldname = 'SEL'.

    I_LAYOUT-EDIT ='X'.

    I_LAYOUT-colwidth_optimize = 'X'.

    I_LAYOUT-window_titlebar = 'EXAMPLE FOR ALV GRID'.

    ENDFORM. " LAYOUT_MAKT

    ----


    • Form BUILD_FIELDCATLOG_MAKT

    ----


    FORM BUILD_FIELDCATLOG_MAKT .

    REFRESH FIELDCAT.

    WA_FIELDCAT-FIELDNAME = 'MATNR'.

    WA_FIELDCAT-KEY = 'X'.

    WA_FIELDCAT-COL_POS = '1'.

    *WA_FIELDCAT-EDIT_MASK = 'DD.MM.YYYY'.

    WA_FIELDCAT-EMPHASIZE = 'C510'.

    wa_fieldcat-seltext_m = 'MATERIAL NUMBER'.

    APPEND WA_FIELDCAT TO FIELDCAT.

    clear wa_fieldcat.

    WA_FIELDCAT-FIELDNAME = 'MAKTX'.

    WA_FIELDCAT-COL_POS = '2'.

    WA_FIELDCAT-EMPHASIZE = 'C710'.

    wa_fieldcat-seltext_m = 'MATERIAL DESCRIPTION'.

    APPEND WA_FIELDCAT TO FIELDCAT.

    clear wa_fieldcat.

    WA_FIELDCAT-FIELDNAME = 'MAKTG'.

    WA_FIELDCAT-COL_POS = '3'.

    WA_FIELDCAT-EMPHASIZE = 'C210'.

    wa_fieldcat-seltext_m = 'MATERIAL DESCRIPTION'.

    APPEND WA_FIELDCAT TO FIELDCAT.

    clear wa_fieldcat.

    ENDFORM. " BUILD_FIELDCATLOG_MAKT

    ----


    • Form DISPLAY_ALV_MAKT

    ----


    FORM TOP-OF-PAGE.

    REFRESH I_LISTHEADER.

    DATA: ld_lines type i,

    ld_linesc(10) type c,

    I_DATE(10) TYPE C,

    I_INFO LIKE WA_LISTHEADER-INFO.

    WA_LISTHEADER-TYP = 'H'.

    WA_LISTHEADER-INFO = 'MATERIAL DESCRIPTION FOR SELECTED NUMBER'.

    APPEND WA_LISTHEADER TO I_LISTHEADER.

    CLEAR WA_LISTHEADER.

    WA_LISTHEADER-TYP = 'S'.

    WA_LISTHEADER-KEY = 'DATE :'.

    CONCATENATE SY-DATUM+6(2) '.'

    SY-DATUM+4(2) '.'

    SY-DATUM(4) INTO I_DATE.

    WA_LISTHEADER-INFO = I_datE.

    APPEND WA_LISTHEADER TO I_LISTHEADER.

    CLEAR WA_LISTHEADER.

    describe table ITAB1 lines ld_lines.

    ld_linesc = ld_lines.

    concatenate 'TOTAL NUMBER OF RECORD SELECTED: ' ld_linesc

    into I_INFO separated by space.

    WA_LISTHEADER-TYP = 'A'.

    WA_LISTHEADER-INFO = I_INFO.

    append WA_LISTHEADER to I_LISTHEADER.

    clear: WA_LISTHEADER , I_INFO.

    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

    EXPORTING

    IT_LIST_COMMENTARY = I_LISTHEADER

    I_LOGO = 'ENJOYSAP_LOGO'.

    • I_END_OF_LIST_GRID =

    • I_ALV_FORM =

    ENDFORM. "TOP-OF-PAGE

    &----


    *& Form DISPLAY_ALV_MAKT

    &----


    • text

    ----


    FORM DISPLAY_ALV_MAKT .

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    I_CALLBACK_PROGRAM = SY-REPID

    I_CALLBACK_TOP_OF_PAGE = 'TOP-OF-PAGE'

    I_GRID_TITLE = I_TITLE_MAKT

    IS_LAYOUT = I_LAYOUT

    IT_FIELDCAT = fieldcat

    TABLES

    T_OUTTAB = ITAB1

    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_ALV_MAKT

    reward points to all helpful answers

    kiran.M

    Add comment
    10|10000 characters needed characters exceeded