Mark fields (columns) in editable ALV Grid as mandatory

Hi,
could you please help me to set up a column in an editable alv grid as mandatory? I had a look in several references and also did not find anything in the fieldcatalog structure.
Best regards,
Fabian

Hello Fabian
Here is some coding to explain what I meant.
*& Report  ZUS_SDN_ALV_ERROR_LOG
REPORT  zus_sdn_alv_error_log.
DATA:
  er_data_changed    TYPE REF TO cl_alv_changed_data_protocol.
START-OF-SELECTION.
* Dynpro is empty (contains no elements)
  CALL SCREEN '0100'.
END-OF-SELECTION.
*&      Module  PBO_0100  OUTPUT
*       text
MODULE pbo_0100 OUTPUT.
* Event DATA_CHANGED was fired due to changes in the editable ALV grid
  IF ( er_data_changed IS BOUND ).
* User did not change any values
  ELSE.
    CREATE OBJECT er_data_changed
*      EXPORTING
*        I_CONTAINER =
*        I_CALLING_ALV = <your ALV grid instance>
  ENDIF.
* That is how your code probably looks like
*  LOOP AT gt_outtab INTO gs_outtab.
*    IF ( gs_outtab-obligatory IS INITIAL ).
*      CALL METHOD go_alvlog->add_protocol_entry
*        EXPORTING
*          i_msgid     = '00'
*          i_msgty     = 'E'
*          i_msgno     = '398'
*          I_MSGV1     = 'Field OBLIGATORY must not be empty'
**          I_MSGV2     =
**          I_MSGV3     =
**          I_MSGV4     =
*          i_fieldname = 'OBLIGATORY'
**          I_ROW_ID    =
*          I_TABIX     = syst-tabix
*    ENDIF.
*  ENDLOOP.
* Generate a protocol for testing purposes
  DO 5 TIMES.
    CALL METHOD er_data_changed->add_protocol_entry
      EXPORTING
        i_msgid     = '00'
        i_msgty     = 'E'
        i_msgno     = '398'
        i_msgv1     = 'Field OBLIGATORY must not be empty'
*          I_MSGV2     =
*          I_MSGV3     =
*          I_MSGV4     =
        i_fieldname = 'OBLIGATORY'
        i_row_id    = syst-index
        i_tabix     = syst-index
  ENDDO.
  CALL METHOD er_data_changed->display_protocol
*    EXPORTING
*      I_CONTAINER =
ENDMODULE.                 " PBO_0100  OUTPUT
Please note that this report dumps as soon as you close the log popup. However, this will not happen within your event handler method.
Regards
  Uwe

Similar Messages

  • Mandatory Fields on Editable ALV Grid

    Hi. I am using oops method to make an editable ALV grid.
    How do I sent some columns for mandatory data entry?
    Here are my declarations
    gs_layout TYPE lvc_s_layo, "Layout declaration
    go_grid TYPE REF TO cl_gui_alv_grid,  "Grid
    go_custom_container TYPE REF TO cl_gui_custom_container,"Container
    go_fieldcat type lvc_t_fcat, "Field Catalog
    Thanks,
    Shareen

    Hi Shareen Hegde ,
    Try this program.
    report zshail_alv_new .
    tables: sflight.
    type-pools: icon.
    data: pt_sort type lvc_t_sort.
    data: my_column type table of lvc_s_ceno with header line.
    data: t_hype type LVC_T_HYPE.
    class shail_event definition.
    public section.
    methods:
    handle_toolbar for event toolbar of cl_gui_alv_grid
    importing e_object e_interactive,
    handle_user_command for event user_command of cl_gui_alv_grid importing
    e_ucomm,
    handle_contextmenu_request for event context_menu_request of
    cl_gui_alv_grid importing e_object.
    endclass.
    class shail_event implementation.
    method handle_toolbar.
    perform handler_toolbar using e_object e_interactive.
    endmethod.
    method handle_user_command.
    perform handler_user_command using e_ucomm.
    endmethod.
    method handle_contextmenu_request.
    perform handler_contextmenu_request using e_object.
    endmethod.
    endclass.
    data: go_container type ref to cl_gui_custom_container,
          go_grid type ref to cl_gui_alv_grid,
          field_catalog type lvc_t_fcat,
          layout type lvc_s_layo.
    data: begin of itab occurs 0.
    include structure sflight.
    data: end of itab.
    data: obj type ref to shail_event.
    data: button_exclude type ui_functions.
    start-of-selection.
    call screen 200.
    *&      Module  STATUS_0100  OUTPUT
          text
    module status_0100 output.
    SET PF-STATUS 'xxxxxxxx'.
    SET TITLEBAR 'xxx'.
    if go_container is initial.
    create object go_container
      exporting
       PARENT                      =
        container_name              = 'ALV_CONTAINER'
       STYLE                       =
       LIFETIME                    = lifetime_default
       REPID                       =
       DYNNR                       =
       NO_AUTODEF_PROGID_DYNNR     =
    EXCEPTIONS
       CNTL_ERROR                  = 1
       CNTL_SYSTEM_ERROR           = 2
       CREATE_ERROR                = 3
       LIFETIME_ERROR              = 4
       LIFETIME_DYNPRO_DYNPRO_LINK = 5
       others                      = 6
    if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    create object go_grid
      exporting
       I_SHELLSTYLE      = 0
       I_LIFETIME        =
        i_parent          = go_container
       I_APPL_EVENTS     = space
       I_PARENTDBG       =
       I_APPLOGPARENT    =
       I_GRAPHICSPARENT  =
       I_USE_VARIANT_CLASS = SPACE
       I_NAME            =
    EXCEPTIONS
       ERROR_CNTL_CREATE = 1
       ERROR_CNTL_INIT   = 2
       ERROR_CNTL_LINK   = 3
       ERROR_DP_CREATE   = 4
       others            = 5
    if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    create object obj.
    set handler obj->handle_toolbar for go_grid.
    set handler obj->handle_user_command for go_grid.
    set handler obj->handle_contextmenu_request for go_grid.
    select * from sflight into corresponding fields of table itab.
    perform catalog_fill changing field_catalog.
    perform layout_fill changing layout.
    perform prepare_sort_table changing pt_sort.
    call method go_grid->set_table_for_first_display
      exporting
       I_BYPASSING_BUFFER            =
       I_BUFFER_ACTIVE               =
       I_CONSISTENCY_CHECK           =
       I_STRUCTURE_NAME              = 'SFLIGHT'
       IS_VARIANT                    =
       I_SAVE                        =
       I_DEFAULT                     = 'X'
        is_layout                     = layout
       IS_PRINT                      =
       IT_SPECIAL_GROUPS             =
        it_toolbar_excluding          = button_exclude
        IT_HYPERLINK                  = t_hype
       IT_ALV_GRAPHICS               =
       IT_EXCEPT_QINFO               =
      changing
        it_outtab                     = itab[]
        it_fieldcatalog               = field_catalog
        it_sort                       = pt_sort
       IT_FILTER                     =
    EXCEPTIONS
       INVALID_PARAMETER_COMBINATION = 1
       PROGRAM_ERROR                 = 2
       TOO_MANY_LINES                = 3
       others                        = 4
    if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    else.
    call method go_grid->refresh_table_display
    EXPORTING
       IS_STABLE      =
       I_SOFT_REFRESH =
    EXCEPTIONS
       FINISHED       = 1
       others         = 2
    if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    endif.
    endmodule.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
          text
    module user_command_0100 input.
    case sy-ucomm.
    when 'BACK'.
    LEAVE TO SCREEN 0.
    endcase.
    endmodule.                 " USER_COMMAND_0100  INPUT
    *&      Form  CATALOG_FILL
          text
         <--P_FIELD_CATALOG  text
    form catalog_fill changing p_field_catalog.
    data ls_fcat type lvc_s_fcat .
    ls_fcat-fieldname = 'CARRID' .
    ls_fcat-inttype = 'C' .
    ls_fcat-outputlen = '20' .
    ls_fcat-coltext = 'Carrier ID' .
    ls_fcat-web_field = 'carrid_handle'.
    ls_fcat-edit = 'X'.
    *ls_fcat-emphasize = 'C310'.   "needed for column coloring
    append ls_fcat to field_catalog .
    clear ls_fcat .
    ls_fcat-fieldname = 'FLDATE' .
    ls_fcat-ref_table = 'SFLIGHT' .
    ls_fcat-ref_table = 'FLDATE' .
    ls_fcat-outputlen = '20' .
    ls_fcat-coltext = 'Flight Date' .
    ls_fcat-web_field = 'fldate_handle'.
    append ls_fcat to field_catalog .
    clear ls_fcat .
    ls_fcat-fieldname = 'PRICE' .
    ls_fcat-ref_table = 'SFLIGHT' .
    ls_fcat-ref_table = 'PRICE' .
    ls_fcat-outputlen = '20' .
    ls_fcat-coltext = 'Airfare' .
    append ls_fcat to field_catalog .
    clear ls_fcat .
    ls_fcat-fieldname = 'SEATSMAX' .
    ls_fcat-ref_table = 'SFLIGHT' .
    ls_fcat-ref_table = 'SEATSMAX' .
    ls_fcat-outputlen = '20' .
    ls_fcat-coltext = 'Maximum seats' .
    append ls_fcat to field_catalog .
    endform.                    " CATALOG_FILL
    *&      Form  LAYOUT_FILL
          text
         <--P_LAYOUT  text
    form layout_fill changing p_layout type lvc_s_layo.
    p_layout-zebra = 'X' .
    p_layout-grid_title = 'Flights' .
    p_layout-smalltitle = 'X' .
    p_layout-no_merging = 'X'.
    *p_layout-sel_mode = 'A'.
    *p_layout-info_fname = 'rowcolor'.
    endform.                    " LAYOUT_FILL
    *&      Form  exclude_std_buttons
          text
         <--P_BUTTON_EXCLUDE  text
    form exclude_std_buttons changing p_button_exclude type ui_functions.
    the various buttons are details,sort asc,sort desc,find,set filter,
    total, subtotal,
    print,view,export,changelayout,display graphic, eu documentation
    MC_FC_DETAIL,MC_FC_FIND,MC_FC_FILTER,MC_FC_GRAPHIC,MC_FC_SORT_ASC,
    MC_FC_SORT_DSC,MC_FC_SUBTOT,MC_FC_SUM,MC_FC_PC_FILE,MC_FC_VIEWS
    data: ls_exclude type ui_func.
    ls_exclude = cl_gui_alv_grid=>mc_fc_detail.
    append ls_exclude to p_button_exclude.
    ls_exclude = cl_gui_alv_grid=>mc_fc_find.
    append ls_exclude to p_button_exclude.
    ls_exclude = cl_gui_alv_grid=>mc_fc_filter.
    append ls_exclude to p_button_exclude.
    ls_exclude = cl_gui_alv_grid=>mc_fc_graph.
    append ls_exclude to p_button_exclude.
    ls_exclude = cl_gui_alv_grid=>mc_fc_sort_asc.
    append ls_exclude to p_button_exclude.
    ls_exclude = cl_gui_alv_grid=>mc_fc_sort_dsc.
    append ls_exclude to p_button_exclude.
    ls_exclude = cl_gui_alv_grid=>mc_fc_subtot.
    append ls_exclude to p_button_exclude.
    ls_exclude = cl_gui_alv_grid=>mc_fc_sum.
    append ls_exclude to p_button_exclude.
    ls_exclude = cl_gui_alv_grid=>mc_fc_print.
    append ls_exclude to p_button_exclude.
    ls_exclude = cl_gui_alv_grid=>mc_fc_views.
    append ls_exclude to p_button_exclude.
    endform.                    " exclude_std_buttons
    *&      Form  handle_toolbar
          text
         -->P_E_OBJECT  text
         -->P_E_INTERACTIVE  text
         -->P_ENDMETHOD  text
    form handler_toolbar using    p_e_object type ref to
    cl_alv_event_toolbar_set
                                 p_e_interactive                   .
    data: ls_toolbar type stb_button.
    clear ls_toolbar.
    move 'PER' to ls_toolbar-function. "#EC NOTEXT
    move icon_display_text to ls_toolbar-icon.
    move 'Test Info'(201) to ls_toolbar-quickinfo.
    move 'Test Info'(201) to ls_toolbar-text.
    move ' ' to ls_toolbar-disabled. "#EC NOTEXT
    append ls_toolbar to p_e_object->mt_toolbar.
    endform.                    " handle_toolbar
    *&      Form  handle_user_command
          text
         -->P_E_UCOMM  text
    form handler_user_command using    p_e_ucomm.
    case p_e_ucomm.
    when 'PER'.
    perform selected_columns.
    when 'CREA'.
    message i001(zmess).
    endcase.
    endform.                    " handle_user_command
    *&      Form  prepare_sort_table
          text
         <--P_PT_SORT  text
    form prepare_sort_table changing p_pt_sort type lvc_t_sort.
    data: ls_sort type lvc_s_sort.
    ls_sort-spos = '1'.
    ls_sort-fieldname = 'FLDATE'.
    ls_sort-up = space.
    ls_sort-down = 'X'.
    append ls_sort to p_pt_sort.
    endform.                    " prepare_sort_table
    *&      Form  handler_contextmenu_request
          text
         -->P_E_OBJECT  text
    form handler_contextmenu_request using    p_e_object type ref to
    cl_ctmenu.
    *CALL METHOD p_e_object->hide_functions
    EXPORTING
       fcodes = LT_FCODES
    CALL METHOD p_e_object->clear
    *break-point.
    CALL METHOD p_e_object->add_function
      EXPORTING
        fcode       = 'CREA'
        text        = 'Add Function'
       ICON        =
       FTYPE       =
       DISABLED    =
       HIDDEN      =
       CHECKED     =
       ACCELERATOR =
    endform.                    " handler_contextmenu_request
    *&      Form  selected_columns
          text
    -->  p1        text
    <--  p2        text
    form selected_columns.
    CALL METHOD go_grid->get_selected_cells_id
       IMPORTING
         ET_CELLS = my_column[]
    loop at my_column.
    this will specify the id of the selected cell
    message i001(zmess) with my_column-row_id.
    message i002(zmess) with my_column-col_id.
    endloop.
    endform.                    " selected_columns
    *&      Form  display_values
          text
         -->P_ROW_ID  text
    *&      Form  prepare_hyp_tab
          text
         <--P_T_HYPE  text
    form prepare_hyp_tab changing p_t_hype type lvc_t_hype.
    endform.                    " prepare_hyp_tab
    *&      Module  STATUS_0200  OUTPUT
          text
    module STATUS_0200 output.
    SET PF-STATUS 'xxxxxxxx'.
    SET TITLEBAR 'xxx'.
    endmodule.                 " STATUS_0200  OUTPUT
    *&      Module  USER_COMMAND_0200  INPUT
          text
    module USER_COMMAND_0200 input.
    CASE SY-UCOMM.
    WHEN 'NEXT'.
    CALL SCREEN 100.
    WHEN 'EXIT'.
    LEAVE PROGRAM.
    ENDCASE.
    endmodule.                 " USER_COMMAND_0200  INPUT
    Good Luck and REWARD ME for the same
    Thanks
    Ashok.N

  • Urgent : Problem with Editable  ALV Grid  for Quantity and Currency Fields

    Hi All,
    I am using Editable ALV Grid display and have quantity and value as editable fields in the display.
    When user changes these values these values are not changing properly .
    For the quantity field the domain is MENG13 with 3 deciamal places and here  if we enter 500 it takes it as 0.500   .
    The same problem is for the currency field. Here the Domain is WERT7 with 3 decimal places.
    Here also it takes last 2 digits after decimal places by default.
    Please advice how to get proper values in this case from ALV editable fields.
    Thanks and Regards
    Harshad
    Edited by: Harshad Rahirkar on Dec 25, 2007 7:39 AM

    for all the currency field , it will display like that only.
    u have to manipulate uin program before displaying.
    if they are giving 500, in program multiply with 100 and move it to table.
    when u are getting from table, divinde and display.
    this is what I am doing.
    Reward if helpfull.

  • How to make fields/columns un-editable in ALV

    Hi,
    How can I make a field/column un-editable in ALV.
    I tried writing: ls_fc_po-edit = ' '.     (inside loop for the selected column/field), but it doesnot work for me.
    Any suggestions please.
    Thanks,
    Ravish

    The code for the field catalogue is below:
    LOOP AT lt_fc_po INTO ls_fc_po.
        IF ls_fc_po-fieldname EQ 'PO_ID'.
          ls_fc_po-no_out = 'X'.
        ELSEIF ls_fc_po-fieldname EQ 'UNIT_OF_MEASURE'.
          ls_fc_po-outputlen = '10'.
          ls_fc_po-tooltip = 'Unit of Measure'.
        ELSEIF ls_fc_po-fieldname EQ 'ITEM_ID'.
          ls_fc_po-outputlen = '10'.
          ls_fc_po-tooltip = 'Purchase Order Items'.
        ELSEIF ls_fc_po-fieldname EQ 'QUANTITY'.
          ls_fc_po-outputlen = '10'.
        ELSEIF ls_fc_po-fieldname EQ 'CURRENCY'.
          ls_fc_po-edit = ' '.
          ls_fc_po-outputlen = '10'.
          ls_fc_po-tooltip = 'Currency'.
        ELSEIF ls_fc_po-fieldname EQ 'DATE_OF_DELIVERY'.
          ls_fc_po-outputlen = '18'.
          ls_fc_po-coltext = 'Delivery Date'.
          ls_fc_po-tooltip = 'Requested Delivery date'.
        ELSEIF ls_fc_po-fieldname EQ 'PLANT_ID'.
          ls_fc_po-outputlen = '15'.
          ls_fc_po-coltext = 'Plant'.
          ls_fc_po-tooltip = 'Plant Identifier'.
        ELSEIF ls_fc_po-fieldname EQ 'MATERIAL_DESC'.
          ls_fc_po-outputlen = '18'.
        ELSEIF ls_fc_po-fieldname EQ 'MATERIAL_ID'.
          ls_fc_po-outputlen = '15'.
          ls_fc_po-coltext = 'Material'.
          ls_fc_po-tooltip = 'Material Identifier'.
          IF GL_PO_EVENT_ALV = 0.
            GL_PO_EVENT_ALV = 1.
            data: l_field type lvc_fname.
            data: lt_f4 type  lvc_t_f4.
            data: ls_f4 type lvc_s_f4.
            l_field = ls_fc_po-fieldname.
            ls_f4-fieldname  = l_field.
            ls_f4-register   = 'X'.
            ls_f4-getbefore  = 'X'.
            ls_f4-chngeafter = 'X'.
            append ls_f4 to lt_f4.
            CALL METHOD po_itm_trn_alvgrid->register_f4_for_fields
              EXPORTING
                it_f4 = lt_f4.
          ENDIF.
        ENDIF.
        MODIFY lt_fc_po FROM ls_fc_po.
      ENDLOOP.

  • Problem While Saving the editable ALV GRID

    Dear Experts,
    I have a scenario in which i am display the ALV(using class) with some data in the custom container of module pool screen in the non-editable mode.Also i have save and edit buttons.If i click the edit button i have written the code to edit the some columns in the ALV grid, it is working fine.After editing it,when i click the save button then ALV has to refreshed with edited data and then it should go to non editable mode but it is not working.I have written the code for changing the editable ALv to non editable mode as follows :
      call method c_alvgd->set_ready_for_input
        exporting
          i_ready_for_input = 0.
    *****Row and column of the alv are refreshed after changing values
      stable-row = 'X'.
      stable-col = 'X'.
    *REfreshed ALV display with the changed values
    *This ALV is non editable and contains new values
      call method c_alvgd->refresh_table_display
        exporting
          is_stable = stable
        exceptions
          finished  = 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.
    Could you Suggest me solution for this issue ?
    Thanks & Regards,
    R.Dhineshraj.

    Dhinesh,
    I suppose that you are able to get your changes values on screen but not able to get your field in DISPLAY mode from editable mode, let me know if this is not your problem.
    When you press SAVE, after the PAI, again PBO will run and hence the editable code for that field will overwrite which will keep it editable.
    So, do something like this.
    data: gv_edit value 'X'.....  "global variable in TOP include
    PBO....
    loop at ...
    if gv_edit = 'X'.
    CALL METHOD lo_alv->set_ready_for_input
      EXPORTING
        i_ready_for_input = 1.
    else.
    CALL METHOD lo_alv->set_ready_for_input
      EXPORTING
        i_ready_for_input = 0.
    endif.
    endloop.
    PAI.
    when 'SAVE'.
    gv_edit =  space.
    When 'EDIT'.
    gv_edit = 'X'.
    Regards,
    Diwakar

  • Field catalog update in ALV grid

    Hi All,
    When you're changing an existing field catalog in an ALV grid, there's a possibility this change will not appear immediately in the list display.
    Can anyone explain this,
    Kind regards,
    Rob Makelaar.
    The Netherlands

    Hi Rob
    ALV as an encapsulated object uses some kind of buffer for the field catalog. You can switch buffer capabilities with the parameter <b>"I_BUFFER_ACTIVE"</b> of the method <b>"set_table_for_first_display"</b>.
    The use of this parameter is explained as follows:
    <i>Flag to be set by the application if the method call is static. This means the method is always called with the same field catalog. In this case, the field catalog can be held in a special buffer. This accelerates the display of small lists, in particular.</i>
    And as an additional point, you should have marked this thread as a question thread since you require some answer. If you want so, you can do this by editing your original post and check relevant checkbox under the editbox. This way you can reward points to helpful posts using the scala at the left of each particular post and you can mark a question as solved to save SDNers's times.
    Regards
    *--Serdar <a href="https://www.sdn.sap.com:443http://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.sdn.businesscard.sdnbusinesscard?u=qbk%2bsag%2bjiw%3d">[ BC ]</a>

  • How to switch off column coloring of alv grid printouts?

    Hello World!
    Is there any possibility (a customizing option or a parameter) to switch off cell/column coloring of alv grid printouts?
    It is very useful to see colored columns in screens, but they are darkened in printouts. How to avoid it?
    Thanks and regards,
    Vladimir

    Hi,
    You can have different layouts for a ALV report and each layout the look and feel can be different.
    So, the manual activity is the user will have to switch to the B/W layout before printing. I am not sure if you have enabled the LAYOUT option for the user to change it by himself.
    I hope I am able to get across my point.
    If you are using OO ALV control, you can dynamically change the layout using set_frontend_layout  method. The user can also change the layout --
    choose Change layout or Settings ® Layout ® Change.
    The Change Layout dialog box shows you which columns are currently displayed and which additional columns can be displayed.
    Regards,
    Ravi
    Note - Please mark the helpful answers
    Message was edited by: Ravikumar Allampallam

  • Check_changed_data method on editable ALV Grid ( class cl_gui_alv_grid)

    Hi guys,
    I use the following method (register_edit_event) in the PBO soon after first display of an editable ALV grid to register enter as an event to do validations on fields like qty. If user enters some character like 'abc' for qty and hits enter on keyboard, ALV grid pop's up a standard message ( I haven't coded for this.Since I use DDIC structure in field catalog, the Std. ALV program takes care of it. ). THis takes care of the validation before I click on save.
    call method alv_grid->register_edit_event
                            exporting
                               i_event_id = cl_gui_alv_grid=>mc_evt_enter.
    This works fine. But I want this validation to run when I also click the SAVE button of the screen. Is it possible to run this standard validation in my PAI event eg. SAVE ? I thought I will be, by calling the method check_changed_data in my PAI event. But this is doing nothing. Does this method conflict with register_edit_event or something ? So , basically what I am looking for is to trigger the event or call the method which does the same work as the "check" button on ALV grid.
    Any advice or tips or sample code is greatly appreciated.
    Thanks,
    Shareen

    Hi Shareen,
    Handle the data_changed event in the grid.
    Whenever you make changes in the data in ALV Grid this event would be triggered. Here you can perform additional validations that you may need to perform.
        METHODS handle_data_changed
          FOR EVENT data_changed OF cl_gui_alv_grid
          IMPORTING er_data_changed.
    Implementation:
      METHOD handle_data_changed.
        PERFORM validations USING er_data_changed.
      ENDMETHOD.
    FORM validations USING er_data_changed TYPE REF TO cl_alv_changed_data_protocol.
      DATA: ls_good TYPE lvc_s_modi.
      DATA  wa LIKE LINE OF lt_good_cells.
      CALL METHOD g_grid->register_edit_event
        EXPORTING
          i_event_id = cl_gui_alv_grid=>mc_evt_modified.
      LOOP AT er_data_changed->mt_good_cells INTO ls_good.
        CASE ls_good-fieldname.
        WHEN 'FIELDNAME'. "Your fieldname
            CALL METHOD er_data_changed->get_cell_value "Get the changed value
              EXPORTING
                i_row_id    = ls_good-row_id
                i_fieldname = ls_good-fieldname
              IMPORTING
                e_value     = temp. "Your temp variable
            "Make your validations here.
        ENDCASE.
    Ps: Reward points if helpful.
    Regards,
    Wenceslaus.

  • How to disable sorting for some columns in a ALV GRID?

    Hi i have requirement where I have to disable sorting for some columns in a ALV GRID. i am using REUSE_ALV_GRID_DISPLAY function module.
    Can anybody help me. how to acieve this? Any code snippets will really be appreciated.

    Hi,
    I have tried this but not completely successful. I think this can be done using the OOPS method.
      DATA: it_event_exit TYPE  slis_t_event_exit.
      DATA: w_exit TYPE slis_event_exit.
      w_exit-ucomm = '&ODN'.
      w_exit-before = 'X'.
      CLEAR w_exit-after.
      APPEND w_exit TO it_event_exit.
      w_exit-ucomm = '&OUP'.
      w_exit-before = 'X'.
      CLEAR w_exit-after.
      APPEND w_exit TO it_event_exit.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program          = w_repid
          i_callback_top_of_page      = 'ALV_TOP_OF_PAGE'
          i_callback_html_top_of_page = 'ALV_HTML_TOP_OF_PAGE'
          i_callback_user_command     = 'USER_COMMAND'  <- User command form
          is_layout                   = wm_layout
          it_fieldcat                 = wt_fieldcat
          it_events                   = i_events
          it_event_exit               = it_event_exit    <- Need to fill
          it_sort                     = wt_sort
          i_default                   = 'X'
    Now you can capture this events in the user command
    FORM user_command  USING r_ucomm LIKE sy-ucomm
                             rs_selfield TYPE slis_selfield.
      IF r_ucomm = '&OUP' and rs_selfield-SEL_TAB_FIELD = 'Your field name'.
      ENDIF.
    ENDFORM.                    "user_command
    In this form you will get the function code in 'r_ucomm' and the field selected for sorting in 'rs_selfield-SEL_TAB_FIELD'. But reseting 'r_ucomm' will not work.
    May be somebody else can give some help on this.
    But this will work if you follow the oop method.
    Please see this document for more info.
    http://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/abap/an easy reference for alv grid control.pdf
    Thanks
    Vinod

  • Determining Duplicate Entries in Editable ALV Grid

    Hopefully this question is not as obvious as it may seem at first. Thanks for any input or ideas...read carefully, it is not just a simple duplicate check with which I'm having a problem.
    I have an editable ALV grid and I need to ensure that the user doesn't try to enter the same material number twice. I used the program BCALV_EDIT_03 and 04 as a model. I can tell if in my session a user is trying to put in the material number twice. Not a problem. I can also tell if the user is trying to add a material to the ones already on the grid that is a duplicate. That is not a problem either. Here is the catch...and I'd like to point out that BCALV_EDIT_04 has the same problem.
    The user enters line 10 with material 0245 and line 20 with 0345. There is no duplicate. Then they say, 'Oooops, I got them backward' and then move 0345 to line 10 and 0245 to line 20.  When you hit enter, the change handler says that line 10 and 20 were changed and the field MATNR was changed. It then compares the new fields to what is already in the grid...low and behold the grid already has these two entries and the protocol adds the error for both lines.
    I will add the code here, but it is pretty much exactly as in BCALV_EDIT_04. If you want to see the error in that program execute it, put in two new lines with the same airline and two different dates and hit save. Everything is fine. Then swap the dates and hit Save again...it will say these are duplicates, which they are not...this program is not saving to the database. The only difference between mine and bcalv_edit_04 is that mine uses an 'ENTER' event and not a 'SAVE'.
    I'm looking for good ideas on how to compare the two...the mt_good_cells (session active) and the grid itself to know when a user has 'moved' data. The current workaround is for the user to copy the line and then reapply it...but that seems a bit glitchy.
    Thanks in advance, I appreciate any sage advice. : )
    METHOD check_double_entries.
        DATA: lt_good_cells TYPE lvc_t_modi,
              ls_good TYPE lvc_s_modi,
              l_matnr TYPE matnr,
              l_del_row TYPE lvc_s_moce,
              ls_rosi LIKE LINE OF i_rosi,
              l_reentered TYPE c.
        LOOP AT pr_data_changed->mt_good_cells INTO ls_good.
          CASE ls_good-fieldname.
            WHEN 'MATNR'.
              CALL METHOD pr_data_changed->get_cell_value
                EXPORTING
                  i_row_id    = ls_good-row_id
                  i_fieldname = ls_good-fieldname
                IMPORTING
                  e_value     = l_matnr.
              READ TABLE lt_good_cells WITH KEY
                                value = l_matnr
                                TRANSPORTING NO FIELDS.
              IF sy-subrc = 0.
                CALL METHOD pr_data_changed->add_protocol_entry
                  EXPORTING
                    i_msgid     = '0K'
                    i_msgno     = '000'
                    i_msgty     = 'E'
                    i_msgv1     = text-m01
                    i_fieldname = ls_good-fieldname
                    i_row_id    = ls_good-row_id.
                error_in_data = 'X'.
              ELSE.
                ls_good-value = l_matnr.
                APPEND ls_good TO lt_good_cells.
              ENDIF.
          ENDCASE.
        ENDLOOP.
        LOOP AT lt_good_cells INTO ls_good.
          l_matnr = ls_good-value.
          READ TABLE i_rosi WITH KEY matnr = l_matnr
                        TRANSPORTING NO FIELDS.
          IF sy-subrc = 0.
            l_reentered = space.
            LOOP AT pr_data_changed->mt_deleted_rows INTO l_del_row.
              READ TABLE i_rosi INTO ls_rosi INDEX l_del_row-row_id.
              IF sy-subrc NE 0.
                MESSAGE i000(0k) WITH text-e01.
              ELSEIF ls_rosi-matnr EQ ls_good-value.
                l_reentered = 'X'.
              ENDIF.
            ENDLOOP.
            IF l_reentered NE 'X'.
              CALL METHOD pr_data_changed->add_protocol_entry
                EXPORTING
                  i_msgid     = '0K'
                  i_msgno     = '000'
                  i_msgty     = 'E'
                  i_msgv1     = text-m01
                  i_fieldname = ls_good-fieldname
                  i_row_id    = ls_good-row_id.
              error_in_data = 'X'.
            ENDIF.
          ENDIF.
        ENDLOOP.
      ENDMETHOD.                    "check_double_entries

    Hi Greg,
    please check your posting in the prview tab. If the code is not formatted, you posted too much. Reduce and try again, then somebody may be willing to read.
    Regards,
    Clemens

  • Hiding a column in an ALV Grid

    Hi ,
    I want to hide a column in an ALV grid and I am doing it as such.However it doesn't work.
    data : gw_fieldcat type lvc_s_fcat,
              gt_fieldcat type lvc_t_fcat.
    perform build_grid1 changing gt_fieldcat.
    form build_grid1 changing p_gt_ss.
    gw_fieldcat-fieldname   = 'UKURS'.
    gw_fieldcat-scrtext_m   = 'Exchange rate'.
    gw_fieldcat-no_out      = 'X'.
    gw_fieldcat-col_pos     = 9.
    APPEND gw_fieldcat TO gt_fieldcat.
    endform.
    Kindly suggest.

    Hi,
    As per code it looks good..check in the debugging corresponding to the field 'UKURS is no_out has value X in the fieldcatalog.

  • All the columns of an alv grid report are not downloading in excel in 1 lin

    Hi All,
    I have some 60 columns in my alv grid report and user can download the report using list->export->localfile->spreadsheet.
    What the issue is that all the columns are not downloading in one line, instead they split in two rows.
    Please help.
    Regards,
    Neha Patel

    hi,
    just use this procedure it will solve your problem:
    Firstly export  the data to memory using the FM LIST_FROM_MEMORY.
    CALL FUNCTION 'LIST_FROM_MEMORY'
    TABLES
    listobject = t_listobject
    EXCEPTIONS
    not_found = 1
    OTHERS = 2.
    IF sy-subrc 0.
    MESSAGE e000(su) WITH text-001.
    ENDIF.
    then i converted it into ASCII using LIST_TO_ASCI,
    CALL FUNCTION 'LIST_TO_ASCI'
    TABLES
    listasci = t_xlstab
    listobject = t_listobject
    EXCEPTIONS
    empty_list = 1
    list_index_invalid = 2
    OTHERS = 3.
    IF sy-subrc NE 0.
    MESSAGE e003(yuksdbfzs).
    ENDIF.
    This gives the data in ASCII format separated by '|' and the header has '-', dashes. If you use this internal table directly without any proccesing in SO_NEW_DOCUMENT_ATT_SEND_API1, then you will not get a good excel sheet attachment. To overcome this limitation, i used cl_abap_char_utilities=>newline and cl_abap_char_utilities=>horizontal_tab to add horizontal and vertical tabs to the internal table, replacing all occurences of '|' with
    cl_abap_char_utilities=>horizontal_tab.
    Set the doc_type as 'XLS', create the body and header using the packing_list and pass the data to be downloaded to SO_NEW_DOCUMENT_ATT_SEND_API1 as contents_bin.
    This will create an excel attachment.
    Sample code for formatting the data for the attachment in excel format.
    u2022     Format the data for excel file download
    LOOP AT t_xlstab INTO wa_xlstab .
    DESCRIBE TABLE t_xlstab LINES lw_cnt.
    CLEAR lw_sytabix.
    lw_sytabix = sy-tabix.
    u2022     If not new line then replace '|' by tabs
    IF NOT wa_xlstab EQ cl_abap_char_utilities=>newline.
    REPLACE ALL OCCURRENCES OF '|' IN wa_xlstab
    WITH cl_abap_char_utilities=>horizontal_tab.
    MODIFY t_xlstab FROM wa_xlstab .
    CLEAR wa_xlstab.
    wa_xlstab = cl_abap_char_utilities=>newline.
    IF lw_cnt NE 0 .
    lw_sytabix = lw_sytabix + 1.
    u2022     Insert new line for the excel data
    INSERT wa_xlstab INTO t_xlstab INDEX lw_sytabix.
    lw_cnt = lw_cnt - 1.
    ENDIF.
    CLEAR wa_xlstab.
    ENDIF.
    ENDLOOP.
    Sample code for creating attachment and sending mail:
    FORM send_mail .
    u2022     Define the attachment format
    lw_doc_type = 'XLS'.
    u2022     Create the document which is to be sent
    lwa_doc_chng-obj_name = 'List'.
    lwa_doc_chng-obj_descr = w_subject. "Subject
    lwa_doc_chng-obj_langu = sy-langu.
    u2022     Fill the document data and get size of message
    LOOP AT t_message.
    lt_objtxt = t_message-line.
    APPEND lt_objtxt.
    ENDLOOP.
    DESCRIBE TABLE lt_objtxt LINES lw_tab_lines.
    IF lw_tab_lines GT 0.
    READ TABLE lt_objtxt INDEX lw_tab_lines.
    lwa_doc_chng-doc_size = ( lw_tab_lines - 1 ) * 255 + STRLEN( lt_objtxt ).
    lwa_doc_chng-obj_langu = sy-langu.
    lwa_doc_chng-sensitivty = 'F'.
    ELSE.
    lwa_doc_chng-doc_size = 0.
    ENDIF.
    u2022     Fill Packing List For the body of e-mail
    lt_packing_list-head_start = 1.
    lt_packing_list-head_num = 0.
    lt_packing_list-body_start = 1.
    lt_packing_list-body_num = lw_tab_lines.
    lt_packing_list-doc_type = 'RAW'.
    APPEND lt_packing_list.
    u2022     Create the attachment (the list itself)
    DESCRIBE TABLE t_xlstab LINES lw_tab_lines.
    u2022     Fill the fields of the packing_list for creating the attachment:
    lt_packing_list-transf_bin = 'X'.
    lt_packing_list-head_start = 1.
    lt_packing_list-head_num = 0.
    lt_packing_list-body_start = 1.
    lt_packing_list-body_num = lw_tab_lines.
    lt_packing_list-doc_type = lw_doc_type.
    lt_packing_list-obj_name = 'Attach'.
    lt_packing_list-obj_descr = w_docdesc.
    lt_packing_list-doc_size = lw_tab_lines * 255.
    APPEND lt_packing_list.
    u2022     Fill the mail recipient list
    lt_reclist-rec_type = 'U'.
    LOOP AT t_recipient_list.
    lt_reclist-receiver = t_recipient_list-address.
    APPEND lt_reclist.
    ENDLOOP.
    u2022     Finally send E-Mail
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
    document_data = lwa_doc_chng
    put_in_outbox = 'X'
    commit_work = 'X'
    IMPORTING
    sent_to_all = lw_sent_to_all
    TABLES
    packing_list = lt_packing_list
    object_header = lt_objhead
    contents_bin = t_xlstab
    contents_txt = lt_objtxt
    receivers = lt_reclist
    EXCEPTIONS
    too_many_receivers = 1
    document_not_sent = 2
    document_type_not_exist = 3
    operation_no_authorization = 4
    parameter_error = 5
    x_error = 6
    enqueue_error = 7
    OTHERS = 8.
    Hope it will help you
    Regards
    Rahul sharma

  • How to create editable ALV grid/list

    Hi,
    I want to create editable ALV grid/list so that user can modify the data in the ALV.
    And when user presses save button data will get saved in Z table.
    I dont know how to create editable ALV so could anybody please help me regarding this?
    Thanks & regards,
    Sameer Dhuke

    HI
    check the demo programs BCALV_FULLSCREEN_GRID_EDIT
    BCALV_GRID_EDIT
    BCALV_TEST_GRID_EDIT_01
    BCALV_TEST_GRID_EDITABLE
    REUSE_ALV_GRID EDITABLE
    ALV Grid editable fields
    Just to make things a bit easy
    In the layout,there is a property called edit, make it 'X' for the particular field whichever you want to make editable.
    Hope this helps,
    Suruchi
    Message was edited by:
            Suruchi Mahajan

  • Editable ALV Grid: Append new rows

    Hi All,
    I have developed a report which will displays output in editable ALV grid list. Users can modify the values in output and save. These values will be stored in one custom table.
    My requirement is whenever user clicks on '+' mark (Create entries or Append or Copy: Standard toolbar) report should allow to enter new entries and save. How do I capture the selected function code? why becuase i need to display one value from the custom table in that added new row...
    Regards,
    Ramesh.

    Hi Ramesh,
    please check changed data event.....
    please go through the reference link......
    https://wiki.sdn.sap.com/wiki/display/Snippets/UpdatingtheInternalTable-AfterEditinALVusingFunctionModules
    Regards,
    Venkat

  • How can we find out data in an editable ALV grid has been changed or not?

    Hi Experts,
    How can we find out whether a data in an editable ALV grid has been changed or not.
    I am using the
    FM -> REUSE_ALV_GRID_DISPLAY_LVC
    for ALV display.
    I have to chekc whther data has been changed or not befor saving. if changed then only i want to
    SAVE
    . I cannot use the internal table comparison method for this purpose also i am not using OOP ALV.
    So kindly sugest me an alternative.
    Thanks and Regards,
    Shahana

    Hi,
    Thanks for your answer. I already saw this post.
    See this method.
    CALL METHOD reuse_alv_grid->check_changed_data
    IMPORTING
    e_valid = lv_check.
    This will update the internal table with the edited values. Then we can go for internal table comparison.
    But my scenario will not allow me for itab comparisons.I just want to know the ALV data has been changed or not.
    Regards,
    Shahana

Maybe you are looking for

  • Search in Sharepoint Foundation 2013 sp1 do not work

    When we type anything in any search bar, the result is "Sorry, something went wrong" with Correlation ID: aa0fb79c-5878-d0b4-2016-c1ebc17f3336. The server was originally installed with the 2013 Foundation beta version on a 2008 R2 server (single serv

  • Error while using the Geospatial Range FIlter

    Hello, When I try to use the Geospatial Range Filter I get the error: javax.portlet.PortletException: com.endeca.portal.data.DataSourceException: An error occurred while executing query: exception encountered while executing external function 'intern

  • Adobe AIR for Android - GPU Mode - Bitmap Auto-Smoothing Issue

    Hi everyone I'm having a bit of an issue with the AS3 bitmap object. I'm currently developing an 8-bit style pixel game for AIR for Android. This game is being developed at a very low resolution and is being scaled up to maintain the charm of an old

  • How do i use a song from my i tunes as a rington ?

    so iv just got an i phone 4. ive uploaded alot of albums but how do i choose songs from the albums to use as ringtones ?

  • When releasing Billing, system prompted no accouting document created

    Dear SAP Guru and Experts. Currently user is hitting the error when the Billing is released. The system prompted "no accounting document created". It is understood from the log VFX3 where the G/L code is not maintained in the company code. My questio