Alv grid error

hi all,
I have simple issue in alv grid,
I have designed an alv grid, by default it has scroll bars.
when i scroll the alv grid, the last executed status message (ie in pai) is executed on every page and the message shows in
the status bar on every scroll...
how can i avoid this .
thanks and regards
Jose

Hi Jijo,
           Declare a flag variable ..
DATA: GV_FLAG TYPE C.
then put this folowing pseudo code and it will work..
IF GV_FLAG IS INITAL.
MESSAGE 'XSYZ'.
GV_FLAG = 'X'.
ENDIF.
Then what it will do is the status message when it is displayed for first time the Flag is set to ''X' and as the flag is set once the code will not execute again to show the message.
Regards,
Raghav

Similar Messages

  • Filter in web dynpro ALV grid error

    The filter in the ALV web dynpro seems to work like *<condition>*. let's say if you have 4 entries in the table 30,230,300,1230 applying the filter value '30' will select all of them making the filter function virtually useless.
    Is there a way to change how the filter works?

    Dear Stanley,
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/63a47dd9-0b01-0010-3d8e-de27242bf011
    Regards,
    Flavya

  • Allow to erase values under the input-check of the ALV Grid Control

    Hi,<br />
    in my ALV Grid I do have a cell which automatically checks the values entered by the user. When the user does not enter the values belonging to the DDIC Domain Value Range of the data element, the cell is rendered with a red border and an ALV error message comes up telling the user to enter the correct values from the F4 help.
    In general, this is really great, but in case the user needs to erase the value, this automatical ALV Grid error message keeps popping up asking him to enter at least one value from the value range.
    (I assume this is due to the fact that the Domain value range does not contain the value 'empty'.)
    <br />
    I would like to keep the functionality of checking the entered value but want to switch off the error message in case nothing was entered. How can I achive this?
    <br /> <br />
    This is what I did so far: <br />
    1. Upon initializing ALV Grid, I define the field catalog like this: <br />
    ls_fieldcat-fieldname = 'REACTION'.                       "#EC NOTEXT <br />
      ls_fieldcat-edit       = abap_true. <br />
      ls_fieldcat-coltext   = 'Reaction'.                       "#EC NOTEXT <br />
      ls_fieldcat-outputlen = '8'.                              "#EC NOTEXT  <br />
    <br />
    * This forces the user to set at least one value; not allowing him to delete it!! <br />
      ls_fieldcat-ref_table = 'CRMS_ES_FOREIGN_ATTRIBUTE'.      "#EC NOTEXT <br />
      ls_fieldcat-ref_field =  'REACTION'. <br />
      ls_fieldcat-key = abap_true. <br />
    <br />
      ls_fieldcat-checktable = '!'. <br />
      ls_fieldcat-f4availabl  = 'X'. "shows the handle for F4 help <br />
      ls_fieldcat-col_id = 7.
    <br />
    (I would assume here that the ls_fieldcat - structure would allow an additional field which allows empty values, but I could not find one!) <br />
    <br />
    2. For my ALV Grid instance, I am registering the F4 during initialization:<br />
    call method gr_fkt_grid->register_f4_for_fields <br />
            exporting <br />
              it_f4 = lt_f4. <br />
    <br />
          ls_f4-fieldname  = 'REACTION'.   "EC SYNTCHAR <br />
          ls_f4-register   = abap_true. <br />
          insert ls_f4 into table lt_f4. <br />
          call method gr_fkt_grid->register_f4_for_fields <br />
            exporting <br />
              it_f4 = lt_f4. <br />
    <br /> <br />
    3. Then I am setting the handler while initializing: <br />
          set handler lr_grid_event_receiver->handle_f4 <br />
          for all instances. <br />
    <br /> <br />
    4. I also have checking methods in PAI for the ALV cells, but they do not apply in this case, <br />
        since ALV itself performs this check described above. I cannot see a chance for <br />
        interfering myself in PAI. <br />
    <br />
    Does anyone have an idea how I could prevent the ALV Grid of bringing up the message "Enter a valid value" and <br />
    allowing to delete the cell content while keeping its checks in case the user enters a wrong value? <br />
    <br />
    Thank you very much,<br />
    regards,<br />
    Konrad<br />

    Hi Konrad,
    Inside the handler method for event DATA_CHANGED,  always suppress the error log by calling method activate_display_protocol with dialog = ''.
    Whenever u need error log call  method display_protocol based on ok_code(sy-ucomm).
    Ex:
    method data_changed.  " Handler method for event 'DATA_CHANGED'
    *Suppressing error log
        call method g_o_grid->activate_display_protocol        "  Always suppress error log when grid is changed
          exporting
            i_dialog = ''.
        if er_data_changed->mt_protocol[] is not initial.
          if ok_code = 'BACK' or ok_code = 'SAVE'.      "  Based  on  ok_code display error log
    *Display error log
            call method er_data_changed->display_protocol.
          endif.
        endif.
      endmethod.                    "data_changed
    Might solve ur problem
    Thanks,
    Edited by: Sap Fan on Oct 14, 2009 5:35 AM

  • Error when double clicking any field in Alv grid

    Hi All,
    I have created a custom container. To that custom container I am displaying an alv grid with all editable fields using oops concept.
    Hence when I am double clicking on any on the field of the table I am getting a dump " an exception condition ERROR raised in CL_GUI_ALV_GRID_BASE  in method SET_DRAG_DROP_ROWS".
    Kindly help

    Hi,
    Check the PF-STATUS. It seems that you have assigned F6 shortcut key for some event.
    Remove the F6 assignment & activate the pf-status.
    Best regards,
    Prashant

  • Runtime error while trying to execute custom F4 help in OOP ALV grid.

    Dear All,
    I am trying to add custom search help for one of my column in ALV grid. I'm using OOP ALV, when i click for search help for that column, the system shows runtime error like below.
    I am new to OOP concept and tried to follow program BCALV_EDIT_03. But not getting this error occur. Please help me.
    With regards.

    Hi,
    In order to be able to provide a search help for a field in an ALV you must do the following things.
    1) The field where F4 help need to be attached needs to be made editable.
    2) Create an event handler class to handle the ONF4 event. You can refer the following code:
        CLASS lcl_alv1_handler DEFINITION.
        PUBLIC SECTION.
           "Tohandle F4 helps
           METHODS handle_f4 FOR EVENT onf4 OF cl_gui_alv_grid
                   IMPORTING e_fieldname e_fieldvalue es_row_no er_event_data
                             et_bad_cells e_display.
        ENDCLASS.
       CLASS lcl_alv1_handler IMPLEMENTATION.
          METHOD handle_f4.
    CASE e_fieldname.
         WHEN 'LIFNR'.               "Set F4 for courier vendor
             SELECT lifnr name1 FROM lfa1 INTO TABLE lt_lifnr.
           IF lt_lifnr IS NOT INITIAL.
             CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
               EXPORTING
                 retfield           = 'LIFNR'
                 window_title   = 'Vendors'
                 value_org       = 'S'
               TABLES
                 value_tab       = lt_lifnr
                 return_tab      = lt_return
               EXCEPTIONS
                 parameter_error = 1
                 no_values_found = 2
                 OTHERS          = 3.
             IF sy-subrc = 0.
               READ TABLE gt_final INTO wa_final_t INDEX es_row_no-row_id.
               IF sy-subrc = 0.
                 READ TABLE lt_return INTO wa_return INDEX 1.
                 IF sy-subrc = 0.
                   CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
                     EXPORTING
                       input  = wa_return-fieldval
                     IMPORTING
                       output = lv_lifnr.
                   wa_final_t-lifnr  = lv_lifnr.
                   MODIFY gt_final FROM wa_final_t INDEX es_row_no-row_id.
                 ENDIF.
               ENDIF.
             ENDIF.
           ENDIF.
          ENDCASE.
             CALL METHOD o_alv->refresh_table_display.
          ENDMETHOD.
       ENDCLASS.
        In the above method, GT_FINAL-LIFNR is being overwritten by the LIFNR you had selected       from F4 help. So we will call the refresh_table_display after it to see the result in the ALV.
    3) After creating the ALV object, add the fields to which the F4 has to be added. For this you
        need to declare an internal table based on  lvc_t_f4. Use the following code. Here O_ALV is    my ALV object.:
       CREATE OBJECT o_container
           EXPORTING
             container_name              = 'CUSTCON'
           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.
         CREATE OBJECT o_alv
           EXPORTING
             i_parent          = o_container
           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.
       CLEAR : gt_f4, wa_f4.
       wa_f4-fieldname   = 'LIFNR'.
       wa_f4-register    = 'X'.
       wa_f4-getbefore   = space.
       wa_f4-chngeafter  = space.
       APPEND wa_f4 TO gt_f4.
       Here I am assigning F4 to LIFNR field in the final internal table that is displayed using ALV.
       After this register this field for F4.
        CALL METHOD o_alv->register_f4_for_fields
           EXPORTING
              it_f4 = gt_f4.
       CREATE OBJECT o_alv_handler.
       SET HANDLER : o_alv_handler->handle_f4 FOR o_alv1.
       The object o_alv_handler is created based on the event handler class.
    I hope that this will solve your issue. Revert if this is solved.
    Rgards,
    Abijith

  • Run-time error while executing alv grid report

    Hi everyone
    I m trying to run a alv grid report it is giving a run time error while executing the statement CALL METHOD V_ALV->SET_TOOLBAR_INTERACTIVE.
    Actually i added 2 buttons in the toolbar.after that when i execute the report i m getting errors.
    <b>Error Analysis</b>
    An exception occurred that is explained in detail below.                     
    The exception, which is assigned to class 'CX_SY_REF_IS_INITIAL', was not    
    caught in                                                                   
    procedure "TOOLBAR_MENUS_INIT" "(METHOD)", nor was it propagated by a RAISING
    clause.                                                                     
    Since the caller of the procedure could not have anticipated that the        
    exception would occur, the current program is terminated.                    
    The reason for the exception is:                                             
    You attempted to use a 'NULL' object reference (points to 'nothing')         
    access a component (variable: "ME->M_CL_MENU_BUTTON_VARIANT").               
    An object reference must point to an object (an instance of a class)         
    before it can be used to access components.                                  
    Either the reference was never set or it was set to 'NULL' using the         
    CLEAR statement.

    Hi Dinesh,
    Seems you have not initialised ( Instantiated in OO ) the object and / or the parent container.
    Check if you have create object for both the parent as well as the alv object.
    So when you instatntiate the object of ALV you pass the object ( instantiated before hand ) in the parent container position.
    Also you would have to register the events to the object using method. Then only the buttons will finction.
    eg :
    IF G_CUSTOM_CONTAINER IS INITIAL.
        CREATE OBJECT CUSTOM_CONTAINER_1
               EXPORTING CONTAINER_NAME = CONTAINER_1.
        CREATE OBJECT GRID1
               EXPORTING I_PARENT = CUSTOM_CONTAINER_1.
        CALL METHOD ALV_GRID1->SET_TABLE_FOR_FIRST_DISPLAY
             EXPORTING I_STRUCTURE_NAME = 'VBAK
             CHANGING  IT_OUTTAB        = IT_VBAK.
    Reward points if useful.

  • Display error message in ALV grid  using OOPS

    Hi,
    I have a requirement to display report in ALV. I have created ALV grid using OOPS with three editable cells and 1 button on toolbar. When user enter values in Ediatble cell  and click on the Toolbar button, sales order item should be assigned to contract.
    When the user select  the row and click on toolbar button, a salesorder item should be assigned  to contract and i am using BAPI and fine with BAPI. All the error message should be displayed in a popup and the corresponding failed row  should change its color .
    Once the user identified the failed row, he can edit the value in the ediatble cells and should reprocess in the same screen ( without going back to selection screen).
    To display POP Up, I  am using FM BAL_LOG_CREATE, BAL_LOG_MSG_ADD, BAL_DSP_PROFILE_NO_TREE_GET, BAL_CNTL_CREATE.
    by using above 4 FM , i can display POP UP. but i cannot change the color of the failed row. 
    Once I identified the failed row and reprocess from the same screen , I am successful in processing the failed row, but my error log still has the reprocessed row as failed row because,  error log is not refreshing.
    Please suggest me how to clear error log which was created by using the above FM's and change the color of the failed row .
    Thanks in Advance

    Hi
    Please suggest me how to clear error log which was created by using the above FM's....
    U can use BAL_LOG_REFRESH
    ....and change the color of the failed row
    You need to insert a new field for Colour Attributes in your output table and input its name in the layout structure:
    IS_LAYOUT-INFO_FNAME = <field name for colour>
    The field has to be a CHAR 3 and its value can be -
    > Cxy
    C is a constant
    x is the colour number (from 1 to 9)
    y is intensified (0 = off, 1 = on)
    After changing the value of output table you need to run the method REFRESH_TABLE_DISPLAY for refreshing the output
    Max

  • Error in field catalog in ALV grid display using classes at do_sum = "X'.

    Hi,
    I'm using classes in ALV Grid display.
    the code for the field catalog is going to dump because of the statement in the field catalog for field 'netwr',do_sum = 'X'.
    that do_sum = 'X' is not working and going to dump when executed.with out that do_sum it is working fine. the error in dump analysys is showing sap standard incude LSLVCF01.
        assign component
               <ls_fieldcat>-fieldname of structure rt_data to <g_field>.
        if sy-subrc ne 0.
          message x000(0k).
        endif.
    sy-subrc is 4 when the program is being executed.
    CODE:
    FORM prepare_field_catalog CHANGING pt_fieldcat TYPE lvc_t_fcat.
      DATA ls_fcat TYPE lvc_s_fcat.
      ls_fcat-fieldname = 'VBELN1'.
      ls_fcat-ref_field = 'VBELN'.
      ls_fcat-ref_table = 'VBRK'.
      ls_fcat-coltext = 'Invoice No'.
      ls_fcat-seltext = 'Invoice No'.
      APPEND ls_fcat TO pt_fieldcat.
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'BUDAT'.
      ls_fcat-ref_table = 'BKPF'.
      ls_fcat-coltext = 'Invoice Date'.
      ls_fcat-seltext = 'Invoice Date'.
      APPEND ls_fcat TO pt_fieldcat.
      CLEAR ls_fcat.
    ls_fcat-fieldname = 'NETWR'.
      ls_fcat-ref_field = 'NETWR'.
      ls_fcat-ref_table = 'VBRK'.
      ls_fcat-coltext = 'Value of Invoice'.
      ls_fcat-seltext = 'Value of Invoice'.
      ls_fcat-datatype = 'CURR'.
      ls_fcat-do_sum = 'X'.
      APPEND ls_fcat TO pt_fieldcat.
      CLEAR ls_fcat.
    ENDFORM.
    can u please look in the code and rectify the error,
    would appeciate ur response.
    regards,
    veera.

    Hi,
    try this..
    ls_fcat-fieldname = 'NETWR'.
    ls_fcat-ref_field = 'NETWR'.
    ls_fcat-ref_table = 'VBRK'.
    ls_fcat-coltext = 'Value of Invoice'.
    ls_fcat-seltext = 'Value of Invoice'.
    ls_fcat-datatype = 'CURR'.
    ls_fcat-do_sum = 'X'.
    <b>ls_fcat-cfieldname = 'WAERS'.</b>
    APPEND ls_fcat TO pt_fieldcat.
    CLEAR ls_fcat.
    Regards
    vijay

  • Error While ALV Grid is exported to Excel.

    Hi Experts,
    I get an error OBJECTS_NOT_CHARLIKE , while I try to download an ALV Grid , to an excel file using the standard icon Export  present on the ALV Grid.
    Regards.
    Edited by: sunitha j on May 19, 2009 1:15 PM

    This happens when your output list contains qty. or amount fields.
    To fix the error use sap table name instead of your internal table name while preparing field catalog.
    In case you are forced to use int. table name while preparing field catalog , add "quantity" field for qty figures and "currency" field for amount figures.
    Example :
    it_catalog-fieldname = 'MENGE'.
    it_catalog-quantity = 'NOS'.
    it_catalog-tabname = 'i_bseg'.
    it_catalog-seltext_s = 'Quantity'.
    APPEND it_catalog TO it_fieldcat.
    it_catalog-fieldname = 'DMBTR'.
    it_catalog-tabname = 'i_bseg'.
    it_catalog-seltext_s = 'Amount'.
    it_catalog-currency = 'INR'.
    APPEND it_catalog TO it_fieldcat.

  • CL_SALV_BS_TT_RESULT_TABLE====CP error while downloading data from ALV grid

    Hi ,
    I am  facing a problem when ever i am going to donload data from ALV grid to excel file.I am getting CL_SALV_BS_TT_RESULT_TABLE====CP error in GET_CELL_VALUE. Could you please provide me is there any OSS note or any patch required to solve this issue.
    Thanks in Advance,
    Venkatarao.

    Hi,
    Just refer to OSS note 1356898 for guidelines.
    Regards,
    Vasanth

  • Error in clicking save to local file button in alv grid?

    Hi
    I am getting error , While clicking on some buttons like save as local file button in alv grid display
    How to rectify it
    Thanks in advance

    In your REUSE_ALV_GRID_DISPLAY 
    EXPORTING
          I_SAVE                  = 'U'
    put this field....and then check it will definitely work...

  • Error in clicking save to local file button in alv grid? urgent

    >>>>>       if lr_tabledescr->applies_to_data( <coltab_any> ) eq 'X'. 
    exactly i am getting error here
    how to rectify this error
    Error in clicking save to local file button and mail receipt button in alv grid?

    In your REUSE_ALV_GRID_DISPLAY 
    EXPORTING
          I_SAVE                  = 'U'
    put this field....and then check it will definitely work...

  • ALV Grid OO Error

    Hi Guys,
    When i am executing the program for ALV grid using OO concepts i got thisn type of error
    "Short text
    Access via 'NULL' object reference not possible.
    What happened?
    Error in the ABAP Application Program
    The current ABAP program "Z_TEST_PGM" had to be terminated because it has
    come across a statement that unfortunately cannot be executed.
    Error analysis
    An exception occurred that is explained in detail below.
    The exception, which is assigned to class 'CX_SY_REF_IS_INITIAL', was not
    caught in
    procedure "ALVGRID_OO_DISPLAY" "(FORM)", nor was it propagated by a RAISING
    clause.
    Since the caller of the procedure could not have anticipated that the
    exception would occur, the current program is terminated.
    The reason for the exception is:
    You attempted to use a 'NULL' object reference (points to 'nothing')
    access a component (variable: "GRID").
    An object reference must point to an object (an instance of a class)
    before it can be used to access components.
    Either the reference was never set or it was set to 'NULL' using the
    CLEAR statement."
    The code for this one is .
    Data : grid type ref to cl_gui_alv_grid,
    g_custom_container type ref to cl_gui_custom_container,
    FCAT TYPE LVC_T_FCAT,
    gt_final1 type table of t_Final_out.
    Initialization.
    v_repid = sy-repid.
    set screen '101'.
    MODULE STATUS_0101 output.
    if g_custom_container is initial .
    create object g_custom_container
    Exporting
    Container_name = 'CCCONTAINER'.
    Create Object grid
    Exporting
    I_Parent = g_custom_container.
    Endif.
    CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
    EXPORTING
    I_STRUCTURE_NAME = 't_final_out'
    CHANGING
    CT_FIELDCAT = FCAT[].
    ENDMODULE.
    Perform ALVGRID_OO_Display.
    Form ALVGRID_OO_Display.
    *set screen '101'.
    Call Method grid->set_table_for_first_display
    Exporting I_Structure_name = 't_final_out'
    Changing it_outtab = gt_final1.
    Endform.
    't_final_out' is the final output Structure of the Internal table.
    Please respond to this thread.
    Thanks,
    Gopi

    t_final_out is a local structure do n't give this structure create a global structure in se11 with the fields used and pass that structure to FM  'LVC_FIELDCATALOG_MERGE'. this will sove your problem.
    <b>if helpful reward some points.</b>

  • Time out error in production server  for alv grid report

    hi. i have developed alv grid report using nested select statments. when i testing in development  server it is giving the output but in production server if i give 4 months then it is showing time out error.please help me out..its urgent.
    Thanks in advance.

    Hi Manu,
    Don't use Nested selected statements.
    Use the Following  Performance Tuning Options that i have given below so that your problem can be solved.
    1)  Always check the driver internal tables is not empty, while using FOR ALL ENTRIES
    2) Avoid for all entries in JOINS
    3) Try to avoid joins and use FOR ALL ENTRIES.
    4)   Try to restrict the joins to 1 level only ie only for tables
    5)   Avoid using Select *.
    6)   Avoid having multiple Selects from the same table in the same object.
    7)  Try to minimize the number of variables to save memory.  
    8)   The sequence of fields in 'where clause' must be as per primary/secondary index ( if any)
    9)   Avoid creation of  index as far as possible
    10) Avoid operators like  <>, > , < & like % in where clause conditions
    11) Avoid select/select single statements in loops.
    12) Try to use 'binary search' in READ internal table. Ensure table is sorted before using   BINARY SEARCH.
    13) Avoid using aggregate functions  (SUM, MAX etc) in selects ( GROUP BY , HAVING,)  
    14) Avoid using  ORDER  BY in selects
    15) Avoid Nested Selects
    16) Avoid Nested Loops of Internal Tables
    17) Try  to  use FIELD SYMBOLS.
    18) Try to avoid into Corresponding Fields of
    19) Avoid using Select  Distinct, Use DELETE ADJACENT
    <b>
    Reward Points for sure if you find it useful. </b>
    Regards
    Babu

  • Control Framework: Fatal error - GUI cannot be reached-ALV Grid in Bckgrnd

    I have an ALV grid which dumps in the background. But works fine in the foreground.
    I thought I am not using Control framework anywhere. But I get 'COntrol framework :Fatal error - GU cannot be reached' error.
    I am using a docking container that I have split using a splitter.
    I have no custom container in my screen. What else could be causing the Control framework error ? Any suggestions is appreciated. But please do not tell me to use 'REUSE_ALV*' or Classical reporting
    Here are the PBO modules of my screen and here are my data declarations.
    ALV Data declarations :
    data :gt_sort type lvc_t_sort,
            gr_event_handler TYPE REF TO lcl_event_handler ,
         o_docking type ref to cl_gui_docking_container,"Docking Container
         o_grid type ref to cl_gui_alv_grid,"Grid
         o_split type ref to cl_gui_easy_splitter_container,"Splitter
         o_top_container type ref to cl_gui_container,   "Top Container
         o_bottom_container type ref to cl_gui_container,"Bottom Container
         o_document type ref to cl_dd_document.          "Document
    module status_0100 output.
    if o_docking is initial.
      set pf-status 'ZSTATUS_0100'.
      set titlebar 'ZTITLE_0100'.
    Creating Objects
      perform create_objects.
    Filling top of page
      perform fill_top_of_page.
    Filling the fieldcatalog table
    perform build_fieldcat. "we already got'em
    Displaying the output
      perform display_output.
    endif.
    Here is the Form Create_objects called in the PBO.
    form create_objects .
    Creating Docking Container
      CREATE OBJECT o_docking
             EXPORTING
               RATIO                       = '95'.
      IF sy-subrc eq 0.
    Splitting the Docking container
        CREATE OBJECT o_split
          EXPORTING
           PARENT            = o_docking
           sash_position     = 25 "Position of Splitter Bar (in Percent)
           with_border       = 0. "With Border = 1 Without Border = 0
      Placing the containers in the splitter
        o_top_container = o_split->top_left_container .
        o_bottom_container = o_split->bottom_right_container .
      Creating Grid
        CREATE OBJECT o_grid
          EXPORTING
            i_parent          =  o_bottom_container.
      Creating the document
        CREATE OBJECT o_document
        EXPORTING
            style  = 'ALV_GRID'.
         CREATE OBJECT gr_event_handler .
      ENDIF.
    endform.                    " create_objects
    form fill_top_of_page .
    data : lv_char(255) type c.
    Calling the methods for dynamic text
       CALL METHOD o_document->add_gap
        EXPORTING
          width      = 140.
      CALL METHOD o_document->add_text
        EXPORTING
          text          = 'Plant Attainment Report '
          sap_fontsize  = 'Large'
          sap_color     = cl_dd_area=>list_key_int
          sap_emphasis  = cl_dd_area=>strong. " For bold
    Display the data
      CALL METHOD o_document->display_document
        EXPORTING
           parent             = o_top_container.
    Calling the method of ALV to process top of page
      CALL METHOD o_grid->list_processing_events
        EXPORTING
          i_event_name      = 'TOP_OF_PAGE'
          i_dyndoc_id       = o_document.
    endform.                    " fill_top_of_page
    form display_output .
      gx_variant-report = sy-repid.
      gs_layout-zebra = 'X'.
      gs_layout-sel_mode ='X'.
      gs_layout-cwidth_opt = 'X'.
      call method o_grid->set_table_for_first_display
        exporting
          is_variant      = gx_variant
          i_save          = 'A'
          is_layout       = gs_layout
        changing
          it_fieldcatalog = it_fldcat
          it_outtab       = <gt_tabletotal>.
        IF sy-subrc <> 0.
           MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                       WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
        SET HANDLER gr_event_handler->handle_print_top_of_page FOR o_grid .
    endform.                    " display_output 
    Edited by: Shareen Hegde on Jul 23, 2009 5:03 PM (I have no clue why 
    .. doesn't work anymore. My code looks messed up..Sorry folks!

    Nilesh,
    If i put all these create objects inside the      IF CL_GUI_ALV_GRID=>OFFLINE( ) IS INITIAL.   ENDIF , will I be still able to use ,
    call method o_grid->set_table_for_first_display
        exporting
          is_variant      = gx_variant
          i_save          = 'A'
          is_layout       = gs_layout
        changing
          it_fieldcatalog = it_fldcat
          it_outtab       = <gt_tabletotal>.
         in background ? WIll I not get - OBJECTS_OBJREF_NOT_ASSIGNED   erorr ?
    How can I call the set_table_for_first_display without creating the object reference ?
    Here is my creat object routine.
    form create_objects .
    * Creating Docking Container
    IF CL_GUI_ALV_GRID=>OFFLINE( ) .
      CREATE OBJECT o_docking
             EXPORTING
               RATIO                       = '95'.
      IF sy-subrc eq 0.
    * Splitting the Docking container
        CREATE OBJECT o_split
          EXPORTING
           PARENT            = o_docking
           sash_position     = 25 "Position of Splitter Bar (in Percent)
           with_border       = 0. "With Border = 1 Without Border = 0
    *   Placing the containers in the splitter
        o_top_container = o_split->top_left_container .
        o_bottom_container = o_split->bottom_right_container .
    *   Creating Grid
        CREATE OBJECT o_grid
          EXPORTING
            i_parent          =  o_bottom_container.
    *   Creating the document
        CREATE OBJECT o_document
        EXPORTING
            style  = 'ALV_GRID'.
         ENDIF.
         CREATE OBJECT gr_event_handler .
    endif.
    endform.                    " create_objects

Maybe you are looking for