Positioning ALV Grid displayed via FM REUSE_ALV_GRID_DISPLAY

Hi,
i'm displaying an ALV List via FM REUSE_ALV_GRID_DISPLAY, the user can edit and change values. But after refreshing the table the user losses his scroll position, the refreshed list starts always at line 1. How can i scroll down to the users last scrollposition?

Hi Rainer,
Check the following with comments. if you r not refreshing the following way , let me know how are u refreshing .
*&      Form  user_command
*       text
*      -->R_UCOMM      text
*      -->RS_SELFIELD  text
FORM user_command  USING r_ucomm LIKE sy-ucomm
                          rs_selfield TYPE slis_selfield.
   CASE r_ucomm.
       " When u press on Refresh Button
     WHEN 'REFRESH'.
       " I believe u might have set the following one to get ur list refreshed.
       rs_selfield-refresh = 'X'.
       " If my belive is right, You can set the following one to get ur row stable after refresh
       rs_selfield-row_stable = 'X'."Keep row position when list is set up again
   ENDCASE.
ENDFORM.                    "user_command
I hope that it solves ur problem.
Regards,
Venkat.O

Similar Messages

  • Field Catolgue in alv grid display

    Hi Abapers,
    I need to display the percentage rows with decimals and other rows without decimal . Is their any option in field catalog to do like this. Or tell me any other alternative to achieve this.
    sno  total     col1      col2      col3
    1      220       100        20       100
    2      320      120         50        150
    tot    540       220        70         250
    per               40.74     1.87  and so on
    or ,
    I have two different internal tables how can i put it in one field catalog to pass it to alv grid display.
    Regards,
    Priya

    Don't   do  total  by your  self  in the Pogram.
    in the   Fieldcatalog  there is an Attribute which will do total  &  Average .
    Enable it so that  from one  internal  table   data   it self it will do  good.
    example program
    Below is an example ABAP program which will populate a simple internal table(it_ekpo) with data and
    display it using the basic ALV grid functionality(including column total). The example details the main
    sections of coding required to implement the ALV grid functionality:
                             Data declaration
                             Data retrieval
                             Build fieldcatalog
                             Build layout setup
    REPORT  zdemo_alvgrid                 .
    TABLES:     ekko.
    type-pools: slis.                                 "ALV Declarations
    *Data Declaration
    TYPES: BEGIN OF t_ekko,
      ebeln TYPE ekpo-ebeln,
      ebelp TYPE ekpo-ebelp,
      statu TYPE ekpo-statu,
      aedat TYPE ekpo-aedat,
      matnr TYPE ekpo-matnr,
      menge TYPE ekpo-menge,
      meins TYPE ekpo-meins,
      netpr TYPE ekpo-netpr,
      peinh TYPE ekpo-peinh,
    END OF t_ekko.
    DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
          wa_ekko TYPE t_ekko.
    *ALV data declarations
    data: fieldcatalog type slis_t_fieldcat_alv with header line,
          gd_tab_group type slis_t_sp_group_alv,
          gd_layout    type slis_layout_alv,
          gd_repid     like sy-repid.
    *Start-of-selection.
    START-OF-SELECTION.
    perform data_retrieval.
    perform build_fieldcatalog.
    perform build_layout.
    perform display_alv_report.
    *&      Form  BUILD_FIELDCATALOG
    *       Build Fieldcatalog for ALV Report
    form build_fieldcatalog.
    * There are a number of ways to create a fieldcat.
    * For the purpose of this example i will build the fieldcatalog manualy
    * by populating the internal table fields individually and then
    * appending the rows. This method can be the most time consuming but can
    * also allow you  more control of the final product.
    * Beware though, you need to ensure that all fields required are
    * populated. When using some of functionality available via ALV, such as
    * total. You may need to provide more information than if you were
    * simply displaying the result
    *               I.e. Field type may be required in-order for
    *                    the 'TOTAL' function to work.
      fieldcatalog-fieldname   = 'EBELN'.
      fieldcatalog-seltext_m   = 'Purchase Order'.
      fieldcatalog-col_pos     = 0.
      fieldcatalog-outputlen   = 10.
      fieldcatalog-emphasize   = 'X'.
      fieldcatalog-key         = 'X'.
    *  fieldcatalog-do_sum      = 'X'.
    *  fieldcatalog-no_zero     = 'X'.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'EBELP'.
      fieldcatalog-seltext_m   = 'PO Item'.
      fieldcatalog-col_pos     = 1.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'STATU'.
      fieldcatalog-seltext_m   = 'Status'.
      fieldcatalog-col_pos     = 2.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'AEDAT'.
      fieldcatalog-seltext_m   = 'Item change date'.
      fieldcatalog-col_pos     = 3.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MATNR'.
      fieldcatalog-seltext_m   = 'Material Number'.
      fieldcatalog-col_pos     = 4.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MENGE'.
      fieldcatalog-seltext_m   = 'PO quantity'.
      fieldcatalog-col_pos     = 5.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MEINS'.
      fieldcatalog-seltext_m   = 'Order Unit'.
      fieldcatalog-col_pos     = 6.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'NETPR'.
      fieldcatalog-seltext_m   = 'Net Price'.
      fieldcatalog-col_pos     = 7.
      fieldcatalog-outputlen   = 15. 
      fieldcatalog-do_sum      = 'X'.        "Display column total
      fieldcatalog-datatype     = 'CURR'.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'PEINH'.
      fieldcatalog-seltext_m   = 'Price Unit'.
      fieldcatalog-col_pos     = 8.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
    endform.                    " BUILD_FIELDCATALOG
    *&      Form  BUILD_LAYOUT
    *       Build layout for ALV grid report
    form build_layout.
      gd_layout-no_input          = 'X'.
      gd_layout-colwidth_optimize = 'X'.
      gd_layout-totals_text       = 'Totals'(201).
    *  gd_layout-totals_only        = 'X'.
    *  gd_layout-f2code            = 'DISP'.  "Sets fcode for when double
    *                                         "click(press f2)
    *  gd_layout-zebra             = 'X'.
    *  gd_layout-group_change_edit = 'X'.
    *  gd_layout-header_text       = 'helllllo'.
    endform.                    " BUILD_LAYOUT
    *&      Form  DISPLAY_ALV_REPORT
    *       Display report using ALV grid
    form display_alv_report.
      gd_repid = sy-repid.
      call function 'REUSE_ALV_GRID_DISPLAY'
           exporting
                i_callback_program      = gd_repid
    *            i_callback_top_of_page   = 'TOP-OF-PAGE'  "see FORM
    *            i_callback_user_command = 'USER_COMMAND'
    *            i_grid_title           = outtext
                is_layout               = gd_layout
                it_fieldcat             = fieldcatalog[]
    *            it_special_groups       = gd_tabgroup
    *            IT_EVENTS                = GT_XEVENTS
                i_save                  = 'X'
    *            is_variant              = z_template
           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  DATA_RETRIEVAL
    *       Retrieve data form EKPO table and populate itab it_ekko
    form data_retrieval.
    select ebeln ebelp statu aedat matnr menge meins netpr peinh
    up to 10 rows
      from ekpo
      into table it_ekko.
    endform.                    " DATA_RETRIEVAL
    gowri
    Message was edited by:
            Gowri Krishna

  • How to devide the top of page in alv grid display

    hi all
    in the alv grid display am getting the page number and total number of pages in the left hand side
    but what i need is i need in the right hand side
    how to get that

    Hi,
    PLease refer to the code below:
    *& Report  ZDEMO_ALVGRID                                               *
    *& Example of a simple ALV Grid Report                                 *
    *& The basic requirement for this demo is to display a number of       *
    *& fields from the EKKO table.                                         *
    REPORT  zdemo_alvgrid                 .
    TABLES:     ekko.
    type-pools: slis.                                 "ALV Declarations
    *Data Declaration
    TYPES: BEGIN OF t_ekko,
      ebeln TYPE ekpo-ebeln,
      ebelp TYPE ekpo-ebelp,
      statu TYPE ekpo-statu,
      aedat TYPE ekpo-aedat,
      matnr TYPE ekpo-matnr,
      menge TYPE ekpo-menge,
      meins TYPE ekpo-meins,
      netpr TYPE ekpo-netpr,
      peinh TYPE ekpo-peinh,
    END OF t_ekko.
    DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
          wa_ekko TYPE t_ekko.
    *ALV data declarations
    data: fieldcatalog type slis_t_fieldcat_alv with header line,
          gd_tab_group type slis_t_sp_group_alv,
          gd_layout    type slis_layout_alv,
          gd_repid     like sy-repid,
          gt_events     type slis_t_event,
          gd_prntparams type slis_print_alv.
    *Start-of-selection.
    START-OF-SELECTION.
    perform data_retrieval.
    perform build_fieldcatalog.
    perform build_layout.
    perform build_events.
    perform build_print_params.
    perform display_alv_report.
    *&      Form  BUILD_FIELDCATALOG
    *       Build Fieldcatalog for ALV Report
    form build_fieldcatalog.
    * There are a number of ways to create a fieldcat.
    * For the purpose of this example i will build the fieldcatalog manualy
    * by populating the internal table fields individually and then
    * appending the rows. This method can be the most time consuming but can
    * also allow you  more control of the final product.
    * Beware though, you need to ensure that all fields required are
    * populated. When using some of functionality available via ALV, such as
    * total. You may need to provide more information than if you were
    * simply displaying the result
    *               I.e. Field type may be required in-order for
    *                    the 'TOTAL' function to work.
      fieldcatalog-fieldname   = 'EBELN'.
      fieldcatalog-seltext_m   = 'Purchase Order'.
      fieldcatalog-col_pos     = 0.
      fieldcatalog-outputlen   = 10.
      fieldcatalog-emphasize   = 'X'.
      fieldcatalog-key         = 'X'.
    *  fieldcatalog-do_sum      = 'X'.
    *  fieldcatalog-no_zero     = 'X'.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'EBELP'.
      fieldcatalog-seltext_m   = 'PO Item'.
      fieldcatalog-col_pos     = 1.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'STATU'.
      fieldcatalog-seltext_m   = 'Status'.
      fieldcatalog-col_pos     = 2.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'AEDAT'.
      fieldcatalog-seltext_m   = 'Item change date'.
      fieldcatalog-col_pos     = 3.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MATNR'.
      fieldcatalog-seltext_m   = 'Material Number'.
      fieldcatalog-col_pos     = 4.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MENGE'.
      fieldcatalog-seltext_m   = 'PO quantity'.
      fieldcatalog-col_pos     = 5.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MEINS'.
      fieldcatalog-seltext_m   = 'Order Unit'.
      fieldcatalog-col_pos     = 6.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'NETPR'.
      fieldcatalog-seltext_m   = 'Net Price'.
      fieldcatalog-col_pos     = 7.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-do_sum      = 'X'.
      fieldcatalog-datatype     = 'CURR'.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'PEINH'.
      fieldcatalog-seltext_m   = 'Price Unit'.
      fieldcatalog-col_pos     = 8.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
    endform.                    " BUILD_FIELDCATALOG
    *&      Form  BUILD_LAYOUT
    *       Build layout for ALV grid report
    form build_layout.
      gd_layout-no_input          = 'X'.
      gd_layout-colwidth_optimize = 'X'.
      gd_layout-totals_text       = 'Totals'(201).
    *  gd_layout-totals_only        = 'X'.
    *  gd_layout-f2code            = 'DISP'.  "Sets fcode for when double
    *                                         "click(press f2)
    *  gd_layout-zebra             = 'X'.
    *  gd_layout-group_change_edit = 'X'.
    *  gd_layout-header_text       = 'helllllo'.
    endform.                    " BUILD_LAYOUT
    *&      Form  DISPLAY_ALV_REPORT
    *       Display report using ALV grid
    form display_alv_report.
      gd_repid = sy-repid.
      call function 'REUSE_ALV_GRID_DISPLAY'
           exporting
                i_callback_program      = gd_repid
                i_callback_top_of_page   = 'TOP-OF-PAGE'  "see FORM
                i_callback_user_command = 'USER_COMMAND'
    *            i_grid_title           = outtext
                is_layout               = gd_layout
                it_fieldcat             = fieldcatalog[]
    *            it_special_groups       = gd_tabgroup
                it_events               = gt_events
                is_print                = gd_prntparams
                i_save                  = 'X'
    *            is_variant              = z_template
           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  DATA_RETRIEVAL
    *       Retrieve data form EKPO table and populate itab it_ekko
    form data_retrieval.
    select ebeln ebelp statu aedat matnr menge meins netpr peinh
    up to 10 rows
      from ekpo
      into table it_ekko.
    endform.                    " DATA_RETRIEVAL
    * Form  TOP-OF-PAGE                                                 *
    * ALV Report Header                                                 *
    Form top-of-page.
    *ALV Header declarations
    data: t_header type slis_t_listheader,
          wa_header type slis_listheader,
          t_line like wa_header-info,
          ld_lines type i,
          ld_linesc(10) type c.
    * Title
      wa_header-typ  = 'H'.
      wa_header-info = 'EKKO Table Report'.
      append wa_header to t_header.
      clear wa_header.
    * Date
      wa_header-typ  = 'S'.
      wa_header-key = 'Date: '.
      CONCATENATE  sy-datum+6(2) '.'
                   sy-datum+4(2) '.'
                   sy-datum(4) INTO wa_header-info.   "todays date
      append wa_header to t_header.
      clear: wa_header.
    * Total No. of Records Selected
      describe table it_ekko lines ld_lines.
      ld_linesc = ld_lines.
      concatenate 'Total No. of Records Selected: ' ld_linesc
                        into t_line separated by space.
      wa_header-typ  = 'A'.
      wa_header-info = t_line.
      append wa_header to t_header.
      clear: wa_header, t_line.
      call function 'REUSE_ALV_COMMENTARY_WRITE'
           exporting
                it_list_commentary = t_header.
    *            i_logo             = 'Z_LOGO'.
    endform.
    *       FORM USER_COMMAND                                          *
    *       --> R_UCOMM                                                *
    *       --> RS_SELFIELD                                            *
    FORM user_command USING r_ucomm LIKE sy-ucomm
                      rs_selfield TYPE slis_selfield.
    * Check function code
      CASE r_ucomm.
        WHEN '&IC1'.
    *   Check field clicked on within ALVgrid report
        IF rs_selfield-fieldname = 'EBELN'.
    *     Read data table, using index of row user clicked on
          READ TABLE it_ekko INTO wa_ekko INDEX rs_selfield-tabindex.
    *     Set parameter ID for transaction screen field
          SET PARAMETER ID 'BES' FIELD wa_ekko-ebeln.
    *     Sxecute transaction ME23N, and skip initial data entry screen
          CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
        ENDIF.
      ENDCASE.
    ENDFORM.
    *&      Form  BUILD_EVENTS
    *       Build events table
    form build_events.
      data: ls_event type slis_alv_event.
      call function 'REUSE_ALV_EVENTS_GET'
           exporting
                i_list_type = 0
           importing
                et_events   = gt_events[].
      read table gt_events with key name =  slis_ev_end_of_page
                               into ls_event.
      if sy-subrc = 0.
        move 'END_OF_PAGE' to ls_event-form.
        append ls_event to gt_events.
      endif.
        read table gt_events with key name =  slis_ev_end_of_list
                               into ls_event.
      if sy-subrc = 0.
        move 'END_OF_LIST' to ls_event-form.
        append ls_event to gt_events.
      endif.
    endform.                    " BUILD_EVENTS
    *&      Form  BUILD_PRINT_PARAMS
    *       Setup print parameters
    form build_print_params.
      gd_prntparams-reserve_lines = '3'.   "Lines reserved for footer
      gd_prntparams-no_coverpage = 'X'.
    endform.                    " BUILD_PRINT_PARAMS
    *&      Form  END_OF_PAGE
    form END_OF_PAGE.
      data: listwidth type i,
            ld_pagepos(10) type c,
            ld_page(10)    type c.
      write: sy-uline(50).
      skip.
      write:/40 'Page:', sy-pagno .
    endform.
    *&      Form  END_OF_LIST
    form END_OF_LIST.
      data: listwidth type i,
            ld_pagepos(10) type c,
            ld_page(10)    type c.
      skip.
      write:/40 'Page:', sy-pagno .
    endform.
    Thanks,
    Sriram Ponna.

  • Kindly help to develop alv grid display

    Hi ,
    I have a requirement in which I need to display ALV GRID display and in its tool bar 4 butons are required. In the same view down to alv display i want to develop a tabstrip and its functionalities.I have designed classic alv using SALV_WD_TABLE component. I want a good GRID Display, not like flat field names that comes in list display, looking for bulged fields(like what comes for ALV GRID in normal abap)  display with print version etc hidden and buttons at the top of ALV.  Kindly help
    Highly rewarded
    Kindly help
    Regards,
    Lakshmi
    Edited by: Lakshmi Menon on Nov 27, 2008 4:49 PM

    Well Web Dynpro is generally output in HTML so the output formatting is never going to quite look like a desktop application (which is the case with the ALV Grid).  You have very little control over the look of the column headers.  In fact you can only manipulate what is available via the Portal Theme. 
    There is a new Tradeshow Plus theme available in NetWeaver 7.01 which uses a gradiant background for the column headers.  This gives them a little more depth:
    http://www.flickr.com/photos/tjung/3068850120/
    The other option is next year when NetWeaver Business Client version 3.0 comes out, you will be able to render Web Dynpro applications using the NWBC Smart Client Rendering.  This will render Web Dynpro applications using desktop libraries instead of HTML/Browser. This gives Web Dynpro a more SAPGUI/Desktop appears of course.
    http://www.flickr.com/photos/tjung/2685619882/in/set-72157606418550143/

  • Folder in alv grid display report

    Hi Experts,
    I have a requirement  to generate the folder in alv grid display, to display the multiple line items where ever we have.
    Actually I am displaying the material details and production order details.
    If the material is having the multiple production order details , in that case we need to place all the production order details in one folder, and if you open that folder arrow, we have to display the production order details.
    I am using REUSE_ALV_GRID_DISPLAY function module to develope this application. Here Hierseq list is recommended to use for this application, why because folder option is already available in grid display. that we can observe in CL6AN. 
    Is it possible to implement it through function modules or through OOABAP.
    Actually, I have to generate the report which we can see in CL6AN Transaction code,,
    Your valuable suggestions surely will attract the benifits.
    Thanks in advance.
    Ramesh.

    Hi ramesh,
    Hierseq list is not supported in the grid display. You could do this using an OO tree display but this could be rather complicated. What about displaying one field per material line with the number of production orders. At double-click on that field, open a second grid display (possibly as popup) to show the production order details.
    Regards,
    Clemens

  • Update values in AlV grid display after entering value

    Hi,
         I have an issue in ALV grid display.
        Let me explain.
        i have 8 fields to display in which one is editiable.
       Fields are: date
                       material,
                       material Description,
                       Opening Stock,
                       Closing stock-  (  this field is editiable)
                       Closing stock,
                       Received Stock,
                       Actual production.
    Actual production = Closing stock + removal stock
                                 - receipt stock - opening stock.
    when i change the value of closing stock and press enter, actual production should get update, the new values should display.
    Thany you in advance.

    Hi,
    Please refer the code below:
    REPORT z_demo_alv_jg.*******************************************************************
    * TYPE-POOLS                                                      *
    TYPE-POOLS: slis. *******************************************************************
    * INTERNAL TABLES/WORK AREAS/VARIABLES     *
    DATA: i_fieldcat TYPE slis_t_fieldcat_alv,
          i_index TYPE STANDARD TABLE OF i WITH HEADER LINE,
          w_field TYPE slis_fieldcat_alv,
          p_table LIKE dd02l-tabname,
          dy_table TYPE REF TO data,
          dy_tab TYPE REF TO data,
          dy_line TYPE REF TO data.*******************************************************************
    * FIELD-SYMBOLS                                                   *
    FIELD-SYMBOLS: <dyn_table> TYPE STANDARD TABLE,
                   <dyn_wa> TYPE ANY,
                   <dyn_field> TYPE ANY,
                   <dyn_tab_temp> TYPE STANDARD TABLE.*******************************************************************
    * SELECTION SCREEN                                                *
    PARAMETERS: tabname(30) TYPE c,
                lines(5)  TYPE n.*******************************************************************
    * START-OF-SELECTION                                              *
    START-OF-SELECTION.* Storing table name
      p_table = tabname.* Create internal table dynamically with the stucture of table name
    * entered in the selection screen
      CREATE DATA dy_table TYPE STANDARD TABLE OF (p_table).
      ASSIGN dy_table->* TO <dyn_table>.
      IF sy-subrc <> 0.
        MESSAGE i000(z_zzz_ca_messages) WITH ' No table found'.    LEAVE TO LIST-PROCESSING.
      ENDIF.
    * Create workarea for the table
      CREATE DATA dy_line LIKE LINE OF <dyn_table>.
      ASSIGN dy_line->* TO <dyn_wa>.* Create another temp. table
      CREATE DATA dy_tab TYPE STANDARD TABLE OF (p_table).
      ASSIGN dy_tab->* TO <dyn_tab_temp>.  SORT i_fieldcat BY col_pos.* Select data from table
      SELECT * FROM (p_table)
      INTO TABLE <dyn_table>
      UP TO lines ROWS.  REFRESH <dyn_tab_temp>.* Display report
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
        EXPORTING
          i_callback_program       = sy-repid
          i_structure_name         = p_table
          i_callback_user_command  = 'USER_COMMAND'
          i_callback_pf_status_set = 'SET_PF_STATUS'
        TABLES
          t_outtab                 = <dyn_table>
        EXCEPTIONS
          program_error            = 1
          OTHERS                   = 2.  IF sy-subrc <> 0.  ENDIF.*&-----------------------------------------------------------------*
    *&      Form  SET_PF_STATUS
    *       Setting custom PF-Status
    *      -->RT_EXTAB   Excluding table
    FORM set_pf_status USING rt_extab TYPE slis_t_extab.  SET PF-STATUS 'Z_STANDARD'.ENDFORM.                    "SET_PF_STATUS*&----------------------------------------------------------------*
    *&      Form  user_command
    *       Handling custom function codes
    *      -->R_UCOMM      Function code value
    *      -->RS_SELFIELD  Info. of cursor position in ALV
    FORM user_command  USING    r_ucomm LIKE sy-ucomm
                               rs_selfield TYPE slis_selfield.* Local data declaration
      DATA: li_tab TYPE REF TO data,
            l_line TYPE REF TO data.* Local field-symbols
      FIELD-SYMBOLS:<l_tab> TYPE table,
                    <l_wa>  TYPE ANY.* Create table
      CREATE DATA li_tab TYPE STANDARD TABLE OF (p_table).
      ASSIGN li_tab->* TO <l_tab>.* Create workarea
      CREATE DATA l_line LIKE LINE OF <l_tab>.
      ASSIGN l_line->* TO <l_wa>.  CASE r_ucomm.*   When a record is selected
        WHEN '&IC1'.*     Read the selected record
          READ TABLE <dyn_table> ASSIGNING <dyn_wa> INDEX
          rs_selfield-tabindex.      IF sy-subrc = 0.*       Store the record in an internal table
            APPEND <dyn_wa> TO <l_tab>.*       Fetch the field catalog info
            CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
              EXPORTING
                i_program_name         = 'Z_DEMO_PDF_JG'
                i_structure_name       = p_table
              CHANGING
                ct_fieldcat            = i_fieldcat
              EXCEPTIONS
                inconsistent_interface = 1
                program_error          = 2
                OTHERS                 = 3.
            IF sy-subrc = 0.*         Make all the fields input enabled except key fields
              w_field-input = 'X'.          MODIFY i_fieldcat FROM w_field TRANSPORTING input
              WHERE key IS INITIAL.        ENDIF.*       Display the record for editing purpose
            CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
              EXPORTING
                i_callback_program    = sy-repid
                i_structure_name      = p_table
                it_fieldcat           = i_fieldcat
                i_screen_start_column = 10
                i_screen_start_line   = 15
                i_screen_end_column   = 200
                i_screen_end_line     = 20
              TABLES
                t_outtab              = <l_tab>
              EXCEPTIONS
                program_error         = 1
                OTHERS                = 2.        IF sy-subrc = 0.*         Read the modified data
              READ TABLE <l_tab> INDEX 1 INTO <l_wa>.*         If the record is changed then track its index no.
    *         and populate it in an internal table for future
    *         action
              IF sy-subrc = 0 AND <dyn_wa> <> <l_wa>.
                <dyn_wa> = <l_wa>.
                i_index = rs_selfield-tabindex.
                APPEND i_index.
              ENDIF.
            ENDIF.      ENDIF.*   When save button is pressed
        WHEN 'SAVE'.*     Sort the index table
          SORT i_index.*     Delete all duplicate records
          DELETE ADJACENT DUPLICATES FROM i_index.      LOOP AT i_index.*       Find out the changes in the internal table
    *       and populate these changes in another internal table
            READ TABLE <dyn_table> ASSIGNING <dyn_wa> INDEX i_index.
            IF sy-subrc = 0.
              APPEND <dyn_wa> TO <dyn_tab_temp>.
            ENDIF.      ENDLOOP.*     Lock the table
          CALL FUNCTION 'ENQUEUE_E_TABLE'
            EXPORTING
              mode_rstable   = 'E'
              tabname        = p_table
            EXCEPTIONS
              foreign_lock   = 1
              system_failure = 2
              OTHERS         = 3.      IF sy-subrc = 0.*       Modify the database table with these changes
            MODIFY (p_table) FROM TABLE <dyn_tab_temp>.        REFRESH <dyn_tab_temp>.*       Unlock the table
            CALL FUNCTION 'DEQUEUE_E_TABLE'
              EXPORTING
                mode_rstable = 'E'
                tabname      = p_table.      ENDIF.
      ENDCASE.  rs_selfield-refresh = 'X'.ENDFORM.                    "user_command
    Thanks,
    Sriram Ponna.

  • How to capture the checkbox status in ALV Grid display

    I need some immediate help regarding Grid ALV.
    My Requirement: I need to display an ALV grid report along with checkboxes. Further, I need to provide an option wherein the user can checkboxes and select the records that I need to process further (by clicking the process button on the ALV Report).
    My Query: The problem here is that I am not able to capture the status of the checkboxes. This means that I am not able to capture which of the records have been selected by checking their resp checkboxes.
    Solutions that I have tried: I have tried capturing the same at user command by checking the value in slis_selfield. But all the records show the value as 1 for the checkbox field.
    Kinldy suggest how to go about it.
    I am not using Object Oriented ALV. Please suggest something to be used in ALV Grid display in 4.6C version.
    Regards,
    Namrata

    Here is a Sample code , it might help you
    TABLES : sflight.
    TYPE-POOLS: slis.
    DATA : w_repid LIKE sy-repid.
    w_repid = sy-repid.
    DATA: BEGIN OF it_sflight OCCURS 0,
      checkbox(1),
      carrid LIKE sflight-carrid,
    END OF it_sflight.
    *layout
    DATA: wa_layout TYPE slis_layout_alv.
    *field catalog
    DATA: it_fieldcatalog TYPE slis_t_fieldcat_alv,
              wa_fieldcatalog TYPE slis_fieldcat_alv.
    START-OF-SELECTION.
      SELECT carrid FROM sflight
         INTO CORRESPONDING FIELDS OF TABLE it_sflight.
    END-OF-SELECTION.
      CLEAR it_fieldcatalog.
      REFRESH it_fieldcatalog.
      wa_fieldcatalog-fieldname = 'CHECKBOX'.
      wa_fieldcatalog-outputlen = '3'.
      wa_fieldcatalog-col_pos = '1'.
      wa_fieldcatalog-seltext_m = 'Chk'.
      wa_fieldcatalog-checkbox = 'X'.
      wa_fieldcatalog-edit = 'X'.
      APPEND wa_fieldcatalog TO it_fieldcatalog.
      CLEAR wa_fieldcatalog.
      wa_fieldcatalog-fieldname = 'CARRID'.
      wa_fieldcatalog-outputlen = '10'.
      wa_fieldcatalog-col_pos = '2'.
      wa_fieldcatalog-seltext_m = 'Carrid'.
      APPEND wa_fieldcatalog TO it_fieldcatalog.
      CLEAR wa_fieldcatalog.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program = w_repid
          is_layout = wa_layout
          i_callback_user_command = 'USER_COMMAND'
          it_fieldcat = it_fieldcatalog
        TABLES
          t_outtab = it_sflight
        EXCEPTIONS
          program_error = 1
          OTHERS = 2.
    *& Form USER_COMMAND
    FORM user_command USING p_ucomm TYPE sy-ucomm
      p_selfld TYPE slis_selfield.
      CASE p_ucomm.
       WHEN '&DATA_SAVE'.
          DATA ref1 TYPE REF TO cl_gui_alv_grid.
          CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
             IMPORTING
               e_grid = ref1.
          CALL METHOD ref1->check_changed_data.
          LOOP AT it_sflight WHERE checkbox = 'X'.
             DELETE it_sflight INDEX sy-tabix.
          ENDLOOP.
          p_selfld-refresh = 'X'.
      ENDCASE.
    ENDFORM. "user_command

  • How to color a row in ALV grid display

    Hi,
    A few rows in the output of ALV grid display should be shown in different color.How can I achieve this?

    Hi,
    Try out this code
    DATA : BEGIN OF G_T_CASH OCCURS 0,
           PARTICULARS TYPE CHAR120,
           AMOUNT1 TYPE CHAR20,
           AMOUNT2 TYPE CHAR20,
           AMOUNT3 TYPE CHAR20,    
           ROW_COLOR TYPE CHAR4,----
    add this in the internal table for alv
          END OF G_T_CASH.
      CLEAR G_WA_CASH.
      G_WA_CASH-PARTICULARS = 'Opening Cash Balance'.
      G_WA_CASH-AMOUNT1 = G_DMBTR.
      G_WA_CASH-AMOUNT2 = ''.
      G_WA_CASH-AMOUNT3 = ''.
    while appending other values also add the following code
      G_WA_CASH-ROW_COLOR = 'C200'.----- C200 depicts light gray color
      APPEND G_WA_CASH TO G_T_CASH.
    add the following code in layout
    MOVE 'ROW_COLOR' TO WA_LS_LAYOUT-INFO_FIELDNAME.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          I_BYPASSING_BUFFER = ' '
          I_SAVE             = 'A'
        I_CALLBACK_PROGRAM                = SY-REPID
      I_CALLBACK_PF_STATUS_SET          = 'SET_PF_STATUS'
       I_CALLBACK_USER_COMMAND           = 'USER_COMMAND'
         IS_LAYOUT                        = WA_LS_LAYOUT
         IT_FIELDCAT                      = G_T_CATALOG
         IT_EVENTS                         = GT_EVENTS
         TABLES
           T_OUTTAB                       = G_T_CASH[]
    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.
    Let me know if the problem still persist.
    Regards,
    Janaki

  • Problem with ALV Grid Display screen Back Button

    Dear Friends ,
    I have an ALV Grid Display,Here am facing a problem for my 'Back' button,i haven't defined any PF Status and is using the standard one.But after the Display when i press Back Button a blank Screen is appearing n then again i have to press back button to go to my Selection Screen.
    Please Suggest if i have to take care of something else.
    I want my Selection Screen when i press Back on my Display Screen.
    DATA:  IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
           FIELDCAT TYPE SLIS_FIELDCAT_ALV.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
            EXPORTING
             I_BYPASSING_BUFFER          =
             I_BUFFER_ACTIVE             =
             I_INTERFACE_CHECK           = ' '
                 I_CALLBACK_PROGRAM          = 'ZRMMPD01A'
             I_CALLBACK_PF_STATUS_SET    = ' '
             I_CALLBACK_USER_COMMAND     = ' '
             I_CALLBACK_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_GRID_SETTINGS             =
               IS_LAYOUT                     =  I_LAYOUT
               IT_FIELDCAT                 =  IT_FIELDCAT
             IT_EXCLUDING                =
             IT_SPECIAL_GROUPS           =
             IT_SORT                     =
             IT_FILTER                   =
             IS_SEL_HIDE                 =
             I_DEFAULT                   = 'X'
             I_SAVE                      = ' '
             IS_VARIANT                  =
             IT_EVENTS                   =
             IT_EVENT_EXIT               =
             IS_PRINT                    =
             IS_REPREP_ID                =
             I_SCREEN_START_COLUMN       = 0
             I_SCREEN_START_LINE         = 0
             I_SCREEN_END_COLUMN         = 0
             I_SCREEN_END_LINE           = 0
        IMPORTING
             E_EXIT_CAUSED_BY_CALLER     =
             ES_EXIT_CAUSED_BY_USER      =
             TABLES
                  T_OUTTAB                    = IT_FINAL
            EXCEPTIONS
                 PROGRAM_ERROR               = 1
                 OTHERS                      = 2
    Thanks and Regards,
    Ashwini

    Hi Vijay ,
    No i dont have any write statement in my proggram.
    Here it is
    REPORT ZRMMPD01A  NO STANDARD PAGE HEADING.
    TABLES : EQUI,SER03,MKPF,OBJK.
    TYPE-POOLS : SLIS.
    DATA  IT_EQUI LIKE EQUI OCCURS 0 WITH HEADER LINE.
    DATA  IT_OBJK LIKE OBJK OCCURS 0 WITH HEADER LINE..
    DATA  IT_SER03 LIKE SER03 OCCURS 0 WITH HEADER LINE.
    DATA  IT_MKPF LIKE MKPF OCCURS 0 WITH HEADER LINE .
    DATA : BEGIN OF IT_DISPLAY OCCURS 0,
                MATNR LIKE EQUI-MATNR,
                SERNR LIKE EQUI-SERNR,
                BWART LIKE SER03-BWART,
                WERK LIKE SER03-WERK,
                CHARGE LIKE SER03-CHARGE,
                LAGERORT LIKE SER03-LAGERORT,
                MBLNR LIKE SER03-MBLNR,
                MJAHR LIKE SER03-MJAHR,
                ZEILE LIKE SER03-ZEILE,
                BUDAT LIKE MKPF-BUDAT,
                BKTXT LIKE MKPF-BKTXT,
                USNAM LIKE MKPF-USNAM,
                XBLNR LIKE MKPF-XBLNR,
            END OF IT_DISPLAY.
    DATA : WA_DISPLAY LIKE IT_DISPLAY.
    DATA  IT_FINAL LIKE IT_DISPLAY OCCURS 0 WITH HEADER LINE.
    DATA  IT_TEMP LIKE IT_DISPLAY OCCURS 0 WITH HEADER LINE.
    DATA:  IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
           FIELDCAT TYPE SLIS_FIELDCAT_ALV.
    DATA :I_LAYOUT TYPE SLIS_LAYOUT_ALV,
          I_EVENTS TYPE SLIS_T_EVENT.
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
    SELECT-OPTIONS : S_MATNR FOR EQUI-MATNR MATCHCODE OBJECT MCD,"OBLIGATORY
                    S_SERNR FOR EQUI-SERNR, "MATCHCODE OBJECT MCD OBLIGATORY
                    S_MBLNR FOR SER03-MBLNR MATCHCODE OBJECT MCD,
                    S_BWART FOR SER03-BWART MATCHCODE OBJECT MCD,
                    S_WERK FOR SER03-WERK MATCHCODE OBJECT MCD,
                    S_LAGET FOR SER03-LAGERORT MATCHCODE OBJECT MCD,
                    S_BUDAT FOR MKPF-BUDAT MATCHCODE OBJECT MCD,
                    S_XBLNR FOR MKPF-XBLNR MATCHCODE OBJECT MCD.
    SELECTION-SCREEN END OF BLOCK B1.
    SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-002.
    PARAMETERS : R1 RADIOBUTTON GROUP G1 DEFAULT 'X',
                 R2 RADIOBUTTON GROUP G1.
    SELECTION-SCREEN END OF BLOCK B2.
    START-OF-SELECTION.
    *Fetch Data.
      PERFORM GET_DATA.
    *Fill Display Fields.
      PERFORM FILL_TABLE.
    *Segregate data according to radio button selection.
      PERFORM SELECT_CONDITION.
    *Fill The Feild catalog.
      PERFORM FIELD_CATALOG.
    *Display Output.
      PERFORM OUTPUT_DISPLAY..
    *&      Form  GET_DATA
          text
    -->  p1        text
    <--  p2        text
    FORM GET_DATA.
      SELECT * FROM EQUI INTO TABLE IT_EQUI
        WHERE MATNR IN S_MATNR
        AND SERNR IN S_SERNR.
      SELECT * FROM OBJK INTO TABLE IT_OBJK
      FOR ALL ENTRIES IN IT_EQUI
      WHERE EQUNR = IT_EQUI-EQUNR.
      SELECT * FROM SER03 INTO TABLE IT_SER03
      FOR ALL ENTRIES IN IT_OBJK
      WHERE OBKNR = IT_OBJK-OBKNR
      AND MBLNR IN S_MBLNR
      AND BWART IN S_BWART
      AND WERK IN S_WERK
      AND LAGERORT IN S_LAGET.
      SELECT * FROM MKPF INTO TABLE IT_MKPF
      FOR ALL ENTRIES IN IT_SER03
      WHERE MBLNR = IT_SER03-MBLNR
      AND BUDAT IN S_BUDAT
      AND XBLNR IN S_XBLNR.
    ENDFORM.                    " GET_DATA
    *&      Form  FILL_TABLE
          text
    -->  p1        text
    <--  p2        text
    FORM FILL_TABLE.
      LOOP AT IT_EQUI.
        LOOP AT IT_OBJK.
          IF IT_OBJK-EQUNR <> IT_EQUI-EQUNR.
            SKIP.
          ELSE.
            READ TABLE IT_SER03 WITH KEY OBKNR = IT_OBJK-OBKNR.
            IF SY-SUBRC = 0.
              WA_DISPLAY-MATNR = IT_EQUI-MATNR.
              WA_DISPLAY-SERNR = IT_EQUI-SERNR.
              WA_DISPLAY-BWART = IT_SER03-BWART.
              WA_DISPLAY-WERK = IT_SER03-WERK.
              WA_DISPLAY-CHARGE = IT_SER03-CHARGE.
              WA_DISPLAY-LAGERORT = IT_SER03-LAGERORT.
              WA_DISPLAY-MBLNR = IT_SER03-MBLNR.
              WA_DISPLAY-MJAHR = IT_SER03-MJAHR.
              WA_DISPLAY-ZEILE = IT_SER03-ZEILE.
             READ TABLE IT_MKPF WITH KEY MBLNR = IT_SER03-MBLNR.
              IF SY-SUBRC = 0.
                WA_DISPLAY-BUDAT = IT_MKPF-BUDAT.
                WA_DISPLAY-BKTXT = IT_MKPF-BKTXT.
                WA_DISPLAY-USNAM = IT_MKPF-USNAM.
                WA_DISPLAY-XBLNR = IT_MKPF-XBLNR.
              ENDIF.
            ENDIF.
          ENDIF.
          IF NOT WA_DISPLAY IS INITIAL.
            APPEND WA_DISPLAY TO IT_DISPLAY.
            CLEAR WA_DISPLAY.
          ENDIF.
        ENDLOOP.
      ENDLOOP.
    ENDFORM.                    " FILL_TABLE
    *&      Form  FIELD_CATALOG
          text
    -->  p1        text
    <--  p2        text
    FORM FIELD_CATALOG.
      FIELDCAT-TABNAME = 'IT_DISPLAY'.
      FIELDCAT-FIELDNAME = 'MATNR'.
      FIELDCAT-SELTEXT_M = 'Material Number'.
      FIELDCAT-OUTPUTLEN =  18.
      APPEND FIELDCAT TO IT_FIELDCAT.
      CLEAR FIELDCAT.
      FIELDCAT-TABNAME = 'IT_DISPLAY'.
      FIELDCAT-FIELDNAME = 'SERNR'.
      FIELDCAT-SELTEXT_M = 'Serial number'.
      FIELDCAT-OUTPUTLEN =  18.
      APPEND FIELDCAT TO IT_FIELDCAT.
      CLEAR FIELDCAT.
      FIELDCAT-TABNAME = 'IT_DISPLAY'.
      FIELDCAT-FIELDNAME = 'MBLNR'.
      FIELDCAT-SELTEXT_L = 'Number of material document'.
      FIELDCAT-OUTPUTLEN =  18.
      APPEND FIELDCAT TO IT_FIELDCAT.
      CLEAR FIELDCAT.
      FIELDCAT-TABNAME = 'IT_DISPLAY'.
      FIELDCAT-FIELDNAME = 'BWART'.
      FIELDCAT-SELTEXT_M = 'Movement type'.
      FIELDCAT-OUTPUTLEN =  18.
      APPEND FIELDCAT TO IT_FIELDCAT.
      CLEAR FIELDCAT.
      FIELDCAT-TABNAME = 'IT_DISPLAY'.
      FIELDCAT-FIELDNAME = 'WERK'.
      FIELDCAT-SELTEXT_M = 'Plant'.
      FIELDCAT-OUTPUTLEN =  5.
      APPEND FIELDCAT TO IT_FIELDCAT.
      CLEAR FIELDCAT.
      FIELDCAT-TABNAME = 'IT_DISPLAY'.
      FIELDCAT-FIELDNAME = 'CHARGE'.
      FIELDCAT-SELTEXT_M = 'Batch number'.
      FIELDCAT-OUTPUTLEN =  18.
      APPEND FIELDCAT TO IT_FIELDCAT.
      CLEAR FIELDCAT.
      FIELDCAT-TABNAME = 'IT_DISPLAY'.
      FIELDCAT-FIELDNAME = 'LAGERORT'.
      FIELDCAT-SELTEXT_M = 'Storage Location'.
      FIELDCAT-OUTPUTLEN =  18.
      APPEND FIELDCAT TO IT_FIELDCAT.
      CLEAR FIELDCAT.
      FIELDCAT-TABNAME = 'IT_DISPLAY'.
      FIELDCAT-FIELDNAME = 'MJAHR'.
      FIELDCAT-SELTEXT_M = 'Material doc. year'.
      FIELDCAT-OUTPUTLEN =  18.
      APPEND FIELDCAT TO IT_FIELDCAT.
      CLEAR FIELDCAT.
      FIELDCAT-TABNAME = 'IT_DISPLAY'.
      FIELDCAT-FIELDNAME = 'ZEILE'.
      FIELDCAT-SELTEXT_L = 'Item in material document'.
      FIELDCAT-OUTPUTLEN =  18.
      APPEND FIELDCAT TO IT_FIELDCAT.
      CLEAR FIELDCAT.
      FIELDCAT-TABNAME = 'IT_DISPLAY'.
      FIELDCAT-FIELDNAME = 'BUDAT'.
      FIELDCAT-SELTEXT_L = 'Posting date in the document'.
      FIELDCAT-OUTPUTLEN =  10.
      APPEND FIELDCAT TO IT_FIELDCAT.
      CLEAR FIELDCAT.
      FIELDCAT-TABNAME = 'IT_DISPLAY'.
      FIELDCAT-FIELDNAME = 'BKTXT'.
      FIELDCAT-SELTEXT_L = 'Document header text'.
      FIELDCAT-OUTPUTLEN =  25.
      APPEND FIELDCAT TO IT_FIELDCAT.
      CLEAR FIELDCAT.
      FIELDCAT-TABNAME = 'IT_DISPLAY'.
      FIELDCAT-FIELDNAME = 'USNAM'.
      FIELDCAT-SELTEXT_M = 'User name'.
      FIELDCAT-OUTPUTLEN =  15.
      APPEND FIELDCAT TO IT_FIELDCAT.
      CLEAR FIELDCAT.
      FIELDCAT-TABNAME = 'IT_DISPLAY'.
      FIELDCAT-FIELDNAME = 'XBLNR'.
      FIELDCAT-SELTEXT_L = 'Reference document number'.
      FIELDCAT-OUTPUTLEN =  25.
      APPEND FIELDCAT TO IT_FIELDCAT.
      CLEAR FIELDCAT.
    ENDFORM.                    " FIELD_CATALOG
    *&      Form  DISPLAY_OUTPUT
          text
    -->  p1        text
    <--  p2        text
    FORM OUTPUT_DISPLAY.
      IF R1 = 'X'.
        CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
          EXPORTING
              I_CALLBACK_PROGRAM          = 'ZRMMPD01A'
              IS_LAYOUT                   =  I_LAYOUT
              IT_FIELDCAT                 = IT_FIELDCAT
          TABLES
              T_OUTTAB                    = IT_DISPLAY
            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.
        REFRESH IT_DISPLAY.
        CLEAR IT_DISPLAY.
      ELSEIF R2 = 'X'.
        CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
            EXPORTING
                 I_CALLBACK_PROGRAM          = 'ZRMMPD01A'
                 IS_LAYOUT                     =  I_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.
        REFRESH IT_DISPLAY.
        CLEAR IT_DISPLAY.
      ENDIF.
    ENDFORM.                    " DISPLAY_OUTPUT
    *&      Form  SELECT_CONDITION
          text
    -->  p1        text
    <--  p2        text
    FORM SELECT_CONDITION.
      IF R2 = 'X'.
        CLEAR WA_DISPLAY.
        SORT IT_DISPLAY BY MATNR SERNR MBLNR ZEILE.
        DELETE ADJACENT DUPLICATES FROM IT_DISPLAY.
        LOOP AT IT_DISPLAY WHERE ZEILE = '0002'.
          READ TABLE IT_DISPLAY WITH KEY MATNR = IT_DISPLAY-MATNR
          SERNR = IT_DISPLAY-SERNR ZEILE = '0001'.
          IF SY-SUBRC = 0.
            DELETE IT_DISPLAY.
          ENDIF.
        ENDLOOP.
        SORT IT_DISPLAY BY MATNR SERNR BWART MBLNR.
        DELETE ADJACENT DUPLICATES FROM IT_DISPLAY.
        LOOP AT IT_DISPLAY.
          IF WA_DISPLAY IS INITIAL.
            WA_DISPLAY =  IT_DISPLAY.
          ENDIF.
          LOOP AT IT_DISPLAY WHERE MATNR = WA_DISPLAY-MATNR
          AND SERNR = WA_DISPLAY-SERNR.
            IF IT_DISPLAY-BUDAT > WA_DISPLAY-BUDAT.
              WA_DISPLAY = IT_DISPLAY.
            ELSE.
              DELETE IT_DISPLAY.
            ENDIF.
          ENDLOOP.
          APPEND WA_DISPLAY TO IT_TEMP.
          CLEAR WA_DISPLAY.
        ENDLOOP.
        DELETE ADJACENT DUPLICATES FROM IT_TEMP.
        IF NOT IT_TEMP[] IS INITIAL.
          IT_FINAL[] = IT_TEMP[].
        ENDIF.
      ENDIF.
    ENDFORM.                    " SELECT_CONDITION
    Regards,
    Ashwini

  • New Page in ALV GRID display.

    HI Experts,
    I have a requirement of displaying top of page and corresponding detailed records for specific combination of top of page(say plant,material,batch etc). Again for the next combination I need repeated header and detail list.
    I guess I have to use NEW PAGE to get this.
    However, I am using the REUSE ALV GRID DISPLAY for which the sort table does not display as required.
    Could you please help me  on this?
    In addition could you please suggest how to use NEW page in report without using OOPS concept.
    Please reply.
    Thanks,
    Suchi.

    Hi,
    1.Put a pushbutton  on the ALV o/p say 'Next'.
    2. Now in the user comand routine you have to change the  table contents u supply to reuse_alv_commentary write, also fill the o/p internal table with data corresponding to ur specific combination and supply to reuse_alv_grid_display.
    3.In the user comand routine u have  slis_selfield.
    4.It contains a component refresh, mark it as 'X'.( slis_selfield-refresh = 'X'.)
    5.No need of new page or calling reus_alv_grid_display number of times.
    Regards,
    Phani.

  • Maximum number of character we can print in a column uing ALV grid display

    Hi frnds,
    My requirment is to print 500 charcter data in a column using ALV grid display.
    Could any body tell me is it possible and the maximum character it can i print in a column using ALV grid dispaly.
    Regards,
    Sandipan

    Hi Sandipan,
    refer notes 857823, 910300 and 959775. All these say there is a limitation of 128 characters.
    857823 - ALV grid: Strings with a maximum of 128 characters
    Symptom
    Entries in cells of the type CHAR or string are truncated after 128
    characters in the SAP GUI.
    also refer,
    ALV Grid Control (cl_gui_alv_grid), function module (Full-screen) Grid
    (Reuse_alv_grid_display, SAPLSLVC_FULLSCREEN), SAPGUI, back end, front end
    Cause and Prerequisites
    The data table that is sent to the front end only allows character values
    with the length 128.
    Solution
    This is the standard system behavior and cannot be changed.

  • How change standard field lable in alv grid display

    Hi Experts,
        How are you doing! I am having some doubts in the alv grid display, I am new to this concepts.
    I want to display field  lable manually, actually its taking from table field discription but I want to display one field name manually.
    example code.
    ls_fldcat-fieldname = 'BPKIND'.
      ls_fldcat-ref_tabname = 'BUT000'.
      ls_fldcat-ref_fieldname = 'BPKIND'.
      APPEND ls_fldcat TO lt_fldcat.
      ls_fldcat-fieldname = 'PARTNER2'.
      ls_fldcat-ref_tabname = 'BUT051'.
      ls_fldcat-ref_fieldname = 'PARTNER2'.
    Here I dont want to display 'PARTNER2' I need 'KEY ACCOUNT MANAGER'.
    Please send me how to do this.
    Surya Ramireddy.

    Hi
      Please check out this program.
    Type-pools: slis.
    Tables: likp.
    Data: Begin of i_likp occurs 0,
            vbeln like likp-vbeln,
            ernam like likp-ernam,
            erzet like likp-erzet,
            erdat like likp-erdat,
          End of i_likp.
    Data: it_fieldcat type slis_t_fieldcat_alv,
          wa_fieldcat type SLIS_FIELDCAT_ALV,
          it_events type slis_t_event.
    Selection-screen: Begin of block b1 with frame title text-001.
      select-options: s_vbeln for likp-vbeln.
    Selection-screen: End of block b1.
    start-of-selection.
    perform get_sales_header_data.
    end-of-selection.
    perform field_catalogue.
    perform modify_field_catalogue.
    perform display_alv_grid_display.
    *&      Form  get_sales_header_data
          text
    -->  p1        text
    <--  p2        text
    form get_sales_header_data .
    select vbeln
           ernam
           erzet
           erdat
           into table i_likp
           from likp
           where vbeln in s_vbeln.
    endform.                    " get_sales_header_data
    *&      Form  field_catalogue
          text
    -->  p1        text
    <--  p2        text
    form field_catalogue .
    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
       I_PROGRAM_NAME               = sy-repid
       I_INTERNAL_TABNAME           = 'I_LIKP'
       I_INCLNAME                   = sy-repid
      CHANGING
        ct_fieldcat                  = it_fieldcat
    EXCEPTIONS
       INCONSISTENT_INTERFACE       = 1
       PROGRAM_ERROR                = 2
       OTHERS                       = 3
    endform.                    " field_catalogue
    *&      Form  modify_field_catalogue
          text
    -->  p1        text
    <--  p2        text
    form modify_field_catalogue .
    loop at it_fieldcat into wa_fieldcat.
    case wa_fieldcat-fieldname.
      when 'VBELN'.
       wa_fieldcat-col_pos = 1.
       wa_fieldcat-seltext_l = 'Sales Doc Header No'.
       wa_fieldcat-emphasize = 'C100'.
      when 'ERNAM'.
       wa_fieldcat-col_pos = 2.
       wa_fieldcat-seltext_l = 'Created By'.
       wa_fieldcat-emphasize = 'C200'.
      when 'ERZET'.
       wa_fieldcat-col_pos = 3.
       wa_fieldcat-seltext_l = 'Entry Time'.
       wa_fieldcat-emphasize = 'C300'.
      when 'ERDAT'.
       wa_fieldcat-col_pos = 4.
       wa_fieldcat-seltext_l = 'Created On'.
       wa_fieldcat-emphasize = 'C400'.
      endcase.
      modify it_fieldcat from wa_fieldcat.
    endloop.
    endform.                    " modify_field_catalogue
    *&      Form  display_alv_grid_display
          text
    -->  p1        text
    <--  p2        text
    form display_alv_grid_display .
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
       I_CALLBACK_PROGRAM                = sy-repid
       IT_FIELDCAT                       = IT_FIELDCAT
      TABLES
        t_outtab                          = i_likp
    EXCEPTIONS
       PROGRAM_ERROR                     = 1
       OTHERS                            = 2
    endform.                    " display_alv_grid_display
    Regards
    Haritha.

  • Want to display more than 300 charcters in a column using ALV grid display

    Hi Guru's,
    I am trying to display more than 500 charcters in a column using alv grid display but it in the output it is showing only 128 characters. Can you help me to display all the characters in particular column Or is there any limitation in maximum of no of charcters for a column?
    Thanks,
    Radha.

    Hi Paurl,
    Define a work area say
    wa_layout type slis_layout_alv.
    then fill this work area as
    wa_layout-zebra = X
    wa_layout-colwidth_optimize = X.
    wa_layout-max_linesize = 300.
    Then in FM 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    is_layout = wa_layout
    etc.
    you provided this for the field which is displayed in alv grid will have more than 128 characters.
    from this code i want,how it refers to particular field.
    when i mentioned field catalog-OUTPUTLEN = '300'.
    it is not displayed the field morethan 128 characters.
    it only displays 128 characters.
    please provide me clear and breif information with suitable code.
    i am trying what your sending but it is not displayed more than 128 characters.
    if you don't mind please spend for me some time for this and
    give me clear and breif information with suitable code.
    Thanks & Regards,
    Radhakrishna.

  • Update all alv (grid) displayed records to internal table

    Hi all,
    i want to update the records into the internal table which are changed by the user in the edit field.
    after he select save button.
    i  have to save the ALV grid displayed records in the internal table.
    hw can i do this ?

    ALV with EDIT and SAVE functionality
    Code:REPORT z_demo_alv_jg.*******************************************************************
    TYPE-POOLS                                                      *
    TYPE-POOLS: slis. *******************************************************************
    INTERNAL TABLES/WORK AREAS/VARIABLES     *
    DATA: i_fieldcat TYPE slis_t_fieldcat_alv,
          i_index TYPE STANDARD TABLE OF i WITH HEADER LINE,
          w_field TYPE slis_fieldcat_alv,
          p_table LIKE dd02l-tabname,
          dy_table TYPE REF TO data,
          dy_tab TYPE REF TO data,
          dy_line TYPE REF TO data.*******************************************************************
    FIELD-SYMBOLS                                                   *
    FIELD-SYMBOLS: <dyn_table> TYPE STANDARD TABLE,
                   <dyn_wa> TYPE ANY,
                   <dyn_field> TYPE ANY,
                   <dyn_tab_temp> TYPE STANDARD TABLE.*******************************************************************
    SELECTION SCREEN                                                *
    PARAMETERS: tabname(30) TYPE c,
                lines(5)  TYPE n.*******************************************************************
    START-OF-SELECTION                                              *
    START-OF-SELECTION.* Storing table name
      p_table = tabname.* Create internal table dynamically with the stucture of table name
    entered in the selection screen
      CREATE DATA dy_table TYPE STANDARD TABLE OF (p_table).
      ASSIGN dy_table->* TO <dyn_table>.
      IF sy-subrc <> 0.
        MESSAGE i000(z_zzz_ca_messages) WITH ' No table found'.    LEAVE TO LIST-PROCESSING.
      ENDIF.
    Create workarea for the table
      CREATE DATA dy_line LIKE LINE OF <dyn_table>.
      ASSIGN dy_line->* TO <dyn_wa>.* Create another temp. table
      CREATE DATA dy_tab TYPE STANDARD TABLE OF (p_table).
      ASSIGN dy_tab->* TO <dyn_tab_temp>.  SORT i_fieldcat BY col_pos.* Select data from table
      SELECT * FROM (p_table)
      INTO TABLE <dyn_table>
      UP TO lines ROWS.  REFRESH <dyn_tab_temp>.* Display report
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
        EXPORTING
          i_callback_program       = sy-repid
          i_structure_name         = p_table
          i_callback_user_command  = 'USER_COMMAND'
          i_callback_pf_status_set = 'SET_PF_STATUS'
        TABLES
          t_outtab                 = <dyn_table>
        EXCEPTIONS
          program_error            = 1
          OTHERS                   = 2.  IF sy-subrc <> 0.  ENDIF.&----
    *&      Form  SET_PF_STATUS
          Setting custom PF-Status
         -->RT_EXTAB   Excluding table
    FORM set_pf_status USING rt_extab TYPE slis_t_extab.  SET PF-STATUS 'Z_STANDARD'.ENDFORM.                    "SET_PF_STATUS&----
    *&      Form  user_command
          Handling custom function codes
         -->R_UCOMM      Function code value
         -->RS_SELFIELD  Info. of cursor position in ALV
    FORM user_command  USING    r_ucomm LIKE sy-ucomm
                               rs_selfield TYPE slis_selfield.* Local data declaration
      DATA: li_tab TYPE REF TO data,
            l_line TYPE REF TO data.* Local field-symbols
      FIELD-SYMBOLS:<l_tab> TYPE table,
                    <l_wa>  TYPE ANY.* Create table
      CREATE DATA li_tab TYPE STANDARD TABLE OF (p_table).
      ASSIGN li_tab->* TO <l_tab>.* Create workarea
      CREATE DATA l_line LIKE LINE OF <l_tab>.
      ASSIGN l_line->* TO <l_wa>.  CASE r_ucomm.*   When a record is selected
        WHEN '&IC1'.*     Read the selected record
          READ TABLE <dyn_table> ASSIGNING <dyn_wa> INDEX
          rs_selfield-tabindex.      IF sy-subrc = 0.*       Store the record in an internal table
            APPEND <dyn_wa> TO <l_tab>.*       Fetch the field catalog info
            CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
              EXPORTING
                i_program_name         = 'Z_DEMO_PDF_JG'
                i_structure_name       = p_table
              CHANGING
                ct_fieldcat            = i_fieldcat
              EXCEPTIONS
                inconsistent_interface = 1
                program_error          = 2
                OTHERS                 = 3.
            IF sy-subrc = 0.*         Make all the fields input enabled except key fields
              w_field-input = 'X'.          MODIFY i_fieldcat FROM w_field TRANSPORTING input
              WHERE key IS INITIAL.        ENDIF.*       Display the record for editing purpose
            CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
              EXPORTING
                i_callback_program    = sy-repid
                i_structure_name      = p_table
                it_fieldcat           = i_fieldcat
                i_screen_start_column = 10
                i_screen_start_line   = 15
                i_screen_end_column   = 200
                i_screen_end_line     = 20
              TABLES
                t_outtab              = <l_tab>
              EXCEPTIONS
                program_error         = 1
                OTHERS                = 2.        IF sy-subrc = 0.*         Read the modified data
              READ TABLE <l_tab> INDEX 1 INTO <l_wa>.*         If the record is changed then track its index no.
            and populate it in an internal table for future
            action
              IF sy-subrc = 0 AND <dyn_wa> <> <l_wa>.
                <dyn_wa> = <l_wa>.
                i_index = rs_selfield-tabindex.
                APPEND i_index.
              ENDIF.
            ENDIF.      ENDIF.*   When save button is pressed
        WHEN 'SAVE'.*     Sort the index table
          SORT i_index.*     Delete all duplicate records
          DELETE ADJACENT DUPLICATES FROM i_index.      LOOP AT i_index.*       Find out the changes in the internal table
          and populate these changes in another internal table
            READ TABLE <dyn_table> ASSIGNING <dyn_wa> INDEX i_index.
            IF sy-subrc = 0.
              APPEND <dyn_wa> TO <dyn_tab_temp>.
            ENDIF.      ENDLOOP.*     Lock the table
          CALL FUNCTION 'ENQUEUE_E_TABLE'
            EXPORTING
              mode_rstable   = 'E'
              tabname        = p_table
            EXCEPTIONS
              foreign_lock   = 1
              system_failure = 2
              OTHERS         = 3.      IF sy-subrc = 0.*       Modify the database table with these changes
            MODIFY (p_table) FROM TABLE <dyn_tab_temp>.        REFRESH <dyn_tab_temp>.*       Unlock the table
            CALL FUNCTION 'DEQUEUE_E_TABLE'
              EXPORTING
                mode_rstable = 'E'
                tabname      = p_table.      ENDIF.
      ENDCASE.  rs_selfield-refresh = 'X'.ENDFORM.                    "user_command

  • TOP OF PAGE in ALV Grid Display in ECC 6.0

    Hi,
    I have an issue with top of page in Alv grid display
    in ECC 6.0. I searched  the forum for this, but
    couldnt fine any solution.
    I am using Reuse_alv_commentary_write to display the header.
    It's working fine in 4.7E but the same code is not working in
    ECC 6.0. The header is shown as  empty.
    I tried to execute some other programs with same FM and
    even standard SAP Prgrms too, even they raise the same issue
    the top of page is empty.
    Please suggest any other FM or approach to use in ECC 6.0 to get the top of page.
    Thanks in advance
    Kaavya.

    hiii
    use following code
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
    *     I_INTERFACE_CHECK                 = ' '
    *     I_BYPASSING_BUFFER                = ' '
    *     I_BUFFER_ACTIVE                   = ' '
         i_callback_program                = sy-repid
    *     I_CALLBACK_PF_STATUS_SET          = ' '
    *     I_CALLBACK_USER_COMMAND           = ' '
         I_CALLBACK_TOP_OF_PAGE            = 'F0020_TOP_OF_PAGE'
    *     I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
    *     I_CALLBACK_HTML_END_OF_LIST       = ' '
         i_structure_name                  = 'I_OUTPUT'
    *     I_BACKGROUND_ID                   = ' '
    *     I_GRID_TITLE                      =
    *     I_GRID_SETTINGS                   =
    *     IS_LAYOUT                       = wa_layout
         it_fieldcat           = i_fieldcat
    *     IT_EXCLUDING                      =
    *     IT_SPECIAL_GROUPS                 =
    *     IT_SORT                           =
    *     IT_FILTER                         =
    *     IS_SEL_HIDE                       =
         i_default                         = 'X'
         i_save                            = 'X'
         is_variant                        = wa_variant
    *     IT_EVENTS                         =
    *     IT_EVENT_EXIT                     =
    *     IS_PRINT                          =
    *     IS_REPREP_ID                      =
    *     I_SCREEN_START_COLUMN             = 0
    FORM f0020_top_of_page.
      DATA: i_listheader TYPE slis_t_listheader WITH HEADER LINE,
            w_date like sy-datum.
      move:
        'H'   TO i_listheader-typ,
        '                 Corporation'   TO i_listheader-info.
    *    text-021    TO i_listheader-info.
    *write: 'Camtura Corporations'.
      APPEND i_listheader.
      WRITE sy-datum TO w_date.
      move:
        'S'   TO i_listheader-typ,
        'Execution date'   TO i_listheader-key,
        w_date     TO i_listheader-info.
      APPEND i_listheader.
    regards
    twinkal

Maybe you are looking for