ALV grid with editable fields

Dear Colleagues,
I develop an ALV grid with OO standard methods. Before the first display of the table I define the editable fields. It works fine.
I have a problem : if the table is empty and I press the standard icons "Append a line" or "Insert a line", the new line don't have the defined editable characteristics.for fields. Is there a standard method which I have forgotten ?
Thanks a lot and kind regards
Peter

vs_toolbar_excluding = cl_gui_alv_grid=>mc_fc_loc_delete_row.
    APPEND vs_toolbar_excluding TO i_toolbar_excluding.
    vs_toolbar_excluding = cl_gui_alv_grid=>mc_fc_loc_append_row.
    APPEND vs_toolbar_excluding TO i_toolbar_excluding.
    vs_toolbar_excluding = cl_gui_alv_grid=>mc_fc_loc_copy_row.
    APPEND vs_toolbar_excluding TO i_toolbar_excluding.
    vs_toolbar_excluding = cl_gui_alv_grid=>mc_fc_loc_insert_row.
    APPEND vs_toolbar_excluding TO i_toolbar_excluding.
    vs_toolbar_excluding = cl_gui_alv_grid=>mc_fc_loc_copy.
    APPEND vs_toolbar_excluding TO i_toolbar_excluding.
    vs_toolbar_excluding = cl_gui_alv_grid=>mc_fc_loc_cut.
    APPEND vs_toolbar_excluding TO i_toolbar_excluding.
    vs_toolbar_excluding = cl_gui_alv_grid=>mc_fc_loc_paste.
    APPEND vs_toolbar_excluding TO i_toolbar_excluding.
    vs_toolbar_excluding = cl_gui_alv_grid=>mc_fc_loc_undo.
    APPEND vs_toolbar_excluding TO i_toolbar_excluding.
    vs_toolbar_excluding = cl_gui_alv_grid=>mc_fc_loc_paste_new_row.
    APPEND vs_toolbar_excluding TO i_toolbar_excluding.
* Displaying the output in ALV Grid
    vs_layout_grid-no_rowmark = 'X'.
    vs_layout_grid-zebra      = 'X'.
    vs_layout_grid-cwidth_opt = 'X'.
    vs_layout_grid-edit       = 'X'.
    vs_layout_grid-ctab_fname = 'CT'.
    vs_layout_grid-stylefname = 'CELLTAB'.
    CALL METHOD v_grid->set_table_for_first_display
      EXPORTING
        i_save                        = 'X'
        is_layout                     = vs_layout_grid
        it_toolbar_excluding          = i_toolbar_excluding[]
      CHANGING
        it_outtab                     = itab[]
        it_fieldcatalog               = it_fieldcat[]
      EXCEPTIONS
        invalid_parameter_combination = 1
        program_error                 = 2
        too_many_lines                = 3
        OTHERS                        = 4.
    IF sy-subrc NE 0.
      MESSAGE 'ALV Grid display unsuccessful' TYPE 'I'.
      STOP.
    ENDIF.                             " IF sy-subrc NE 0
  ELSE.                                " IF w_custom_container...
* Refresh the container if it already exists
    CALL METHOD v_grid->refresh_table_display
      EXCEPTIONS
        finished = 1
        OTHERS   = 2.
    IF sy-subrc NE 0.
      MESSAGE 'Refreshing the container is not successful' TYPE 'I'.
      STOP.
    ENDIF.                            

Similar Messages

  • Create a Procedural ALV Report with editable fields and save the changes

    Hi,
    I am new to ABAP. I have created a Procedural ALV Report with 3 fields. I want to make 2 fields editable. When executed, if the fields are modified, I want to save the changes. All this I want to do without using OO concepts. Please help . Also, I checked out the forum and also the examples
    BCALV_TEST_GRID_EDIT_01
    BCALV_TEST_GRID_EDIT_02
    BCALV_TEST_GRID_EDIT_04_FORMS
    BCALV_TEST_GRID_EDITABLE
    BCALV_EDIT_01
    BCALV_EDIT_02
    BCALV_EDIT_03
    BCALV_EDIT_04
    BCALV_EDIT_05
    BCALV_EDIT_06
    BCALV_EDIT_07
    BCALV_EDIT_08
    BCALV_FULLSCREEN_GRID_EDIT
    But all these are using OO Concepts.
    Please help.
    Regards,
    Smruthi

    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,
      line_color(4) TYPE c,     "Used to store row color attributes
    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.
      PERFORM data_retrieval.
      PERFORM build_fieldcatalog.
      PERFORM build_layout.
      PERFORM display_alv_report.
    *&      Form  BUILD_FIELDCATALOG
          Build Fieldcatalog for ALV Report
    FORM build_fieldcatalog.
      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-edit             = 'X'
      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-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-info_fieldname =      'LINE_COLOR'.
    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_pf_status_set = 'STATUS'
                i_callback_top_of_page   = 'TOP-OF-PAGE'
               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.
    ENDFORM.                    " DISPLAY_ALV_REPORT
    *&      Form  DATA_RETRIEVAL
          Retrieve data form EKPO table and populate itab it_ekko
    FORM data_retrieval.
      DATA: ld_color(1) TYPE c.
      SELECT ebeln ebelp statu aedat matnr menge meins netpr peinh
       UP TO 10 ROWS
        FROM ekpo
        INTO TABLE it_ekko.
      LOOP AT it_ekko INTO wa_ekko.
        ld_color = ld_color + 1.
        IF ld_color = 8.
          ld_color = 1.
        ENDIF.
        CONCATENATE 'C' ld_color '10' INTO wa_ekko-line_color.
        MODIFY it_ekko FROM wa_ekko.
      ENDLOOP.
    ENDFORM.                    " DATA_RETRIEVAL
          FORM top-of-page                                              *
    FORM top-of-page.
      WRITE:/ 'This is First Line of the Page'.
    ENDFORM.
          FORM status                                                   *
    FORM status USING rt_extab TYPE slis_t_extab.  .
      SET PF-STATUS 'ALV'.
    ENDFORM.
          FORM USER_COMMAND                                          *
    -->  RF_UCOMM                                                      *
    -->  RS                                                            *
    FORM user_command USING rf_ucomm LIKE sy-ucomm
                             rs TYPE slis_selfield.            
      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.
      CASE rf_ucomm.
    when 'SAVE'.
    get all the modified entries and store them in an internal table and udpate them in to the required transaction or your custom table.
    endcase.
    endform.
    ENDFORM.
    here u need to 2 performs for PF status and USER_COMMAND in the ALV parameters.
    create a custom PF status and create push buttons and assign your ok codes in your PF status.
    if the field has to be edited in the ALV then pass EDIT = 'X' for that field in the fieldcatlog preparation.
    Hope this will help you.
    Regards,
    phani.

  • ALV GRID with icon fields. When exports to Excel, icon fields are emtpy.

    Hi all,
    In our SAP system (6.0 ECC) we've noticed the following behaviour:
    In ALV GRID with icons (color lights for example...) when we export the list to Excel format with the standard button bat, the icon column is always empty.
    We think that in previous SAP version (4.7), the code corresponding to the icon appeared (For example @08@ for green light).
    It's possible to have tha same functionality in this new version like in 4.7?
    Regards.
    Edited by: Ole ES on Nov 17, 2010 6:05 PM

    Hi,
    Check the format in which you export to Excel (MHTML, XML, ...) and try antoher one.
    http://help.sap.com/saphelp_erp60_sp/helpdata/en/66/79ad48157f11d2953700a0c930328a/content.htm
    I think the integrated Excel mode shows '@08@'.
    Best regards,
    Guillaume

  • Group feature at ALV grid with editable columns

    Am I right ?
    Group function by using a sorted layout is disabled while having one (or more) editable columns, isn't it ?
    ... or is there a possibility to use gouped rows ?
    Greetings
    Markus

    Also...
    *& Report ZDEMO_ALVGRID_EDIT *
    *& Example of a simple ALV Grid Report *
    *& The basic ALV grid, Enhanced to display specific fields as *
    *& editable depending on field value *
    REPORT ZDEMO_ALVGRID_EDIT .
    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,
    field_style TYPE lvc_t_styl, "FOR DISABLE
    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.
    DATA: it_fieldcat TYPE lvc_t_fcat, "slis_t_fieldcat_alv WITH HEADER LINE,
    wa_fieldcat TYPE lvc_s_fcat,
    gd_tab_group TYPE slis_t_sp_group_alv,
    gd_layout TYPE lvc_s_layo, "slis_layout_alv,
    gd_repid LIKE sy-repid.
    *Start-of-selection.
    START-OF-SELECTION.
    PERFORM data_retrieval.
    PERFORM set_specific_field_attributes.
    PERFORM build_fieldcatalog.
    PERFORM build_layout.
    PERFORM display_alv_report.
    *& Form BUILD_FIELDCATALOG
    Build Fieldcatalog for ALV Report
    FORM build_fieldcatalog.
    wa_fieldcat-fieldname = 'EBELN'.
    wa_fieldcat-scrtext_m = 'Purchase Order'.
    wa_fieldcat-col_pos = 0.
    wa_fieldcat-outputlen = 10.
    wa_fieldcat-emphasize = 'X'.
    wa_fieldcat-key = 'X'.
    APPEND wa_fieldcat TO it_fieldcat.
    CLEAR wa_fieldcat.
    wa_fieldcat-fieldname = 'EBELP'.
    wa_fieldcat-scrtext_m = 'PO Item'.
    wa_fieldcat-col_pos = 1.
    APPEND wa_fieldcat TO it_fieldcat.
    CLEAR wa_fieldcat.
    wa_fieldcat-fieldname = 'STATU'.
    wa_fieldcat-scrtext_m = 'Status'.
    wa_fieldcat-col_pos = 2.
    APPEND wa_fieldcat TO it_fieldcat.
    CLEAR wa_fieldcat.
    wa_fieldcat-fieldname = 'AEDAT'.
    wa_fieldcat-scrtext_m = 'Item change date'.
    wa_fieldcat-col_pos = 3.
    APPEND wa_fieldcat TO it_fieldcat.
    CLEAR wa_fieldcat.
    wa_fieldcat-fieldname = 'MATNR'.
    wa_fieldcat-scrtext_m = 'Material Number'.
    wa_fieldcat-col_pos = 4.
    APPEND wa_fieldcat TO it_fieldcat.
    CLEAR wa_fieldcat.
    wa_fieldcat-fieldname = 'MENGE'.
    wa_fieldcat-scrtext_m = 'PO quantity'.
    wa_fieldcat-col_pos = 5.
    APPEND wa_fieldcat TO it_fieldcat.
    CLEAR wa_fieldcat.
    wa_fieldcat-fieldname = 'MEINS'.
    wa_fieldcat-scrtext_m = 'Order Unit'.
    wa_fieldcat-col_pos = 6.
    APPEND wa_fieldcat TO it_fieldcat.
    CLEAR wa_fieldcat.
    wa_fieldcat-fieldname = 'NETPR'.
    wa_fieldcat-scrtext_m = 'Net Price'.
    wa_fieldcat-edit = 'X'. "sets whole column to be editable
    wa_fieldcat-col_pos = 7.
    wa_fieldcat-outputlen = 15.
    wa_fieldcat-datatype = 'CURR'.
    APPEND wa_fieldcat TO it_fieldcat.
    CLEAR wa_fieldcat.
    wa_fieldcat-fieldname = 'PEINH'.
    wa_fieldcat-scrtext_m = 'Price Unit'.
    wa_fieldcat-col_pos = 8.
    APPEND wa_fieldcat TO it_fieldcat.
    CLEAR wa_fieldcat.
    ENDFORM. " BUILD_FIELDCATALOG
    *& Form BUILD_LAYOUT
    Build layout for ALV grid report
    FORM build_layout.
    Set layout field for field attributes(i.e. input/output)
    gd_layout-stylefname = 'FIELD_STYLE'.
    gd_layout-zebra = 'X'.
    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'
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
    EXPORTING
    i_callback_program = gd_repid
    i_callback_user_command = 'USER_COMMAND'
    is_layout_lvc = gd_layout
    it_fieldcat_lvc = it_fieldcat
    i_save = 'X'
    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 CORRESPONDING FIELDS OF TABLE it_ekko.
    ENDFORM. " DATA_RETRIEVAL
    *& Form set_specific_field_attributes
    populate FIELD_STYLE table with specific field attributes
    form set_specific_field_attributes .
    DATA ls_stylerow TYPE lvc_s_styl .
    DATA lt_styletab TYPE lvc_t_styl .
    Populate style variable (FIELD_STYLE) with style properties
    The NETPR field/column has been set to editable in the fieldcatalog...
    The following code sets it to be disabled(display only) if 'NETPR'
    is gt than 10.
    LOOP AT it_ekko INTO wa_ekko.
    IF wa_ekko-netpr GT 10.
    ls_stylerow-fieldname = 'NETPR' .
    ls_stylerow-style = cl_gui_alv_grid=>mc_style_disabled.
    "set field to disabled
    APPEND ls_stylerow TO wa_ekko-field_style.
    MODIFY it_ekko FROM wa_ekko.
    ENDIF.
    ENDLOOP.
    endform. " set_specific_field_attributes
    REWARD POINTS IF usefful !!

  • ALV Grid Display Editable Field Disables Zebra Style

    Hi all,
    First of all, I want to say: "I did my research." I found a post with a very similar question but not identically my case, or at least I can't solve it the same way. [Here is the reference post.|Re: Check box impact on ALV grid (Using OOPS)]
    My Goal: I have an ALV Grid which I want to display using the ZEBRA style in the layout and also make one field in the field catalog editable.
    My Issue: As soon as you make one field editable in the field catalog using the EDIT option, the ZEBRA style in the layout does not works. I also have key fields in the ALV Grid which I want to keep as KEY and which get painted dark blue.
    I can't use the individual row coloring method used in the reference link above since this overrides the blue coloring of the key fields in the ALV. I haven't gone through all the effort of individually painting each cell on the grid, and honestly I don't think it is efficient.
    My Question: Is there a way to have editable fields in the ALV Grid and keep the ZEBRA setting working?
    Please, I will really appreciate if you can read and try to understand my issue before posting incoherent solutions or answers. I don't want to waste anybody's time nor mine.

    Shiva,
    Thanks for your reply; it someway addresses what I am looking for. Unfortunately, I've already went through that reference code; it has exactly the same problem that I am facing.
    If you take that code for example, and you throw it u201Cas-isu201D in your ABAP editor you'll see that even when the ZEBRA style is being used in the layout, since the EDIT option in the field catalog is being set for field NETPR, the ZEBRA style gets lost; only the whole editable column gets white. You can go ahead and play a little bit with that piece of code and you will see what I am saying.
    Regards

  • ALV Grid Handle Edit Event (Lost Focus)

    Hi all,
    I have some problems with the ALV Grid.
    Target:
    I have an ALV Grid with editable Column. If the user insert, update or delete the content of the column and leave the column (column lost focus) i'd like to do somthing - this means I need a event for this action. Can anybody help me to solve this problem?
    Thanks Stefan

    Use Event data_changed and data_changed_finished of the cl_gui_alv_grid.Then all you have to do is registering your event to the ALV and fill the methods with what you want to do.In ALV Grid, There is no event to capture the lost focus of a column if you don't modify it.
    CLASS lcl_event_receiver DEFINITION.
        METHODS:
    *$ Check the change
           handle_data_changed FOR EVENT data_changed
                                   OF cl_gui_alv_grid
                               IMPORTING er_data_changed
                                         e_ucomm
                                         e_onf4
                                         e_onf4_before
                                         e_onf4_after,
           handle_data_changed_finished
                               FOR EVENT data_changed_finished
                                   OF cl_gui_alv_grid
                                IMPORTING e_modified
                                         et_good_cells
                                         sender,
    ENDCLASS.                    "LCL_EVENT_RECEIVER DEFINITION

  • To capture the selected rows along with edited field contents in alv report

    Dear All,
             I do have requirement where, in alv report output one field is editable and need to save the content of the edited field along with the selected rows.
             For example If there are 10 records displayed in the alv output with 20 fields.
    Out of this 20 fields one field (say XYZ) is editable. Also i have already created a new pushbutton (say ABC) on alv output. Now in the alv output if we maintain some value in the field (XYZ ) for the 2nd and 4th record and select this two records, and when clicked on the pushbutton (ABC) it has to update the DB table.
          I am using the Func Module  'REUSE_ALV_GRID_DISPLAY'. 
          Your early reply with sample code would be appreciated.
    Thanks in Advance.

    HI Naveen ,
    There is an import parameter "i_callback_program" in the function module,
    plz pass the program name to it.
    Capture the command by passing a field of type sy-ucomm to "I_CALLBACK_USER_COMMAND ".  Check the returned command and
    and program a functionality as desired.
    u can try the event double_click or at line selection. there u can use READLINE command to c if the line has been selected.
    In case it is , process the code segment.
    Regards
    Pankaj

  • OO ALV grid with a header line is this possible?

    Howdy!
    I have a requirement where I need to produce an ALV grid with the following format:
    <b>Text 1     Text 2  Text 3                  Text 4
                              Text 6
    Col_1 Col_2 Col_3 Col_4 Col_5 Col_6 Col_7 Col_8 Col_9 
    Cell conents -
    Cell conents -
    Cell conents -
    Cell conents -
    Cell conents -
    </b>
    Anyone got any idea on how to get the 'TEXT' fields into the ALV grid? These are dynamic texts that would basically display details of data entered in the selection screen.
    The ALV title line is limited to 70 characters and I can't think of another way of doing this.
    The texts need to appear on the ALV grid becasue the user would like to download them to Excel in addition to the ALV cell contents using the standard ALV functionality.
    Any ideas would be appreciated!
    Message was edited by: Robert

    I'm thinking that this may not work because it is not a full screen grid and the grid container does not care about the container on top of it so, it most likely would not print it.   Implement this example program, you can see how this would work for you if you were using the FM.
    report zrich_0001
           no standard page heading.
    * Global ALV Data Declarations
    type-pools slis.
    data: begin of i_alv occurs 0,
          matnr type mara-matnr,
          end of i_alv.
    * Miscellanous Data Declarations
    data: fieldcat type slis_t_fieldcat_alv,
          events   type slis_t_event,
          list_top_of_page type slis_t_listheader,
          top_of_page  type slis_formname value 'TOP_OF_PAGE'.
    start-of-selection.
      perform initialization.
      perform get_data.
      perform call_alv.
    end-of-selection.
    *  Form  Initialization
    form initialization.
      clear i_alv.       refresh i_alv.
      perform eventtab_build using events[].
    endform.
    *  Form  Get_Data
    form  get_data.
      select matnr into table i_alv
                  from mara up to 100 rows.
    endform.
    *  CALL_ALV
    form call_alv.
      data: variant type  disvariant.
      data: repid type sy-repid.
      repid = sy-repid.
      variant-report = sy-repid.
      variant-username = sy-uname.
      perform build_field_catalog.
      perform comment_build using list_top_of_page[].
    * Call ABAP List Viewer (ALV)
      call function 'REUSE_ALV_GRID_DISPLAY'
           exporting
                it_fieldcat        = fieldcat
                i_callback_program = repid
                is_variant         = variant
                it_events          = events[]
                i_save             = 'U'
           tables
                t_outtab           = i_alv.
    endform.
    * EVENTTAB_BUILD
    form eventtab_build using events type slis_t_event.
    * Registration of events to happen during list display
      data: tmp_event type slis_alv_event.
      call function 'REUSE_ALV_EVENTS_GET'
           exporting
                i_list_type = 0
           importing
                et_events   = events.
      read table events with key name = slis_ev_top_of_page
                               into tmp_event.
      if sy-subrc = 0.
        move top_of_page to tmp_event-form.
        append tmp_event to events.
      endif.
    endform.
    * BUILD_FIELD_CATALOG
    form build_field_catalog.
      clear: fieldcat. refresh: fieldcat.
      data: tmp_fc type slis_fieldcat_alv.
      tmp_fc-reptext_ddic = 'Material'.
      tmp_fc-fieldname    = 'MATNR'.
      tmp_fc-tabname      = 'I_ALV'.
      tmp_fc-outputlen    = 18.
      append tmp_fc to fieldcat.
    endform.
    * COMMENT_BUILD
    form comment_build using list_top_of_page type
                                            slis_t_listheader.
      data: tmp_line type slis_listheader.
      clear tmp_line.
      tmp_line-typ  = 'H'.
      tmp_line-info = 'Here is a line of text'.
      append tmp_line to list_top_of_page.
      clear tmp_line.
      tmp_line-typ  = 'S'.
      tmp_line-key  = 'Key1'.
      tmp_line-info = 'Here is a value'.
      append tmp_line to list_top_of_page.
      clear tmp_line.
      tmp_line-typ  = 'S'.
      tmp_line-key  = 'Key2'.
      tmp_line-info = 'Here is another value'.
      append tmp_line to list_top_of_page.
    endform.
    * TOP_OF_PAGE
    form top_of_page.
      call function 'REUSE_ALV_COMMENTARY_WRITE'
           exporting
                i_logo             = 'ENJOYSAP_LOGO'
                it_list_commentary = list_top_of_page.
    endform.
    Regards,
    Rich Heilman

  • REUSE_ALV_GRID_DISPLAY with editable field -- Get the short text

    Hi everybody,
    I would like to know if you can resolve the following problem:
    I have an editable column in my ALV grid with a match code. When the user choise the value in the range, this value is displayed in the grid. But I would like to display the short text and not the fix value like actually.
    Have you got an idea?
    Thank you in advance.
    Best regards,
    Robin

    You could add another column for the text and change it's contents when the editable field changes.

  • Display amount in ALV Grid with different Decimal Places based on Currency

    HI Experts,
    Working with ALV Report i have one Amount field NETWR which is having Length 15 and Decimal Places 2.
    we have two different types of currency's AED and KWD and AED having 2 decimal Places and KWD having 3 decimal places.
    im using FM: REUSE_ALV_GRID_DISPLAY for Display. value storing in Table was like this
    AED---22.56
    KWD---225.65
    i need to display values like AED : 22.56

    HI Experts,
    Working with ALV Report i have one Amount field NETWR which is having Length 15 and Decimal Places 2. we have two different types of currency's AED and KWD and AED having 2 decimal Places and KWD having 3 decimal places.
    im using FM: REUSE_ALV_GRID_DISPLAY for Display. value storing in Table was like this
    AED---22.56
    KWD---225.65 (converting this value to 22.565 using BAPI_CURRENCY_GETDECIMALS according to currency in my Report)
    i need to display values like AED : 22.56
                                             KWD---22.565 but here field is NETWR with 2 decimal.
    Need to Display amount in ALV Grid with different Decimal Places based on Currency
    Regards,
    Dileep Kumar Reddy

  • REUSE_ALV_GRID_DISPLAY with editable field -- Recuperate new value

    Hi everybody,
    I try to explain my problem. I created an ALV grid with the function REUSE_ALV_GRID_DISPLAY and an internal table.
    The user can change the value of one field and can save it. Indeed, in debbug mode, I can see in the internal table the new value entered by the user. So I can do all the actions with the launch of a routine.
    But the user can forger to save his change. So, when he clicks on "Back" I want to propose him to save. THE PROBLEM : in debbug mode, when the routine is launched, the internal table does't have the new value..
    So have you got an idea to recuperate the new value?
    Thank you very much in advance.
    Best regards.

    I had the same problem and solved it: I used SET_TABLE_FOR_FIRST_DISPLAY.
    The MT_OUTPUT tab has the ALV data and the column in here must be modifed. Steps:
    data: p_grid  type ref to lcl_gui_alv_grid.
    Step 1. Create a sub class for LCL_GUI_ALV_GRID_DEFINITION.
    *       class lcl_gui_alv_grid  definitio
    CLASS lcl_gui_alv_grid DEFINITION
            INHERITING FROM cl_gui_alv_grid.
      PUBLIC SECTION.
        METHODS: update_outtab
                   IMPORTING i_good_cells TYPE lvc_t_modi.
    **             check_changed_data.
    ENDCLASS.                    "lcl_gui_alv_grid  DEFINITIO
    Step2
    Use event data_changed_finished of LCL_EVENT_RECEIVER
    *       CLASS lcl_event_receiver DEFINITION
    CLASS lcl_event_receiver DEFINITION.
      PUBLIC SECTION.
        METHODS:
          handle_data_changed
             FOR EVENT data_changed OF cl_gui_alv_grid
                 IMPORTING er_data_changed,
          handle_data_change_finished    "****<----------
             FOR EVENT data_changed_finished OF cl_gui_alv_grid
                 IMPORTING e_modified et_good_cells,
          handle_double_click
             FOR EVENT double_click OF cl_gui_alv_grid
                 IMPORTING e_row e_column,
          handle_after_refresh
             FOR EVENT after_refresh OF cl_gui_alv_grid.
    *Implementation
    CLASS lcl_event_receiver IMPLEMENTATION.
    METHOD handle_data_change_finished.
        DATA: lt_goodcells TYPE lvc_t_modi.
        CHECK NOT e_modified IS INITIAL AND NOT et_good_cells IS INITIAL.
        lt_goodcells[] = et_good_cells[].
        CALL METHOD p_grid->update_outtab
          EXPORTING
            i_good_cells = lt_goodcells.
        CALL METHOD p_grid->refresh_table_display.
      ENDMETHOD.                    "data_changed_finished
    *-- ALV data updated in class implementation below
    CLASS lcl_gui_alv_grid IMPLEMENTATION.
      METHOD update_outtab.
        FIELD-SYMBOLS: <tab1> TYPE STANDARD TABLE,
                       <good> TYPE lvc_s_modi,
                       <fs1> TYPE ANY,
                       <fs2> TYPE ANY.
        DATA: ls_alv TYPE type_alv,
              fldabgru(32) TYPE c VALUE '<TAB1>-ABGRU_NEW',
              fldbezei(32) TYPE c VALUE '<TAB1>-BEZEI_NEW',
              lv_bezei TYPE bezei40.
        ASSIGN mt_outtab->* TO <tab1>.  "ALV display table
        LOOP AT i_good_cells ASSIGNING <good>.
          READ TABLE <tab1> INTO ls_alv INDEX <good>-row_id.
          IF sy-subrc EQ 0.
            SELECT SINGLE bezei INTO ls_alv-bezei_new
              FROM tvagt
              WHERE spras = sy-langu
                AND abgru = ls_alv-abgru_new.
            IF sy-subrc EQ 0.
              MODIFY <tab1> FROM ls_alv INDEX <good>-row_id.
            ENDIF.
          ENDIF.
        ENDLOOP.
      ENDMETHOD.                    "update_outtab

  • ALV Grid with Popup Window

    Hey @all,
    I want to make a ALV Grid with a Popup Window. The idea is that there is a field for notes and when you click on this field a popup window should be opened where you can insert more text or if text already exists only the first column of the text is shown in field until you click on the field.
    Is there any possibility to do it this way? Do I have to make a second Grid for this Popup Window? Do anybody have an example how to solve this problem?
    Thank you in advance for your answers!
    Greetings,
    Alexander

    *& Report  Z_VISHVAS_ALV1
    report  z_vishvas_alv1.
    type-pools: slis.
    data: begin of i_outtab occurs 0.
            include structure sflight.
    data:   w_chk type c.                  "For multiple selection
    data: end of i_outtab.
          I_OUTTAB TYPE SFLIGHT OCCURS 0,
    data: i_private type slis_data_caller_exit,
          i_selfield type slis_selfield,
          w_exit(1) type c.
    parameters: p_title type sy-title.
    start-of-selection.
      select * from sflight into table i_outtab.
      call function 'REUSE_ALV_POPUP_TO_SELECT'
           exporting
                i_title                 = p_title
                i_selection             = 'X'
                i_zebra                 = 'X'
              I_SCREEN_START_COLUMN   = 0
              I_SCREEN_START_LINE     = 0
              I_SCREEN_END_COLUMN     = 0
              I_SCREEN_END_LINE       = 0
                i_checkbox_fieldname    = 'W_CHK'
              I_LINEMARK_FIELDNAME    =
              I_SCROLL_TO_SEL_LINE    = 'X'
                i_tabname               = 'I_OUTTAB'
                i_structure_name        = 'SFLIGHT'
              IT_FIELDCAT             =
              IT_EXCLUDING            =
              I_CALLBACK_PROGRAM      =
              I_CALLBACK_USER_COMMAND =
               IS_PRIVATE             = I_PRIVATE
         importing
                es_selfield             = i_selfield
                e_exit                  = w_exit
           tables
                t_outtab                = i_outtab
           exceptions
                program_error           = 1
                others                  = 2.
      if sy-subrc <> 0.
       MESSAGE i000(0k) WITH sy-subrc.
      endif.
    *****the internal table is modified with a cross sign for marking the
    ***rows selected
      loop at i_outtab where w_chk = 'X'.
        write: /  i_outtab-carrid, i_outtab-price.
      endloop.

  • Manipulate Layout on ALV Grid with dynamic table

    Dear all
    i'm generating a dynamic table depending of a date selection. That means that I show columns for weeks and the quantity of weeky migh change.
    Now the users wants to have a specific layout of the ALV grid with totals. When he saves the layout, only the weeks at this selection will show the next time he runs the programm with a larger selection.
    a) Is it possible to modify the layout during runtime by programming?
    b) Do you have any other ideas how to solve this problem?
    Thank you

    You don't know the names of your columns? hmm you do, because before you created dynamic table you had to create field catalog, so the structure and column names of newly (dynamically) created table will be the same like defined in the field catalog.
    The last loop also does not look good, in my opinion should be something like:
    LOOP AT lt_datatable +(my first table)+ ASSIGNING <ls_data4>.
        AT NEW pernr.
          APPEND initial line to <fs_1> assigning <fs_2>.
          <fs_2>-pernr = <ls_data4>-pernr.
        ENDAT.
        ASSIGN COMPONENT <ls_data4>-wage_type OF STRUCTURE <fs_2> TO <fs_5>.
        <fs_5> = <ls_data4>-amount.
    ENDLOOP.
    also keep in mind that number of calls of method cl_alv_table_create=>create_dynamic_table is limited to 36 (?) calls within one program session because it uses dynamic subroutine pool behind so you will have short dump if you will execute that 37 times.

  • Hi all  F4 in alv grid with restricted value  -- no solution from forum

    hi all
    i have developed report using alv grid using FM (important).
    i have a field xyz which is input/output enabled in alv grid output. this field is attached with f4 help.
    my requirement is to get or read the row in alv grid when user press f4 on that field so that restricted value should come in f4 help i.e. i have to read current line when user presses f4 i.e. the single line data in alv grid.
    so how to get or read the current row when user press f4 i.e user will choose any row in alv grid and this output is on alv grid and there are multiple records.
    or in other word is it possible to read current row in alv grid when user presses F4, if yes how???.
    i hope u understood the query.

    Hai,
    Check the code it may help u.
    For F4 Values on Screen:
    PROCESS ON VALUE_REQUEST
    using module call starting with FIELD i.e FIELD field MODULE module
    There are number of function modules that can be used for the purpose, but these
    can fullfill the task easily or combination of them.
    DYNP_VALUE_READ
    F4IF_FIELD_VALUE_REQUEST
    F4IF_INT_TABLE_VALUE_REQUEST
    POPUP_WITH_TABLE_DISPLAY
    DYNP_VALUE_READ
    This function module is used to read values in the screen fields. Use of this
    FM causes forced transfer of data from screen fields to ABAP fields.
    There are 3 exporting parameters
    DYNAME = program name = SY-CPROG
    DYNUMB = Screen number = SY-DYNNR
    TRANSLATE_TO_UPPER = 'X'
    and one importing TABLE parameter
    DYNPFIELDS = Table of TYPE DYNPREAD
    The DYNPFIELDS parameter is used to pass internal table of type DYNPREAD
    to this FM and the values read from the screen will be stored in this table.This
    table consists of two fields:
    FIELDNAME : Used to pass the name of screen field for which the value is to
    be read.
    FIELDVALUE : Used to read the value of the field in the screen.
    e.g.
    DATA: SCREEN_VALUES TYPE TABLE OF DYNPREAD ,
    SCREEN_VALUE LIKE LINE OF SCREEN_VALUES.
    SCREEN_VALUE-FIELDNAME = 'KUNNR' . * Field to be read
    APPEND SCREEN_VALUE TO SCREEN_VALUES. * Fill the table
    CALL FUNCTION 'DYNP_VALUES_READ'
    EXPORTING
    DYNAME = SY-CPROG
    DYNUMB = SY-DYNNR
    TRANSLATE_TO_UPPER = 'X'
    TABLES
    DYNPFIELDS = SCREEN_VALUES.
    READ TABLE SCREEN_VALUES INDEX 1 INTO SCREEN_VALUE.Now the screen value for field KUNNR is in the SCREEN_VALUE-FIELDVALUE and can be used for further processing like using it to fill the internal table to be used as parameter in F4IF_INT_TABLE_VALUE_REQUEST ETC.
    F4IF_FIELD_VALUE_REQUEST
    This FM is used to display value help or input from ABAP dictionary.We have to pass the name of the structure or table(TABNAME) along with the field name(FIELDNAME) . The selection can be returned to the specified screen field if three
    parameters DYNPNR,DYNPPROG,DYNPROFIELD are also specified or to a table if RETRN_TAB is specified.
    CALL FUNCTION 'F4IF_FIELD_VALUE_REQUEST'
    EXPORTING
    TABNAME = table/structure
    FIELDNAME = 'field name'
    DYNPPROG = SY-CPROG
    DYNPNR = SY-DYNR
    DYNPROFIELD = 'screen field'
    IMPORTING
    RETURN_TAB = table of type DYNPREAD
    F4IF_INT_TABLE_VALUE_REQUEST
    This FM is used to dsiplay values stored in an internal table as input
    help.This FM is used to program our own custom help if no such input help
    exists in ABAP dictionary for a particular field. The parameter VALUE_TAB is used to pass the internal table containing input values.The parameter RETFIELD
    is used to specify the internal table field whose value will be returned to the screen field or RETURN_TAB.
    If DYNPNR,DYNPPROG and DYNPROFIELD are specified than the user selection is passed to the screen field specified in the DYNPROFIELD. If RETURN_TAB is specified the selectionis returned in a table.
    CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
    EXPORTING
    RETFIELD = field from int table whose value will be returned
    DYNPPROG = SY-CPROG
    DYNPNR = SY-DYNNR
    DYNPROFIELD = 'screen field'
    VALUE_ORG = 'S'
    TABLES
    VALUE_TAB = internal table whose values will be shown.
    RETURN_TAB = internal table of type DDSHRETVAL
    EXCEPTIONS
    parameter_error = 1
    no_values_found = 2
    others = 3.
    POPUP_WITH_TABLE_DISPLAY
    This FM is used to display the contents of an internal table in a popup window.The user can select a row and the index of that is returned in the CHOISE
    parameter.The VALUETAB is used to pass the internal table.
    A suitable title can be set using TITLETEXT parameter. The starting and end position of the popup can be specified by the parameters STARTPOS_COL / ROW and ENDPOS_ROW / COL .
    CALL FUNCTION 'POPUP_WITH_TABLE_DISPLAY'
    EXPORTING
    ENDPOS_COL =
    ENDPOS_ROW =
    STARTPOS_COL =
    STARTPOS_ROW =
    TITLETEXT = 'title text'
    IMPORTING
    CHOISE =
    TABLES
    VALUETAB =
    EXCEPTIONS
    BREAK_OFF = 1
    OTHERS = 2.
    e.g.
    DATA: w_choice TYPE SY-TABIX.
    DATA: BEGIN OF i_values OCCURS 0 WITH HEADER LINE,
    values TYPE I,
    END OF i_values.
    PARAMETRS : id TYPE I.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR id
    i_values-values = '0001'.
    APPEND i_values.
    i_values-values = '0002'.
    APPEND i_values.
    i_values-values = '0003'.
    APPEND i_values.
    i_values-values = '0004'.
    APPEND i_values.
    CALL FUNCTION 'POPUP_WITH_TABLE_DISPLAY'
    EXPORTING
    ENDPOS_COL = 40
    ENDPOS_ROW = 12
    STARTPOS_COL = 20
    STARTPOS_ROW = 5
    TITLETEXT = 'Select an ID'
    IMPORTING
    CHOISE = w_choice
    TABLES
    VALUETAB = i_values
    EXCEPTIONS
    BREAK_OFF = 1
    OTHERS = 2.
    CHECK w_choice > 0.
    READ TABLE i_values INDEX w_choice....now we can process the selection as it is contained
    ...in the structure i_values.
    Other FM that may be used to provide input help is HELP_START .
    check this also.
    See the following ex:
    TYPES: BEGIN OF TY_MBLNR,
    MBLNR LIKE MKPF-MBLNR,
    END OF TY_MBLNR.
    DATA: IT_MBLNR TYPE STANDARD TABLE OF TY_MBLNR WITH HEADER LINE.
    data: it_ret like ddshretval occurs 0 with header line.
    At selection-screen on value-request for s_mat-low.
    Select MBLNR from mkpf into table it_mblnr.
    CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
    EXPORTING
    DDIC_STRUCTURE = ' '
    RETFIELD = 'MBLNR'
    PVALKEY = ' '
    DYNPPROG = ' '
    DYNPNR = ' '
    DYNPROFIELD = ' '
    STEPL = 0
    WINDOW_TITLE =
    VALUE = ' '
    VALUE_ORG = 'S'
    MULTIPLE_CHOICE = ' '
    DISPLAY = ' '
    CALLBACK_PROGRAM = ' '
    CALLBACK_FORM = ' '
    MARK_TAB =
    IMPORTING
    USER_RESET =
    TABLES
    VALUE_TAB = IT_MBLNR
    FIELD_TAB =
    RETURN_TAB = IT_RET
    DYNPFLD_MAPPING =
    EXCEPTIONS
    PARAMETER_ERROR = 1
    NO_VALUES_FOUND = 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.
    IF SY-SUBRC = 0.
    read table it_ret index 1.
    move it_ret-fieldval to S_mat-low.
    ENDIF.
    Go through the test program.
    REPORT Ztest_HELP .
    TABLES : MARA.
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
    PARAMETERS : P_MATNR(10) TYPE C.
    SELECTION-SCREEN END OF BLOCK B1.
    DATA : BEGIN OF ITAB OCCURS 0,
    MATNR TYPE MATNR,
    END OF ITAB.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_MATNR.
    SELECT MATNR
    FROM MARA
    INTO TABLE ITAB
    UP TO 10 ROWS.
    CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
    EXPORTING
    RETFIELD = 'MATERIAL NUMBER'
    DYNPPROG = SY-REPID
    DYNPNR = SY-DYNNR
    DYNPROFIELD = 'P_MATNR'
    VALUE_ORG = 'S'
    TABLES
    VALUE_TAB = ITAB
    EXCEPTIONS
    PARAMETER_ERROR = 1
    NO_VALUES_FOUND = 2
    OTHERS = 3. 
    regards.
    sowjanya.b.

  • Default collapsed view in ALV grid with subtotoal lines

    Hallo experts,
    I am displaying a ALV grid with subtotals. Now my requirement to display the Grid with only subtotal lines. Means the grid should be displayed in collapsed mode by default.
    Can any you help me finding this option.
    Thanks.
    Matt.

    Hallo experts,
    I am displaying a ALV grid with subtotals. Now my requirement to display the Grid with only subtotal lines. Means the grid should be displayed in collapsed mode by default.
    Can any you help me finding this option.
    Thanks.
    Matt.
    Hi Matt,
    Whe you call the FM REUSE_ALV_GRID_DISPLAY, you have to fill the table it_sort.
    In this table, you have to fill the field FIELDNAME with the field that you can show with susbstotals and fill the field EXPA with 'X'.
    W_SORT-SPOS = 1.
    W_SORT-FIELDNAME = 'CODIGO'.
    W_SORT-SUBTOT = 'X'.
    W_SORT-EXPA = 'X'.
    APPEND W_SORT TO IT_SORT.
    In the fieldcatalog there must be any with the field DO_SUM = 'X'
    You can maka this directly in the list by creating a variant with susbtotals, colapse them and save as a default variant for all users.
    Regards,
    Pepe
    Regards,
    Pepe

Maybe you are looking for