16 Replies Latest reply: Feb 10, 2011 8:38 AM by Diwakar Teja B RSS

Top-of-page in Alv Grid

Karthik R
Currently Being Moderated

Hi Experts,

 

I want to display the below said in top-of-page (alv) as TITLE can include only 72 characters.

 

*FORM TITLE.

**

    • WRITE BUDAT-LOW DD/MM/YYYY TO DATE1.

    • WRITE BUDAT-HIGH DD/MM/YYYY TO DATE2.

**

    • CONCATENATE IT_FINAL-NAME1 'Reconcilliation Statement From'

    •              DATE1 'TO' DATE2

    •              INTO TITLE SEPARATED BY SPACE .

**

**

**

**ENDFORM.                    "TITLE

 

Please advice.

Karthik

  • Re: Top-of-page in Alv Grid
    Sarbajit Majumdar
    Currently Being Moderated

    Please explain your problem a little bit elaborately.

     

    Thanks

  • Re: Top-of-page in Alv Grid
    Raghunath Shyamala
    Currently Being Moderated

    Hi,

     

    For this you need to use events in ALV.. in FM you have parameter called event..

     

    sample

    
    -----
    
    IT_EVENT-EVENTNAME = TOP_OF_PAGE.
    IT_EVENT-FORMNAME = top.
    
    call the ALV grid FM ..
    
    
    FORM TOP.
    ---
    ---
    ENDFORM.
    

     

  • Re: Top-of-page in Alv Grid
    KAMESH G
    Currently Being Moderated

    USe TOP-OF-PAGE event ..

  • Re: Top-of-page in Alv Grid
    Krishna Chaitanya N
    Currently Being Moderated

    Hi Karthik,

     

    In ALV you will use the events and a Function module calle Resue_alv_commentry_write you can display the header on the top of the ALV.

     

     

     

    You can check with the below code :

     

    *&---------------------------------------------------------------------*
    *&      Form  DISPLAY
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM DISPLAY .
    
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          I_CALLBACK_PROGRAM = sy-repid
    *      I_GRID_TITLE       = i_title_gts
          IS_LAYOUT          = wa_layout
          IT_FIELDCAT        = lt_fieldcat
          IT_EVENTS          = it_events
        TABLES
          T_OUTTAB           = <dyn_table>
        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'.
    
    
    ENDFORM.                    " DESINLAYOUT
    *&---------------------------------------------------------------------*
    *&      Form  GETEVENTS
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *      -->P_IT_EVENTS  text
    *----------------------------------------------------------------------*
    FORM GETEVENTS  USING  P_IT_EVENTS type slis_t_event.
    
      .
    
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          I_LIST_TYPE     = 0
        IMPORTING
          ET_EVENTS       = p_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.
    
      READ TABLE P_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.
    
    ENDFORM.                    " GETEVENTS
    
    
    
    *&---------------------------------------------------------------------
    *& Form top-of-page
    *&---------------------------------------------------------------------
    FORM TOP_OF_PAGE.
    
      WA_LISTHEADER-TYP = 'S'.
      WA_LISTHEADER-KEY = 'DATE'.
    * WA_LISTHEADER-INFO = SY-DATUM. " - DG1K902198
      WRITE SY-DATUM TO WA_LISTHEADER-INFO." + DG1K902198
      APPEND WA_LISTHEADER TO IT_LISTHEADER.
    
      WA_LISTHEADER-TYP = 'S'.
      WA_LISTHEADER-KEY = 'TIME'.
    * WA_LISTHEADER-INFO = SY-UZEIT." - DG1K902198
      WRITE SY-UZEIT TO WA_LISTHEADER-INFO. " +DG1K902198
      APPEND WA_LISTHEADER TO IT_LISTHEADER.
    
      WA_LISTHEADER-TYP = 'S'.
      WA_LISTHEADER-KEY = 'CLIENT'.
      WA_LISTHEADER-INFO = SY-MANDT.
      APPEND WA_LISTHEADER TO IT_LISTHEADER.
    
      CLEAR WA_LISTHEADER.
    
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary = IT_LISTHEADER. "it_listheader.
    
    
      REFRESH IT_LISTHEADER.         "it_listheader.
    
    
    ENDFORM. "top-of-pa

     

     

     

    This will work....Try with the above code with the changes that you wanted.

     

    Regards,

    Kittu

    • Re: Top-of-page in Alv Grid
      Karthik R
      Currently Being Moderated

      Hi Kittu,

       

      Thanks for your post, but its not working.

       

      Now my out put is:

      Subcontracting Vend

       

      • Reconcilliation Statement  From  22.12.2006 T* 

       

      it should be:

        Subcontracting Vendors

        Reconcilliation Statement  From  22.12.2006 TO 16.02.2009.

       

      Please advice if there is any thing wrong with my coding.

       

      
      FORM GETEVENTS  USING  GT_EVENTS TYPE SLIS_T_EVENT.
       
        CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
         EXPORTING
           I_LIST_TYPE           = 0
         IMPORTING
           ET_EVENTS             = GT_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.
       
        READ TABLE GT_EVENTS INTO WA_EVENTS WITH KEY NAME = 'TOP_OF_PAGE'.
        WA_EVENTS-FORM = 'TOP_OF_PAGE'.
       
        MODIFY EVENT FROM WA_EVENTS TRANSPORTING FORM WHERE NAME = WA_EVENTS-NAME.
       
      ENDFORM.                    &quot;GETEVENTS
       
      

       

       

      FORM TOP_OF_PAGE.
      
        DATA : LV_DATE(24) TYPE C.
        WRITE BUDAT-LOW DD/MM/YYYY TO DATE1.
        WRITE BUDAT-HIGH DD/MM/YYYY TO DATE2.
      
        CONCATENATE  DATE1 'TO' DATE2 INTO LV_DATE SEPARATED BY SPACE.
      
        WA_TOP-TYP = 'S'.
        WA_TOP-KEY = IT_FINAL-NAME1.
        APPEND WA_TOP TO IT_TOP.
        CLEAR WA_TOP.
      
        WA_TOP-TYP = 'S'.
        WA_TOP-KEY = 'Recon.Statement From'.
        WA_TOP-INFO = LV_DATE.
        APPEND WA_TOP TO IT_TOP.
        CLEAR WA_TOP.
      
        CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
          EXPORTING
            IT_LIST_COMMENTARY       = IT_TOP
      *     I_LOGO                   =
      *     I_END_OF_LIST_GRID       =
      *     I_ALV_FORM               =
                  .
      
      ENDFORM.                    "TOP_OF_PAGE
      

       

      Please advice.

      Karthik

       

      • Re: Top-of-page in Alv Grid
        ram Kumar
        Currently Being Moderated

        Hi Karthik,

         

        As i see in your coding, you are passing "Subcontracting Vendors" in to KEY of the header structure.

         

          WA_TOP-TYP = 'S'.
          WA_TOP-KEY = IT_FINAL-NAME1.
          APPEND WA_TOP TO IT_TOP.
          CLEAR WA_TOP.
        

         

        But, the Key can hold only a maximum of 20 Characters. So its better that you pass this text in "info"

         

        Similarly, for the other details also, you need to take care of the maximum characters that it would accept.

         

        types: begin of slis_listheader,
                 typ(1) type c,   " H = Header, S = Selection, A = Action
                 key(20) type c,
                 info type slis_entry,
               end of slis_listheader.

         

        info accepts a maxmum of 60 Characters only.

         

         

        Best Regards,

        Ram.

        • Re: Top-of-page in Alv Grid
          Karthik R
          Currently Being Moderated

          Hi Ram,

           

          Thank you !!

           

          Can you please advice me on this as if mt vendor name is lengthy I am facing trouble.

           

          Karthik

          • Re: Top-of-page in Alv Grid
            ram Kumar
            Currently Being Moderated

            Karthik,

             

            I guess the vendor name may not be lengthier than 60 characters. Hence you can pass it in the INFO field of the list header strucutre, instead of Key. In this way, you wil not face this issue.

             

            Only draw back would be, it will not be displayed in BOLD letters

            For bold, you can provide TYPE as "H".

             

             

            Best Regards,

            Ram.

             

            Edited by: ram Kumar on Mar 5, 2009 7:13 PM

          • Re: Top-of-page in Alv Grid
            Bathri S
            Currently Being Moderated

            Hi,

                    Try with this.

                 DATA : LH TYPE SLIS_T_LISTHEADER,

                             LS TYPE SLIS_LISTHEADER .

             

             

                 I_CALLBACK_TOP_OF_PAGE            = 'TOP'

             

            FORM TOP.

             

              DATA : L_DATE(10) TYPE C .

              DATA : L_DATE1(20) TYPE C .

              CLEAR LS.

             

              LS-TYP = 'H'.

              LS-INFO = 'STUDENT DETAILS'.

              APPEND LS TO LH.

              CLEAR LS.

             

              LS-TYP = 'S'.

              WRITE: SY-DATUM TO L_DATE USING EDIT MASK '__/__/____'.

              CONCATENATE 'DATE :' L_DATE INTO L_DATE1 SEPARATED BY SPACE.

              LS-INFO = L_DATE1.

              APPEND LS TO LH.

              CLEAR LS.

  • Re: Top-of-page in Alv Grid
    Tarun Gambhir
    Currently Being Moderated

    Hi,

     

    Use the top_of_page this way to print as per your requirement:-

     

    *FOR TOP OF THE PAGE
    DATA : it_top TYPE slis_t_listheader,
           wa_top TYPE slis_listheader.
    
    *&---------------------------------------------------------------------*
    *          DISPLAY RECORDS IN ALV GRID
    *&---------------------------------------------------------------------*
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
        i_callback_program                = sy-repid
        i_callback_top_of_page            = 'TOP'
        it_fieldcat                       = it_field
       TABLES
        t_outtab                          = it_ekpo
       EXCEPTIONS
        program_error                     = 1
        OTHERS                            = 2.
    
      IF sy-subrc <> 0.
      ENDIF.
    
    *&---------------------------------------------------------------------*
    *&      Form  top
    *&---------------------------------------------------------------------*
    *       TO WRITE THE HEADER
    *----------------------------------------------------------------------*
    FORM top.
    
      DATA : lv_date(20) TYPE c.
      WRITE BUDAT-LOW DD/MM/YYYY TO DATE1. 
      WRITE BUDAT-HIGH DD/MM/YYYY TO DATE2.
    
      CONCATENATE DATE1 DATE2 INTO lv_date SEPARATED BY SPACE.
    
      REFRESH it_top.
    
      wa_top-typ = 'S'.
      wa_top-key = IT_FINAL-NAME1.
      wa_top-info = ' '.
      APPEND wa_top TO it_top.
      CLEAR wa_top.
    
      wa_top-typ = 'S'.
      wa_top-key = 'Reconcilliation Statement From'.
      wa_top-info = lv_date.
      APPEND wa_top TO it_top.
      CLEAR wa_top.
    
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
         it_list_commentary       = it_top.
    ENDFORM.                    "top
    

     

    Hope this helps you.

     

    Regards,

    Tarun

  • Re: Top-of-page in Alv Grid
    Sarbajit Majumdar
    Currently Being Moderated

    i_callback_top_of_page             = 'TOP_OF_PAGE'

    of the FM 'REUSE_ALV_GRID_DISPLAY'

     

    then

    FORM top_of_page.

     

      DATA: l_header TYPE slis_t_listheader,

            l_wa     TYPE slis_listheader.

     

      l_wa-typ = 'S'.

    WRITE BUDAT-LOW DD/MM/YYYY TO DATE1.

    WRITE BUDAT-HIGH DD/MM/YYYY TO DATE2.

    **

     

     

    CONCATENATE IT_FINAL-NAME1 'Reconcilliation Statement From'

    DATE1 'TO' DATE2

    INTO TITLE SEPARATED BY SPACE .

    write title to  l_wa-info .

     

      APPEND l_wa TO l_header.

     

      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

        EXPORTING

          it_list_commentary = l_header

     

    •     i_logo             = 'SARBA_LOGO'.

    •     I_END_OF_LIST_GRID       =

    •     I_ALV_FORM               =

    ENDFORM.                    "top_of_page

  • Re: Top-of-page in Alv Grid
    Mohammad MahaboobKhan
    Currently Being Moderated

    hi,

     

    Total lenght should be less than equal to 72 char.

    other wise it goes dump.

     

     

     

     

    Regards

    Md.MahaboobKhan

  • Re: Top-of-page in Alv Grid
    Joan Jesudasan
    Currently Being Moderated

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

        EXPORTING

          i_callback_program = v_repid

          is_layout          = gs_layout

          it_fieldcat        = i_fieldcat[]

          it_events          = i_event[]

          it_sort            = i_sort[]

          i_save             = 'A'

        TABLES

          t_outtab           = i_final_1

        EXCEPTIONS

          program_error      = 1

          OTHERS             = 2.

     

     

    FORM top_of_page.    

     

    Write : /5   TITLE1.

                                        

    ENDFORM.                

     

    FORM f_build_eventtab  USING   ps_event TYPE slis_t_event.

      DATA: wa_event TYPE slis_alv_event.

     

      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

        EXPORTING

          i_list_type = 0

        IMPORTING

          et_events   = ps_event.

     

      READ TABLE ps_event WITH KEY name = slis_ev_top_of_page INTO wa_event.

      IF sy-subrc EQ 0.

        MOVE slis_ev_top_of_page TO wa_event-form.

        APPEND wa_event TO ps_event.

      ENDIF.

    ENDFORM.                   

     

    Regards,

    Joan

  • Re: Top-of-page in Alv Grid
    Suhas Saha
    Currently Being Moderated

    Hello,

     

    You have to use the parameter I_CALLBACK_HTML_TOP_OF_PAGE for this purpose. Please refer to this [link|ALV Top-of-Page; for details.

     

    BR,

    Suhas

Actions