OO ALV buffer problem

Hello all,
When a workflow work item is executed, a function module is called that displays a screen.  The workitem calls a function module that displays an ALV on a screen.  The same ALV is displayed for 3 different workitems.
I am changing the field catalog based on certain criteria to set an individual field to be editable/non-editable.  I can see that the edit field in the field catalog contains the appropriate value, but the grid does not reflect what is in the field catalog.
The first workitem displays the ALV correctly.
The second and third workitems display the ALV using fieldcat values from the first workitem.  The fieldcat contains the correct values when the grid is displayed using method "set_table_for_first_display".
If I log off of SAP and log back on, the second workitem ALV displays with the correct value.  But the third workitem now display with the fieldcat values from the second workitem.
If I log off of SAP and log back on, the third workitem ALV displays with the correct value.
Any thought on what I need to do to correct this problem?
This is the logic that creates and displays the ALV in the PBO of the screen of the function module.
clear: il_fieldcat, l_layout.
  refresh: il_fieldcat.
  free: il_fieldcat.
  submit balvbufdel and return.                         " clear ALV buffer
  submit bcalv_buffer_del_shared and return. " clear ALV buffer
*            Create an instance for the event handler
  create object gr_event_handler .
*          Create an instance of the container displayed on screen 1400
  create object w_custom_container_1400
         exporting container_name = w_container_1400.
*            Create an instance of the grid displayed in the container
  create object w_grid_1400
         exporting i_parent = w_custom_container_1400.
* Build fieldcat - edit enabled.
  perform build_fieldcat_1400 changing il_fieldcat.
*         >>  call method w_alv->set_frontend_fieldcatalog  after modifying the field ctalog <<
  call method w_grid_1400->set_frontend_fieldcatalog
   exporting
      it_fieldcatalog  =   il_fieldcat.
* Disable generic ALV toolbar functions
  perform exclude_tb_functions_1400 changing lt_exclude.
*  Set layout options:
  l_layout-grid_title = 'ZFXXU003'.
  l_layout-zebra      = 'X'.
  l_layout-edit_mode  = 'X'.  
  set handler gr_event_handler->handle_user_command for w_grid_1400 .
  set handler gr_event_handler->handle_toolbar      for w_grid_1400 .
  set handler gr_event_handler->handle_menu_button  for w_grid_1400 .
  set handler gr_event_handler->handle_data_changed for w_grid_1400 .
  data: w_is_variant type disvariant.
  w_is_variant-report = sy-cprog.
  w_is_variant-variant = '/DEFAULT'.
  call method w_grid_1400->set_table_for_first_display
    exporting
      i_buffer_active      = 'X'
      i_bypassing_buffer   = 'X'
      is_layout            = l_layout
      it_toolbar_excluding = lt_exclude
      i_save               = 'A'       " enable save option
      is_variant           = w_is_variant
    changing
      it_fieldcatalog      = il_fieldcat
      it_outtab            = il_outtab.
* set editable cells to ready for input
  call method w_grid_1400->set_ready_for_input
    exporting
      i_ready_for_input = 1.
* Register ENTER to raise event DATA_CHANGED.
  call method w_grid_1400->register_edit_event
    exporting
      i_event_id = cl_gui_alv_grid=>mc_evt_enter.
  create object w_event_receiver_1400.
  set handler w_event_receiver_1400->handle_data_changed
              for w_grid_1400.
Edited by: Bruce Tjosvold on Dec 8, 2010 4:21 PM
Edited by: Bruce Tjosvold on Dec 8, 2010 4:24 PM
Edited by: Bruce Tjosvold on Dec 8, 2010 5:04 PM

Hi Bruce,
You should avoid the creation of the ALV everytime that you need to change the fieldcatalog by calling the method "set_table_for_first_display". Instead, you should call the "refresh_table_display" method.
Regarding the code that you provide to us, it should be something like this:
if ...
* Build fieldcat - edit enabled.
  perform build_fieldcat_1400 changing il_fieldcat.
call method w_grid_1400->set_table_for_first_display
    exporting
      i_buffer_active      = 'X'
      i_bypassing_buffer   = 'X'
      is_layout            = l_layout
      it_toolbar_excluding = lt_exclude
      i_save               = 'A'       " enable save option
      is_variant           = w_is_variant
    changing
      *it_fieldcatalog      = il_fieldcat* "Here you are specifying your first catalog
      it_outtab            = il_outtab.
else.
   call method w_grid_1400->refresh_table_display
*     EXPORTING
*     IS_STABLE =
*     I_SOFT_REFRESH =
     EXCEPTIONS
      finished = 1
      OTHERS = 2 .
endif.
If you want at this point change the catalog, you should modify the values of it_fieldcat and update it on the existing ALV
  call method w_grid_1400->set_frontend_fieldcatalog
   exporting
      it_fieldcatalog  =   il_fieldcat.
Best regards,
Eric

Similar Messages

  • Re-executing a function in IP web: buffer problem

    Hello everybody,
    we have performed 2 changes to our application:
    1. for performance reasons we replaced a FOX function with an IP exit function and
    2. to limit the number of entires appearing in F4 (000's) in the web application when selecting mater data for filtering we inserted a new InfoObject for the selection with only a few (about 10) master data entries and then passed the variable values to the original infoobject
    Both changes work well but there is a nasty side effect.
    The INITIAL execution of the query (variable pop-up) and filtering in the web application works fine. The user enters data manually and executes a function performing some caluculations (was FOX, is now an IP exit function).
    After this initial execution of the function it is not possible to re-execute the function. If e.g. the user performs a few more manual changes and then tries to execute the function again nothing happens. Only be logging off and on again (i.e. a new session) the user can execute the function again.
    Cache mode for the query (in RSRT) is set to 0 (=inactive).
    It is obviously a  buffer problem (some sort of delta/plan buffer conflict) and I have had this before but I cannot recall how to solve it ... its the age!
    Grateful for any assistance
    Edited by: Martin Helmstein on Nov 10, 2010 11:07 AM
    Clarification: if the user repeats inputting data under the INITIAL filter selection state and executes the function again it works. The problem only occurs if the user changes the filters (drop down boxes in the web application), inputs data and attempts to execute the function with this new selection.

    Hi Martin,
    One easy way of solving is to include the WAD command TRANSFER_STATE at the end of all the Planning function / Sequence commands attached to the Button.
    This will refresh the WAD layout without having to reenter the variable values if any.
    The other Option is to reset all the variables associated with the execution of Planning function after every execution.
    This can be included under Web template Properties so this happens after every refresh of the layout.
    Hope this helps.
    Regards.
    Shafi.

  • Alv report problem

    hi,
    i have problem in ALV.
    my requirement is in a ALV report if i double click on a row it has to take me to another transaction ( say for eg vf03).
    how should i do it.
    john.

    hi
    good
    try this report
    MESSAGE-ID ZZ_9838                      .
    TYPE-POOLS: SLIS.
    *type declaration for values from ekko
    TYPES: BEGIN OF I_EKKO,
           EBELN LIKE EKKO-EBELN,
           AEDAT LIKE EKKO-AEDAT,
           BUKRS LIKE EKKO-BUKRS,
           BSART LIKE EKKO-BSART,
           LIFNR LIKE EKKO-LIFNR,
           END OF I_EKKO.
    DATA: IT_EKKO TYPE STANDARD TABLE OF I_EKKO INITIAL SIZE 0,
          WA_EKKO TYPE I_EKKO.
    *type declaration for values from ekpo
    TYPES: BEGIN OF I_EKPO,
           EBELN LIKE EKPO-EBELN,
           EBELP LIKE EKPO-EBELP,
           MATNR LIKE EKPO-MATNR,
           MENGE LIKE EKPO-MENGE,
           MEINS LIKE EKPO-MEINS,
           NETPR LIKE EKPO-NETPR,
           END OF I_EKPO.
    DATA: IT_EKPO TYPE STANDARD TABLE OF I_EKPO INITIAL SIZE 0,
          WA_EKPO TYPE I_EKPO .
    *variable for Report ID
    DATA: V_REPID LIKE SY-REPID .
    *declaration for fieldcatalog
    DATA: I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
          WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
    DATA: IT_LISTHEADER TYPE SLIS_T_LISTHEADER.
    declaration for events table where user comand or set PF status will
    be defined
    DATA: V_EVENTS TYPE SLIS_T_EVENT,
          WA_EVENT TYPE SLIS_ALV_EVENT.
    declartion for layout
    DATA: ALV_LAYOUT TYPE SLIS_LAYOUT_ALV.
    declaration for variant(type of display we want)
    DATA: I_VARIANT TYPE DISVARIANT,
          I_VARIANT1 TYPE DISVARIANT,
          I_SAVE(1) TYPE C.
    *PARAMETERS : p_var TYPE disvariant-variant.
    *Title displayed when the alv list is displayed
    DATA:  I_TITLE_EKKO TYPE LVC_TITLE VALUE 'FIRST LIST DISPLAYED'.
    DATA:  I_TITLE_EKPO TYPE LVC_TITLE VALUE 'SECONDRY LIST DISPLAYED'.
    INITIALIZATION.
      V_REPID = SY-REPID.
      PERFORM BUILD_FIELDCATLOG.
      PERFORM EVENT_CALL.
      PERFORM POPULATE_EVENT.
    START-OF-SELECTION.
      PERFORM DATA_RETRIEVAL.
      PERFORM BUILD_LISTHEADER USING IT_LISTHEADER.
      PERFORM DISPLAY_ALV_REPORT.
    *&      Form  BUILD_FIELDCATLOG
          Fieldcatalog has all the field details from ekko
    FORM BUILD_FIELDCATLOG.
      WA_FIELDCAT-TABNAME = 'IT_EKKO'.
      WA_FIELDCAT-FIELDNAME = 'EBELN'.
      WA_FIELDCAT-SELTEXT_M = 'PO NO.'.
      APPEND WA_FIELDCAT TO I_FIELDCAT.
      CLEAR WA_FIELDCAT.
      WA_FIELDCAT-TABNAME = 'IT_EKKO'.
      WA_FIELDCAT-FIELDNAME = 'AEDAT'.
      WA_FIELDCAT-SELTEXT_M = 'DATE.'.
      APPEND WA_FIELDCAT TO I_FIELDCAT.
      CLEAR WA_FIELDCAT.
      WA_FIELDCAT-TABNAME = 'IT_EKKO'.
      WA_FIELDCAT-FIELDNAME = 'BUKRS'.
      WA_FIELDCAT-SELTEXT_M = 'COMPANY CODE'.
      APPEND WA_FIELDCAT TO I_FIELDCAT.
      CLEAR WA_FIELDCAT.
    WA_FIELDCAT-TABNAME = 'IT_EKKO'.
      WA_FIELDCAT-FIELDNAME = 'BUKRS'.
      WA_FIELDCAT-SELTEXT_M = 'DOCMENT TYPE'.
      APPEND WA_FIELDCAT TO I_FIELDCAT.
      CLEAR WA_FIELDCAT.
    WA_FIELDCAT-TABNAME = 'IT_EKKO'.
      WA_FIELDCAT-FIELDNAME = 'LIFNR'.
      WA_FIELDCAT-NO_OUT    = 'X'.
      WA_FIELDCAT-SELTEXT_M = 'VENDOR CODE'.
      APPEND WA_FIELDCAT TO I_FIELDCAT.
      CLEAR WA_FIELDCAT.
    ENDFORM.                    "BUILD_FIELDCATLOG
    *&      Form  EVENT_CALL
      we get all events - TOP OF PAGE or USER COMMAND in table v_events
    FORM EVENT_CALL.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
       EXPORTING
         I_LIST_TYPE           = 0
       IMPORTING
         ET_EVENTS             = V_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.
    ENDFORM.                    "EVENT_CALL
    *&      Form  POPULATE_EVENT
         Events populated for TOP OF PAGE & USER COMAND
    FORM POPULATE_EVENT.
      READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.
      IF SY-SUBRC EQ 0.
        WA_EVENT-FORM = 'TOP_OF_PAGE'.
        MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
    WA_EVENT-FORM.
      ENDIF.
      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.
      ENDIF.
    ENDFORM.                    "POPULATE_EVENT
    *&      Form  data_retrieval
      retreiving values from the database table ekko
    FORM DATA_RETRIEVAL.
      SELECT EBELN AEDAT BUKRS BSART LIFNR FROM EKKO INTO TABLE IT_EKKO.
    ENDFORM.                    "data_retrieval
    *&      Form  bUild_listheader
          text
         -->I_LISTHEADEtext
    FORM BUILD_LISTHEADER USING I_LISTHEADER TYPE SLIS_T_LISTHEADER.
      DATA HLINE TYPE SLIS_LISTHEADER.
      HLINE-INFO = 'this is my first alv pgm'.
      HLINE-TYP = 'H'.
    ENDFORM.                    "build_listheader
    *&      Form  display_alv_report
          text
    FORM DISPLAY_ALV_REPORT.
      V_REPID = SY-REPID.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
         I_CALLBACK_PROGRAM                = V_REPID
      I_CALLBACK_PF_STATUS_SET          = ' '
         I_CALLBACK_USER_COMMAND           = 'USER_COMMAND'
         I_CALLBACK_TOP_OF_PAGE            = 'TOP_OF_PAGE'
         I_GRID_TITLE                      = I_TITLE_EKKO
      I_GRID_SETTINGS                   =
      IS_LAYOUT                         = ALV_LAYOUT
         IT_FIELDCAT                       = I_FIELDCAT[]
      IT_EXCLUDING                      =
      IT_SPECIAL_GROUPS                 =
      IT_SORT                           =
      IT_FILTER                         =
      IS_SEL_HIDE                       =
        i_default                         = 'ZLAY1'
         I_SAVE                            = 'A'
        is_variant                        = i_variant
         IT_EVENTS                         = V_EVENTS
        TABLES
          T_OUTTAB                          = IT_EKKO
    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_report
    *&      Form  TOP_OF_PAGE
          text
    FORM TOP_OF_PAGE.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          IT_LIST_COMMENTARY       = IT_LISTHEADER
       i_logo                   =
       I_END_OF_LIST_GRID       =
    ENDFORM.                    "TOP_OF_PAGE
    *&      Form  USER_COMMAND
          text
         -->R_UCOMM    text
         -->,          text
         -->RS_SLEFIELDtext
    FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
    RS_SELFIELD TYPE SLIS_SELFIELD.
      CASE R_UCOMM.
        WHEN '&IC1'.
          READ TABLE IT_EKKO INTO WA_EKKO INDEX RS_SELFIELD-TABINDEX.
          PERFORM BUILD_FIELDCATLOG_EKPO.
          PERFORM EVENT_CALL_EKPO.
          PERFORM POPULATE_EVENT_EKPO.
          PERFORM DATA_RETRIEVAL_EKPO.
          PERFORM BUILD_LISTHEADER_EKPO USING IT_LISTHEADER.
          PERFORM DISPLAY_ALV_EKPO.
      ENDCASE.
    ENDFORM.                    "user_command
    *&      Form  BUILD_FIELDCATLOG_EKPO
          text
    FORM BUILD_FIELDCATLOG_EKPO.
      WA_FIELDCAT-TABNAME = 'IT_EKPO'.
      WA_FIELDCAT-FIELDNAME = 'EBELN'.
      WA_FIELDCAT-SELTEXT_M = 'PO NO.'.
      APPEND WA_FIELDCAT TO I_FIELDCAT.
      CLEAR WA_FIELDCAT.
      WA_FIELDCAT-TABNAME = 'IT_EKPO'.
      WA_FIELDCAT-FIELDNAME = 'EBELP'.
      WA_FIELDCAT-SELTEXT_M = 'LINE NO'.
      APPEND WA_FIELDCAT TO I_FIELDCAT.
      CLEAR WA_FIELDCAT.
      WA_FIELDCAT-TABNAME = 'I_EKPO'.
      WA_FIELDCAT-FIELDNAME = 'MATNR'.
      WA_FIELDCAT-SELTEXT_M = 'MATERIAL NO.'.
      APPEND WA_FIELDCAT TO I_FIELDCAT.
      CLEAR WA_FIELDCAT.
    WA_FIELDCAT-TABNAME = 'I_EKPO'.
      WA_FIELDCAT-FIELDNAME = 'MENGE'.
      WA_FIELDCAT-SELTEXT_M = 'QUANTITY'.
      APPEND WA_FIELDCAT TO I_FIELDCAT.
      CLEAR WA_FIELDCAT.
    WA_FIELDCAT-TABNAME = 'I_EKPO'.
      WA_FIELDCAT-FIELDNAME = 'MEINS'.
      WA_FIELDCAT-SELTEXT_M = 'UOM'.
      APPEND WA_FIELDCAT TO I_FIELDCAT.
      CLEAR WA_FIELDCAT.
    WA_FIELDCAT-TABNAME = 'I_EKPO'.
      WA_FIELDCAT-FIELDNAME = 'NETPR'.
      WA_FIELDCAT-SELTEXT_M = 'PRICE'.
      APPEND WA_FIELDCAT TO I_FIELDCAT.
      CLEAR WA_FIELDCAT.
    ENDFORM.                    "BUILD_FIELDCATLOG_EKPO
    *&      Form  event_call_ekpo
      we get all events - TOP OF PAGE or USER COMMAND in table v_events
    FORM EVENT_CALL_EKPO.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
       EXPORTING
         I_LIST_TYPE           = 0
       IMPORTING
         ET_EVENTS             = V_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.
    ENDFORM.                    "event_call_ekpo
    *&      Form  POPULATE_EVENT
           Events populated for TOP OF PAGE & USER COMAND
    FORM POPULATE_EVENT_EKPO.
      READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.
      IF SY-SUBRC EQ 0.
        WA_EVENT-FORM = 'TOP_OF_PAGE'.
        MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
    WA_EVENT-FORM.
      ENDIF.
      ENDFORM.                    "POPULATE_EVENT
    *&      Form  TOP_OF_PAGE
          text
    FORM F_TOP_OF_PAGE.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          IT_LIST_COMMENTARY       = IT_LISTHEADER
       i_logo                   =
       I_END_OF_LIST_GRID       =
    ENDFORM.                    "TOP_OF_PAGE
    *&      Form  USER_COMMAND
          text
         -->R_UCOMM    text
         -->,          text
         -->RS_SLEFIELDtext
    *retreiving values from the database table ekko
    FORM DATA_RETRIEVAL_EKPO.
    SELECT EBELN EBELP MATNR MENGE MEINS NETPR FROM EKPO INTO TABLE IT_EKPO.
    ENDFORM.
    FORM BUILD_LISTHEADER_EKPO USING I_LISTHEADER TYPE SLIS_T_LISTHEADER.
    DATA: HLINE1 TYPE SLIS_LISTHEADER.
    HLINE1-TYP = 'H'.
    HLINE1-INFO = 'CHECKING PGM'.
    ENDFORM.
    FORM DISPLAY_ALV_EKPO.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      I_INTERFACE_CHECK                 = ' '
      I_BYPASSING_BUFFER                = ' '
      I_BUFFER_ACTIVE                   = ' '
       I_CALLBACK_PROGRAM                = V_REPID
      I_CALLBACK_PF_STATUS_SET          = ' '
      I_CALLBACK_USER_COMMAND           = 'F_USER_COMMAND'
       I_CALLBACK_TOP_OF_PAGE            = 'TOP_OF_PAGE'
      I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
      I_CALLBACK_HTML_END_OF_LIST       = ' '
      I_STRUCTURE_NAME                  =
      I_BACKGROUND_ID                   = ' '
       I_GRID_TITLE                      = I_TITLE_EKPO
      I_GRID_SETTINGS                   =
      IS_LAYOUT                         =
       IT_FIELDCAT                       = I_FIELDCAT[]
      IT_EXCLUDING                      =
      IT_SPECIAL_GROUPS                 =
      IT_SORT                           =
      IT_FILTER                         =
      IS_SEL_HIDE                       =
      I_DEFAULT                         =
       I_SAVE                            = 'A'
      IS_VARIANT                        =
       IT_EVENTS                         = V_EVENTS
      TABLES
        T_OUTTAB                          = IT_EKPO
    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.
    implement your logic in it and i hope this will definitely work.
    thanks
    mrutyun

  • ALV GRID Problem with reading contents

    Hi there! I'm quite new with ABAP and I have some problems with the syntax of it. Maybe I should first describe my aim and then I'll show you my code.
    1. I read contents from two database tables, called 'zbc_dan_registry' and 'zbc_dan_category'.
    'zbc_dan_registry' has 2 columns: name, value.
    zbc_dan_category' has 1 column: category.
    Now I want to have an ALV Grid, that displays the contents of 'zbc_dan_registry' and one additional column with dropdown fields, where the user can select a category for each row. This is, what my code already does.
    Now I want to save the contents of the whole table in a new table 'zbc_dan_registrz' (you see: 'registrz', not 'registry'!) with 3 columns:
    name, category, value.
    My problem is, how can I read the contents of the ALV Grid, with the user selected category for each row, and save them in an internal table? I've tried to adapt the code of "BCALV_EDIT_04", but I don't get it running.
    Some detailled help would be great, you know, I'm really working hard to understand ABAP, but it's really hard for me. Thanks for your support and help!!
    Here's my code so far:
    *& Report  ZBC400_DAN_TESTNO4
    REPORT  ZBC400_DAN_TESTNO4.
    DATA: lt_registrz TYPE TABLE OF zbc_dan_regstrz WITH HEADER LINE,
          lt_category TYPE TABLE OF zbc_dan_category WITH HEADER LINE,
          ls_category TYPE zbc_dan_category, "Struktur Kategorie
          ok_code LIKE sy-ucomm,
          container_r TYPE REF TO cl_gui_custom_container,
          grid_r TYPE REF TO cl_gui_alv_grid,
          gc_custom_control_name TYPE scrfname VALUE 'CONTAINER_REG',
          fieldcat_r TYPE lvc_t_fcat,
          layout_r TYPE lvc_s_layo,
          lt_ddval TYPE lvc_t_drop,
          ls_ddval TYPE lvc_s_drop,
          c TYPE i.
    CLASS lcl_event_receiver DEFINITION DEFERRED.
      DATA g_verifier TYPE REF TO lcl_event_receiver.
      DATA: BEGIN OF gt_outtab OCCURS 0.
        INCLUDE STRUCTURE zbc_dan_regstrz.
        DATA: celltab TYPE lvc_t_styl.
      DATA: END OF gt_outtab.
    CLASS lcl_event_receiver DEFINITION.
      PUBLIC SECTION.
      TYPES: BEGIN OF lt_registrz_key.         "Struktur mit den Schlüsseln der Tabelle 'Registry'
        TYPES:  name TYPE zbc_dan_name,
                value TYPE zbc_dan_value,
                category TYPE zbc_dan_cat.
      TYPES: END OF lt_registrz_key.
      TYPES:  ls_registrz_keys TYPE STANDARD TABLE OF lt_registrz_key,
              ls_registrz_table TYPE STANDARD TABLE OF zbc_dan_regstrz.
      METHODS: get_inserted_rows EXPORTING inserted_rows TYPE ls_registrz_keys.
      METHODS: refresh_delta_tables.
      METHODS: handle_data_changed FOR EVENT data_changed OF cl_gui_alv_grid IMPORTING er_data_changed.
    *  METHODS: get_inserted_rows EXPORTING inserted_rows TYPE registrz_keys.
    *  METHODS: refresh_delta_tables.
      PRIVATE SECTION.
      DATA: inserted_rows TYPE ls_registrz_keys.
      DATA: error_in_data TYPE c.
      METHODS: get_cell_values IMPORTING row_id TYPE int4 pr_data_changed TYPE REF TO cl_alv_changed_data_protocol EXPORTING key TYPE lt_registrz_key.
    ENDCLASS.
    CLASS lcl_event_receiver IMPLEMENTATION.
      METHOD handle_data_changed.
        DATA: ls_good TYPE lvc_s_modi,
              ls_new TYPE lvc_s_moce.
        error_in_data = space.
        IF error_in_data = 'X'.
          CALL METHOD er_data_changed->display_protocol.
        ENDIF.
      ENDMETHOD.
      METHOD get_cell_values.
        CALL METHOD pr_data_changed->get_cell_value
          EXPORTING i_row_id = row_id i_fieldname = 'NAME'
            IMPORTING e_value = key-name.
        CALL METHOD pr_data_changed->get_cell_value
          EXPORTING i_row_id = row_id i_fieldname = 'VALUE'
            IMPORTING e_value = key-value.
        CALL METHOD pr_data_changed->get_cell_value
          EXPORTING i_row_id = row_id i_fieldname = 'CATEGORY'
            IMPORTING e_value = key-category.
      ENDMETHOD.
      METHOD get_inserted_rows.
        inserted_rows = me->inserted_rows.
      ENDMETHOD.
      METHOD refresh_delta_tables.
        clear me->inserted_rows[].
      ENDMETHOD.
    ENDCLASS.
    START-OF-SELECTION.
        SELECT client name value
          INTO CORRESPONDING FIELDS OF TABLE lt_registrz FROM zbc_dan_regstry.
        SELECT category INTO CORRESPONDING FIELDS OF TABLE lt_category FROM zbc_dan_category.
    CALL SCREEN 0100.
    MODULE user_command_0100 INPUT.
      CASE ok_code.
        WHEN 'BACK'.
          SET SCREEN 0.
          MESSAGE ID 'BC400' TYPE 'S' NUMBER '057'.
        WHEN 'SAVE'.
          PERFORM save_data.
        WHEN OTHERS.
      ENDCASE.
    ENDMODULE.
    MODULE clear_ok_code OUTPUT.
      CLEAR ok_code.
    ENDMODULE.
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'DYNPRO100'.
      SET TITLEBAR 'D0100'.
    ENDMODULE.
    MODULE display_alv OUTPUT.
      PERFORM display_alv.
    ENDMODULE.
    FORM display_alv.
    IF grid_r IS INITIAL.
    *----Creating custom container instance
      CREATE OBJECT container_r
      EXPORTING
        container_name = gc_custom_control_name
      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.
    *--Exception handling
        ENDIF.
    *----Creating ALV Grid instance
        CREATE OBJECT grid_r
        EXPORTING
          i_parent = container_r
        EXCEPTIONS
          error_cntl_create = 1
          error_cntl_init = 2
          error_cntl_link = 3
          error_dp_create = 4
          others = 5.
          IF sy-subrc <> 0.
    *--Exception handling
          ENDIF.
          CREATE OBJECT g_verifier.
          SET HANDLER g_verifier->handle_data_changed FOR grid_r.
    *----Preparing field catalog.
          PERFORM prepare_field_catalog CHANGING fieldcat_r.
    *----Preparing layout structure
          PERFORM prepare_layout CHANGING layout_r.
    *----Here will be additional preparations
    *--e.g. initial sorting criteria, initial filtering criteria, excluding
    *--functions
          CALL METHOD grid_r->set_table_for_first_display
          EXPORTING
    * I_BUFFER_ACTIVE =
    * I_CONSISTENCY_CHECK =
    * I_STRUCTURE_NAME =
    * IS_VARIANT =
    * I_SAVE =
    * I_DEFAULT = 'X'
            is_layout = layout_r
    * IS_PRINT =
    * IT_SPECIAL_GROUPS =
    * IT_TOOLBAR_EXCLUDING =
    * IT_HYPERLINK =
          CHANGING
            it_outtab = lt_registrz[]
            it_fieldcatalog = fieldcat_r
    * IT_SORT =
    * IT_FILTER =
          EXCEPTIONS
            invalid_parameter_combination = 1
            program_error = 2
            too_many_lines = 3
            OTHERS = 4.
          IF sy-subrc <> 0.
    *--Exception handling
          ENDIF.
          ELSE.
            CALL METHOD grid_r->refresh_table_display
    * EXPORTING
    * IS_STABLE =
    * I_SOFT_REFRESH =
          EXCEPTIONS
            finished = 1
            OTHERS = 2.
          IF sy-subrc <> 0.
    *--Exception handling
          ENDIF.
        ENDIF.
        CALL METHOD grid_r->register_edit_event
          EXPORTING
            i_event_id = cl_gui_alv_grid=>mc_evt_enter.
        CALL METHOD grid_r->register_edit_event
          EXPORTING
            i_event_id = cl_gui_alv_grid=>mc_evt_modified.
    ENDFORM.
    FORM prepare_field_catalog CHANGING pt_fieldcat TYPE lvc_t_fcat.
      DATA ls_fcat TYPE lvc_s_fcat.
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
      EXPORTING
        i_structure_name = 'ZBC_DAN_REGSTR2'
      CHANGING
        ct_fieldcat = pt_fieldcat[]
      EXCEPTIONS
        inconsistent_interface = 1
        program_error = 2
        OTHERS = 3.
      IF sy-subrc <> 0.
    *--Exception handling
      ENDIF.
      LOOP AT pt_fieldcat INTO ls_fcat.
        CASE ls_fcat-fieldname.
          WHEN 'NAME'.
            ls_fcat-coltext = 'Name'.
            ls_fcat-outputlen = '40'.
            MODIFY pt_fieldcat FROM ls_fcat.
          WHEN 'VALUE'.
            ls_fcat-coltext = 'Wert'.
            ls_fcat-outputlen = '30'.
            MODIFY pt_fieldcat FROM ls_fcat.
          WHEN 'CATEGORY'.
              LOOP AT lt_category into ls_category.
                ls_ddval-handle = 1.
                ls_ddval-value = ls_category-category.
    *            ls_ddval-style = cl_gui_alv_grid=>mc_style_enabled.
                APPEND ls_ddval TO lt_ddval.
             ENDLOOP.
             CALL METHOD grid_r->set_drop_down_table
                EXPORTING it_drop_down = lt_ddval.
            ls_fcat-edit = 'X'.
            ls_fcat-drdn_hndl = '1'.
            ls_fcat-coltext = 'Kategorie'.
            MODIFY pt_fieldcat FROM ls_fcat.
        ENDCASE.
      ENDLOOP.
    ENDFORM.
    FORM prepare_layout CHANGING ps_layout TYPE lvc_s_layo.
      ps_layout-zebra = 'X'.
      ps_layout-grid_title = 'Kategorie zur Registry hinzufügen'.
      ps_layout-smalltitle = 'X'.
    ENDFORM.
    FORM save_data.
      DATA: ls_ins_keys TYPE g_verifier->ls_registrz_keys,
            ls_ins_key TYPE g_verifier->lt_registrz_key,
            ls_registrz TYPE zbc_dan_regstrz,
            ls_outtab LIKE LINE OF gt_outtab,
            lt_instab TYPE TABLE OF zbc_dan_regstrz.
      CALL METHOD g_verifier->get_inserted_rows IMPORTING inserted_rows = ls_ins_keys.
      LOOP AT ls_ins_keys INTO ls_ins_key.
        READ TABLE gt_outtab INTO ls_outtab
        WITH KEY  name = ls_ins_key-name
                  value = ls_ins_key-value
                  category = ls_ins_key-category.
        IF sy-subrc = 0.
          MOVE-CORRESPONDING ls_outtab TO ls_registrz.
          APPEND ls_registrz TO lt_instab.
        ENDIF.
      ENDLOOP.
      INSERT zbc_dan_regstrz FROM TABLE lt_instab.
      CALL METHOD g_verifier->refresh_delta_tables.
      ENDFORM.

    Hi Hans,
    You raised the Question in the Webdynpro ABAP forum. Here its very diffcult to get the answer from this forum. Please close it here and raise the same question in ABAP General Forum there you will get faster and so many anwsers.
    Please close the question here.
    Warm Regards,
    Vijay

  • ALV flickering problem

    Hi,
    I have  flickering problem with ALV control (cl_gui_alv_grid).  My alv grid  control is not in edit mode.
    I am using ALV grid for event planning with drag drop operations, so there may be 1000+ rows sometimes at grid.
    Also I call refresh_table_display with soft_refresh and is_stable='XX.'
    (I call cfw=>set_new_ok_code to trigger PBO. refresh_table_display is being called at PBO )
    It flickers just a second or two after drop_complete but it is critical for usability.
    I think flickering happens because of scrolling, so I used set_scroll_via_id but nothing changed.
    Thanks.

    Hi Manu,
    I tried not to trigger PBO (Called refresh_table_display at PAI, commented set_new_ok_code)
    It does not help..
    (Same behaviour : se38-> BC_ALV_TEST_GRID_PERFORMANCE.Increase record count to 5000.Run.
    Scroll to the bottom of list.)
    Thank you..

  • ALV Grid Problem in WebGUI

    Hi All,
    We've created an ALV grid using classes in R3 and we're testing it in WebGUI.  All of those scenarios are working fine in R3 however the behavior in WebGUI is different.  We're encountering a problem wherein the cellstyles are not being reflected (eg. a particular cell for a particular row should be grayed out if a particular field has this value).  Furthermore, if we enter a value in this field, it should automatically populate values for other fields (eg. column name - PERNR.  Once pernr is entered; column name - NAME should have a value automatically).  Another thing is, the Refresh button is  missing in WebGUI.  One more problem is that the error message for that particular column was not shown.  We're using the add_protocol_entry method, so it should generate a pop-up screen.
    Any solution for all these problems?  Are these problems limitations of the ALV Grid in WebGUI? 
    We'll appreciate all your responses.  Thanks a lot.

    Have a look at example code: BCALV_GRID_01, where they suppress the error by catching it...
    If you are using the ABAP Grid Control (OO object), you can still create the ALV list as a spool listing for the background job.
    The easiest way to do this is to put all the create object statements and method calls for the custom container and ALV grid object inside a subroutine (for example, present_grid).
    All that is required is a simple check of the sy-batch variable to determine if the program is being executed in the foreground or background.
    e.g. if sy-batch is initial.
    call screen 0100.
    else.
    perform present_grid.
    endif.
    In a PBO module of screen 0100, the subroutine present_grid is also performed.
    The set_table_for_first_display method will be invoked in the routine present_grid, however, due to the job being executed in the background, the ALV list output will be written as spool output for the background job.

  • VISA Read function Read buffer problem in serial communication

    Hi,  I use VISA write and read function in serial communication app, the device continuously sends 0x00 if it is not receive a request from Labview program running on PC.
    And the request sent by labview is programmable. I met a weird problem, each time the request changes, the VISA read buffer output port still shows the last request firstly, from second time, shows the right request.
    It works like: Req code: ... 50, 51,51,51,50....;  VISA Read buffer: ...50, 50, 51, 51, 51, 51, 50....
    Please refer to the program.
    Attachments:
    readOne_test.vi ‏21 KB

    How are you running this?  You don't have a while loop around it.  Is it part of a larger VI?  Please don't tell me you are using the run continuously button.
    You don't have any wait statement between you VISA Write and your bytes at port.  So it is very likely the receive buffer is still empty since you didn't give your VI time to wait for the device to turn around and give a reply.  If you read 0 bytes, your VISA read string will be empty.  How does your decoder subVI (which you didn't include) handle an empty string?

  • ALV Tree Problem with Checkboxes

    Hello,
    i've got a problem.
    I have an ALV-Tree and die ALV-Detaillist of the tree are type checkbox.
    That's working correct.
    But i want to fill initial data in the checkboxes but the checkbox isnt set.
    i've done as followed:
      CALL METHOD go_alv_tree->set_table_for_first_display
        EXPORTING
         I_STRUCTURE_NAME     =
         IS_VARIANT           =
         I_SAVE               =
          i_default            = abap_false
          is_hierarchy_header  = ls_header
         IS_EXCEPTION_FIELD   =
         IT_SPECIAL_GROUPS    =
         IT_LIST_COMMENTARY   =
         I_LOGO               =
         I_BACKGROUND_ID      =
         IT_TOOLBAR_EXCLUDING =
        CHANGING
          it_outtab            = <go_data_tab>
         IT_FILTER            =
          it_fieldcatalog      = lt_fcat.
    fieldcat are several fields all as checkbox.
    Then i get a component of the output structure and set a X.
    ASSIGN COMPONENT lv_help_arbpl OF STRUCTURE <go_data_struc>
                           TO <fs_arbl>.
          IF <fs_arbl> IS ASSIGNED.
            <fs_arbl> = lc_xfeld.
          ENDIF.
            CALL METHOD go_alv_tree->add_node
              EXPORTING
                i_relat_node_key     = lv_matnr
                i_relationship       = cl_gui_column_tree=>relat_last_child
                is_outtab_line       = <go_data_struc>
                is_node_layout       = ls_layout
             IT_ITEM_LAYOUT       =
                i_node_text          = lv_node_text
              IMPORTING
                e_new_node_key       = lv_period
              EXCEPTIONS
                relat_node_not_found = 1
                node_not_found       = 2
                OTHERS               = 3.
    in <go_data_struc> the fields which should be set, are set with X.
    But after i add all of my nodes and do CALL METHOD p_go_alv_tree->frontend_update, the checkbox is empty but there is an X in the field beside the checkbox.
    Thanks in advance.
    best regards,
    Dennis

    Ok i solved the problem.
    best regards,
    Dennis

  • ALV  Print  Problem

    Hi All,
        Problem regarding  Printing  the AVL  Grid.
         There are 15 column in the  grid , while printing it gives a pop up . 23 column are not printable. in  the page  format..
    How  to   get  all  the  column  printed..?.Full Points Ensured..
    Regards..
    Lakhan

    Hi Lakan,
      in ALV Grid (OR) Normal Reort we can print upto SOme limit only.You can n't print entire ALV grid.If you want to print whole content, down load file into some notepad (Excel Sheet) and try print.

  • ALV Sort problem

    Hi Experts,
    I have encountered a peculiar situation with respect to ALV, using sort. The problem is as follows:
    1. I have an internal table with 3 fields, upon which I am supposed to implement a sort criteria on the first two fields.
    2. My data is something like this, for ex:
    abc  1  a
    abc  1  b
    cde  1  a
    cde  1  b
    3. I have applied sort criteria, on the first two fields and passed to the fm "REUSE_ALV_GRID_DISPLAY'.
    4. Now the output is as follows:
    abc  1  a
      --  b
    cde --  a
    ---   --  b
    Here ( -- ) dotted lines mean the identical entry from the previous row...
    5. My requirement is I want the output as:
    abc  1  a
    ---  --   b
    cde  1  a
    ---   --  b 
    I mean the sort critetia of the second column should follow the first(adjacent column) sort criteria
    I hope it is clearly explained, and kindly let me know how this can be solved..
    Thank you,
    Shashi

    Hi Bala,
    The suggested solution is not giving the desired results..
    This happens because, when i sort the entries i mentioned earlier, remains the same, even after the two explicit sort statements on the internal table.
    Kindly check the same and let me know.
    Regards,
    Shashi

  • ALV Download Problem

    Hi Experts,
    ALV report is generated well but the PROBLEM, lies in downloading to xls.
    The character size here is more than 1600 characters, so it is downloading to xls in jumbled way.
    Please help.
    Regards,
    IFF

    Hi,
       Use GUI_DOWNLOAD it will work
    *&      Form  sub_download
          text
    -->  p1        text
    <--  p2        text
    FORM sub_download.
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
        BIN_FILESIZE                    =
          filename                        = p_path
         filetype                        = 'ASC'
        APPEND                          = ' '
         write_field_separator           = 'X'
        HEADER                          = '00'
        TRUNC_TRAILING_BLANKS           = ' '
        WRITE_LF                        = 'X'
        COL_SELECT                      = ' '
        COL_SELECT_MASK                 = ' '
        DAT_MODE                        = ' '
        CONFIRM_OVERWRITE               = ' '
        NO_AUTH_CHECK                   = ' '
        CODEPAGE                        = ' '
        IGNORE_CERR                     = ABAP_TRUE
        REPLACEMENT                     = '#'
        WRITE_BOM                       = ' '
        TRUNC_TRAILING_BLANKS_EOL       = 'X'
        WK1_N_FORMAT                    = ' '
        WK1_N_SIZE                      = ' '
        WK1_T_FORMAT                    = ' '
        WK1_T_SIZE                      = ' '
      IMPORTING
        FILELENGTH                      =
        TABLES
          data_tab                        = it_final
        FIELDNAMES                      =
      EXCEPTIONS
        FILE_WRITE_ERROR                = 1
        NO_BATCH                        = 2
        GUI_REFUSE_FILETRANSFER         = 3
        INVALID_TYPE                    = 4
        NO_AUTHORITY                    = 5
        UNKNOWN_ERROR                   = 6
        HEADER_NOT_ALLOWED              = 7
        SEPARATOR_NOT_ALLOWED           = 8
        FILESIZE_NOT_ALLOWED            = 9
        HEADER_TOO_LONG                 = 10
        DP_ERROR_CREATE                 = 11
        DP_ERROR_SEND                   = 12
        DP_ERROR_WRITE                  = 13
        UNKNOWN_DP_ERROR                = 14
        ACCESS_DENIED                   = 15
        DP_OUT_OF_MEMORY                = 16
        DISK_FULL                       = 17
        DP_TIMEOUT                      = 18
        FILE_NOT_FOUND                  = 19
        DATAPROVIDER_EXCEPTION          = 20
        CONTROL_FLUSH_ERROR             = 21
        OTHERS                          = 22
      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.                    " sub_download
    Regards,
    Prashant

  • ALV - Find problem

    Hello,
    I have problem of find value in alv table.
    By choosing some variant I get table with 500 lines and 70 columns. When I use FIND icon of ALV to find specific order number (after selecting the column), the FIND "works" only for first rows and doesn't work for last.
    I pay attention that FIND "works" as function of table size.
    When table is small find work properly.
    Is there some restrictions for find?
    Tnanks in advance,
    Michal

    Do compare your program with demo Program
    BCALV_GRID_DEMO ( find function will work normal way and scrolling also)
    Good Luck
    Thanks
    Seshu

  • ALV filter problem

    Hi,
    I am facing a problem with the ALV grid. Recently our system got upgraded to ECC 5.0
    There is a column in the grid for displaying message texts.If i try to set a filter for the message text column,a popup comes as usual to select the values in the message column. In that popup, suppose a F4 help is taken, texts are getting truncated.
    Could you please suggest any OSS notes need to be added for this?
    Regards,
    Raju

    Hi,
    try to use EDIT_MASK for that field and see.
    you try this way..
    <b>
    Fieldcat-edit_mask = '==ALPHA'.</b>
    for the text field.
    Regards
    vijay

  • ALV list problem

    Hi all,
    I am facing a strange problem in ALV. i have two internal tables one is for alv header and another is alv line items. i have a proper data in in both internal tables.
    when i pass the data of these two internal tables to the function REUSE_ALV_HIERSEQ_LIST_DISPLAY i found in the output that line items date changes.
    actually date is in format 04112005 but when i see the output its showing like this 05.20.0411 .
    please help me to solve the problem.
    Regards,
    Lisa

    Hii
    use this func module
    <b>CONVERT_DATE_TO_INTERN_FORMAT</b>
    <b>CONVERSION_EXIT_PDATE_INPUT</b>
    Thsi will give the dtae in YYYY.MM.DD format
    check this program for reference
    REPORT  Z_50657_ALV_EX1
            MESSAGE-ID ZZ .
                                Type Pools                               *
    TYPE-POOLS: SLIS.
                                 Tables                                  *
    TABLES: LFA1, "Vendor Master
            LFB1, "Vendor Master (Company Code)
            LFM1. "purchasing organization data
                            Internal Tables                              *
    TABLE TO HOLD DATA FROM VENDOR MASTER
    DATA: BEGIN OF IT_LFA1 OCCURS 0,
            LIFNR LIKE LFA1-LIFNR,  "Account Number of Vendor
            KTOKK LIKE LFA1-KTOKK,  "Vendor account group
            NAME1 LIKE LFA1-NAME1,  "Name
            STRAS LIKE LFA1-STRAS,  "House Number and Street
            ORT01 LIKE LFA1-ORT01,  "City
            REGIO LIKE LFA1-REGIO,  "Region
            PFORT LIKE LFA1-PFORT,  "PO Box City
            PSTLZ LIKE LFA1-PSTLZ,  "Postal Code
            PSTL2 LIKE LFA1-PSTL2,  "P.O. Box
            TELF1 LIKE LFA1-TELF1,  "First telephone number
          END OF IT_LFA1.
    TABLE TO HOLD DATA ABOUT COMPANY
    DATA: BEGIN OF IT_LFB1 OCCURS 0,
            LIFNR LIKE LFB1-LIFNR, "Account Number of Vendor
            BUKRS LIKE LFB1-BUKRS, "COMP CODE
          END OF IT_LFB1.
    TABLE TO HOLD DATA ABOUT PURCHASING ORG
    DATA: BEGIN OF IT_LFM1 OCCURS 0,
            LIFNR LIKE LFM1-LIFNR, "Account Number of Vendor
            EKORG LIKE LFM1-EKORG, "Purchasing Organization
          END OF IT_LFM1.
    TABLE TO HOLD DATA FOR FINAL DISPLAY
    DATA: BEGIN OF IT_FINAL OCCURS 0,
            LIFNR LIKE LFB1-LIFNR,  "Account Number of Vendor
            BUKRS LIKE LFB1-BUKRS,  "COMP CODE
            EKORG LIKE LFM1-EKORG,  "Purchasing Organization
            KTOKK LIKE LFA1-KTOKK,  "Vendor account group
            NAME1 LIKE LFA1-NAME1,  "Name
            STRAS LIKE LFA1-STRAS,  "House Number and Street
            ORT01 LIKE LFA1-ORT01,  "City
            REGIO LIKE LFA1-REGIO,  "Region
            PFORT LIKE LFA1-PFORT,  "PO Box City
            PSTLZ LIKE LFA1-PSTLZ,  "Postal Code
            PSTL2 LIKE LFA1-PSTL2,  "P.O. Box
            TELF1 LIKE LFA1-TELF1,  "First telephone number
          END OF IT_FINAL.
    DATA: V_INDEX TYPE SY-TABIX.
                                Work Areas                               *
    *WORK AREAS DEFINED FOR ALV'S
    DATA: X_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
          IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
          L_LAYOUT TYPE SLIS_LAYOUT_ALV.
                          Selection-Screen                               *
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
    SELECT-OPTIONS: S_LIFNR FOR LFA1-LIFNR, "ACCOUNT NUMBER
                    S_BUKRS FOR LFB1-BUKRS, "COMPANY CODE
                    S_EKORG FOR LFM1-EKORG, "PURCHASING ORG
                    S_KTOKK FOR LFA1-KTOKK. "ACCOUNT GROUP
    SELECTION-SCREEN END OF BLOCK B1.
    SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-002.
    PARAMETERS: LIST RADIOBUTTON GROUP G1, "ALV LIST DISPLAY
                GRID RADIOBUTTON GROUP G1. "ALV GRID DISPLAY
    SELECTION-SCREEN END OF BLOCK B2.
                        At  Selection-Screen                             *
    AT SELECTION-SCREEN.
      PERFORM VALIDATION.
                          Start of Selection                             *
    START-OF-SELECTION.
    *POPULATE DATA INTO ITAB_FINAL USING INNER JOINS OF IT_LFA1 IT_LFB1
    *IT_LFM1
      PERFORM GET_DATA.
    *CHECK FOR RADIO BUTTON SELECTION AND ACCORDINGLY DISPLAY ALV GRID/LIST
      PERFORM CHECK_SEL.
    *&      Form  VALIDATION
          text
    FORM VALIDATION.
      IF S_LIFNR IS NOT INITIAL.
        SELECT SINGLE LIFNR FROM LFA1 INTO IT_LFA1 WHERE LIFNR IN S_LIFNR.
        IF SY-SUBRC <> 0.
          MESSAGE I000 WITH 'THIS IS NOT A VALID VENDOR NUMBER'.
          STOP.
        ELSE.
          IF S_BUKRS IS NOT INITIAL.
            SELECT SINGLE BUKRS FROM LFB1 INTO IT_LFB1-BUKRS WHERE BUKRS IN
            S_BUKRS.
            IF SY-SUBRC <> 0.
              MESSAGE I000 WITH 'THIS IS NOT A VALID COMPANY CODE'.
              STOP.
            ENDIF.
          ENDIF.
        ENDIF.
      ENDIF.
      CLEAR IT_LFA1.
      CLEAR IT_LFB1.
    ENDFORM.                    "VALIDATION
    *&      Form  GET_DATA
          text
    FORM GET_DATA.
      SELECT LIFNR
             KTOKK
             NAME1
             STRAS
             ORT01
             REGIO
             PFORT
             PSTLZ
             PSTL2
             TELF1
             FROM LFA1
             INTO TABLE IT_LFA1
             WHERE LIFNR IN S_LIFNR AND KTOKK IN S_KTOKK.
      SORT IT_LFA1 BY LIFNR.
      IF NOT IT_LFA1[] IS INITIAL.
        SELECT LIFNR
               BUKRS
               FROM LFB1
               INTO TABLE IT_LFB1
               FOR ALL ENTRIES IN IT_LFA1 WHERE LIFNR = IT_LFA1-LIFNR AND
                                                BUKRS IN S_BUKRS.
        SORT IT_LFB1 BY LIFNR BUKRS.
        SELECT LIFNR
               EKORG
               FROM LFM1
               INTO TABLE IT_LFM1
               FOR ALL ENTRIES IN IT_LFA1 WHERE LIFNR = IT_LFA1-LIFNR.
        SORT IT_LFM1 BY LIFNR.
      ENDIF.
      IT_FINAL[] = IT_LFB1[].
      LOOP AT IT_FINAL.
        V_INDEX = SY-TABIX.
        READ TABLE IT_LFA1 WITH KEY LIFNR = IT_FINAL-LIFNR BINARY SEARCH.
        IF SY-SUBRC = 0.
          MOVE: IT_LFA1-KTOKK TO IT_FINAL-KTOKK,
                IT_LFA1-NAME1 TO IT_FINAL-NAME1,
                IT_LFA1-STRAS TO IT_FINAL-STRAS,
                IT_LFA1-ORT01 TO IT_FINAL-ORT01,
                IT_LFA1-REGIO TO IT_FINAL-REGIO,
                IT_LFA1-PFORT TO IT_FINAL-PFORT,
                IT_LFA1-PSTLZ TO IT_FINAL-PSTLZ,
                IT_LFA1-PSTL2 TO IT_FINAL-PSTL2,
                IT_LFA1-TELF1 TO IT_FINAL-TELF1.
        ENDIF.
        READ TABLE IT_LFM1 WITH KEY LIFNR = IT_FINAL-LIFNR BINARY SEARCH.
        IF SY-SUBRC = 0.
          MOVE IT_LFM1-EKORG TO IT_FINAL-EKORG.
        ENDIF.
        MODIFY IT_FINAL INDEX V_INDEX.
      ENDLOOP.
    LOOP AT IT_LFA1.
       LOOP AT IT_FINAL WHERE LIFNR = IT_LFA1-LIFNR.
         MOVE IT_LFA1-KTOKK TO IT_FINAL-KTOKK.
         MODIFY IT_FINAL INDEX SY-TABIX.
         MOVE IT_LFA1-NAME1 TO IT_FINAL-NAME1.
         MODIFY IT_FINAL INDEX SY-TABIX.
         MOVE IT_LFA1-STRAS TO IT_FINAL-STRAS.
         MODIFY IT_FINAL INDEX SY-TABIX.
         MOVE IT_LFA1-ORT01 TO IT_FINAL-ORT01.
         MODIFY IT_FINAL INDEX SY-TABIX.
         MOVE IT_LFA1-REGIO TO IT_FINAL-REGIO.
         MODIFY IT_FINAL INDEX SY-TABIX.
         MOVE IT_LFA1-PFORT TO IT_FINAL-PFORT.
         MODIFY IT_FINAL INDEX SY-TABIX.
         MOVE IT_LFA1-PSTLZ TO IT_FINAL-PSTLZ.
         MODIFY IT_FINAL INDEX SY-TABIX.
         MOVE IT_LFA1-PSTL2 TO IT_FINAL-PSTL2.
         MODIFY IT_FINAL INDEX SY-TABIX.
         MOVE IT_LFA1-TELF1 TO IT_FINAL-TELF1.
         MODIFY IT_FINAL INDEX SY-TABIX.
       ENDLOOP.
    ENDLOOP.
    LOOP AT IT_LFM1.
       LOOP AT IT_FINAL WHERE LIFNR = IT_LFM1-LIFNR.
         MOVE IT_LFM1-EKORG TO IT_FINAL-EKORG.
         MODIFY IT_FINAL INDEX SY-TABIX.
       ENDLOOP.
    ENDLOOP.
    SORT IT_FINAL BY LIFNR BUKRS EKORG.
    ENDFORM.                    "GET_DATA
    *&      Form  CHECK_SEL
          text
    FORM CHECK_SEL.
    X_FIELDCAT-FIELDNAME = 'LIFNR'.
    X_FIELDCAT-TABNAME = 'IT_FINAL'.
    X_FIELDCAT-SELTEXT_L  = 'VENDOR'.
    X_FIELDCAT-NO_ZERO    = 'X'.
    X_FIELDCAT-OUTPUTLEN  = 10.
    X_FIELDCAT-COL_POS    = 1.
    APPEND X_FIELDCAT TO IT_FIELDCAT.
    CLEAR X_FIELDCAT.
    X_FIELDCAT-FIELDNAME = 'BUKRS'.
    X_FIELDCAT-TABNAME = 'IT_FINAL'.
    X_FIELDCAT-SELTEXT_L  = 'COMPANY'.
    X_FIELDCAT-NO_ZERO    = 'X'.
    X_FIELDCAT-OUTPUTLEN  = 4.
    X_FIELDCAT-COL_POS    = 2.
    APPEND X_FIELDCAT TO IT_FIELDCAT.
    CLEAR X_FIELDCAT.
    X_FIELDCAT-FIELDNAME = 'EKORG'.
    X_FIELDCAT-TABNAME = 'IT_FINAL'.
    X_FIELDCAT-SELTEXT_L  = 'PURCHASING ORGANISATION'.
    X_FIELDCAT-NO_ZERO    = 'X'.
    X_FIELDCAT-OUTPUTLEN  = 4.
    X_FIELDCAT-COL_POS    = 3.
    APPEND X_FIELDCAT TO IT_FIELDCAT.
    CLEAR X_FIELDCAT.
    X_FIELDCAT-FIELDNAME = 'KTOKK'.
    X_FIELDCAT-TABNAME = 'IT_FINAL'.
    X_FIELDCAT-SELTEXT_L  = 'ACCOUNT GROUP'.
    X_FIELDCAT-NO_ZERO    = 'X'.
    X_FIELDCAT-OUTPUTLEN  = 4.
    X_FIELDCAT-COL_POS    = 4.
    APPEND X_FIELDCAT TO IT_FIELDCAT.
    CLEAR X_FIELDCAT.
    X_FIELDCAT-FIELDNAME = 'NAME1'.
    X_FIELDCAT-TABNAME = 'IT_FINAL'.
    X_FIELDCAT-SELTEXT_L  = 'VENDOR NAME'.
    X_FIELDCAT-NO_ZERO    = 'X'.
    X_FIELDCAT-OUTPUTLEN  = 35.
    X_FIELDCAT-COL_POS    = 5.
    APPEND X_FIELDCAT TO IT_FIELDCAT.
    CLEAR X_FIELDCAT.
    X_FIELDCAT-FIELDNAME = 'STRAS'.
    X_FIELDCAT-TABNAME = 'IT_FINAL'.
    X_FIELDCAT-SELTEXT_L  = 'STREET'.
    X_FIELDCAT-NO_ZERO    = 'X'.
    X_FIELDCAT-OUTPUTLEN  = 10.
    X_FIELDCAT-COL_POS    = 6.
    APPEND X_FIELDCAT TO IT_FIELDCAT.
    CLEAR X_FIELDCAT.
    X_FIELDCAT-FIELDNAME = 'ORT01'.
    X_FIELDCAT-TABNAME = 'IT_FINAL'.
    X_FIELDCAT-SELTEXT_L  = 'CITY NAME'.
    X_FIELDCAT-NO_ZERO    = 'X'.
    X_FIELDCAT-OUTPUTLEN  = 20.
    X_FIELDCAT-COL_POS    = 7.
    APPEND X_FIELDCAT TO IT_FIELDCAT.
    CLEAR X_FIELDCAT.
    X_FIELDCAT-FIELDNAME = 'REGIO'.
    X_FIELDCAT-TABNAME = 'IT_FINAL'.
    X_FIELDCAT-SELTEXT_L  = 'REGION NAME'.
    X_FIELDCAT-NO_ZERO    = 'X'.
    X_FIELDCAT-OUTPUTLEN  = 2.
    X_FIELDCAT-COL_POS    = 8.
    APPEND X_FIELDCAT TO IT_FIELDCAT.
    CLEAR X_FIELDCAT.
      IF LIST = 'X'.
        CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
          EXPORTING
            I_PROGRAM_NAME         = SY-REPID
            I_INTERNAL_TABNAME     = 'IT_FINAL'
            I_INCLNAME             = SY-REPID
          CHANGING
            CT_FIELDCAT            = IT_FIELDCAT
          EXCEPTIONS
            INCONSISTENT_INTERFACE = 1
            PROGRAM_ERROR          = 2
            OTHERS                 = 3.
        IF SY-SUBRC <> 0.
          MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                  WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
        L_LAYOUT-ZEBRA = 'X'.
        CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
          EXPORTING
            I_CALLBACK_PROGRAM = SY-REPID
            IS_LAYOUT          = L_LAYOUT
            IT_FIELDCAT        = IT_FIELDCAT
          TABLES
            T_OUTTAB           = IT_FINAL
          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.
      ELSE.
        CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
          EXPORTING
            I_PROGRAM_NAME         = SY-REPID
            I_INTERNAL_TABNAME     = 'IT_FINAL'
            I_INCLNAME             = SY-REPID
          CHANGING
            CT_FIELDCAT            = IT_FIELDCAT
          EXCEPTIONS
            INCONSISTENT_INTERFACE = 1
            PROGRAM_ERROR          = 2
            OTHERS                 = 3.
        IF SY-SUBRC <> 0.
          MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                  WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
        L_LAYOUT-ZEBRA = 'X'.
        CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
          EXPORTING
            I_CALLBACK_PROGRAM = SY-REPID
            IS_LAYOUT          = L_LAYOUT
            IT_FIELDCAT        = IT_FIELDCAT
          TABLES
            T_OUTTAB           = IT_FINAL
          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.
      ENDIF.
    Regards
    Naresh

  • Alv total problem

    Hi, all
    i have one problem is alv....
    what is the statement should i write to get sub total..
    for eg....
    xxxxxxxxxxxxxx    123123
                                 123123
    subtotal                  642642
    in this way....my total should come
    WA_ALV_FIELDS-TABNAME   = 'IT_TEMP'.
      WA_ALV_FIELDS-FIELDNAME = 'CONTR'.
      WA_ALV_FIELDS-SELTEXT_M = 'Contribution'.
      WA_ALV_FIELDS-NO_ZERO = 'X'.
      APPEND WA_ALV_FIELDS TO ALV_FIELDS.
      CLEAR  WA_ALV_FIELDS.

    Hi,
    For total.
    While building the fieldcatalog you have use do_sum = 'X' for the column which you need the summation.
    For subtotal use below code :
    data :gt_sort TYPE slis_t_sortinfo_alv,
    DATA: ls_sort TYPE slis_sortinfo_alv.
    CLEAR ls_sort.
    ls_sort-fieldname = 'Fieldname'.
    ls_sort-up = 'X'.
    ls_sort-subtot = 'X'.
    APPEND ls_sort TO gt_sort.
    And pass gt_sort to grid display export parameter I_sort.
    Regards,
    Raj.

Maybe you are looking for