Validate ALV entry

Hello.
I'm using an ALV display with a custom field catalog to allow a user to edit data via the ALV display (certain fields).
I create my container and fieldcatalog in the PAI of my screen and use CALL METHOD grid1->refresh_table_display to display it, I can edit the contents of the table displayed in the ALV just fine. Now I want to validate the edits as they happen and pop a message and disallow the edit by a rule/validation I define. Can someone show me how/where/what to insert a validation routine into this?
Thanks!

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.
code METHODS handle_data_changed
FOR EVENT data_changed OF cl_gui_alv_grid
IMPORTING er_data_changed.[/code]
Implementation:
code METHOD handle_data_changed.
PERFORM validations USING er_data_changed.
ENDMETHOD.[/code]
codeFORM 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.
[/code]

Similar Messages

  • Where to validate ALV entries

    We have an editable ALV grid.  Where is the right place to call our validations from?
    Following validation, we also want to (programattically) update some cells in our grid.
    Where is the right place to place the updates?
    Thanks

    Hi,
    You will have many options to validate the ALV entries, based on your requirement you need decide.
    Let us assume if you want to validate on each cell ->then once user enter some value on cell ask them to enter, you need to validate these cell values on_enter event on alv functionality.
    If user want to validate once enter all the cells...then you need to provide some button or use the standard button CHECK on ALV application tool bar..under the Action button youneed to validate.
    Let me know if you need more clarfications on this.
    Regards,
    Naresh.

  • Reset ALV entry in display

    Hello.
    I'm using an ALV display with a custom field catalog to allow a user to edit data via the ALV display (certain fields).
    I create my container and fieldcatalog in the PAI of my screen and use CALL METHOD grid1->refresh_table_display to display it, I can edit the contents of the table displayed in the ALV just fine. I can validate each entry the user makes using the register_edit_event and use CALL METHOD er_data_changed->get_cell_value to get the user data as they enter and I can then validate the entry against my custom rules. My issue is that if the user violates the rules I defined in my code I would like to reset the entry. What method can I use to do this. My code for validation is below.
    CLASS lcl_event_receiver IMPLEMENTATION.
      METHOD handle_data_changed.
        DATA: ls_good TYPE lvc_s_modi.
    DATA wa LIKE LINE OF lt_good_cells.
        CALL METHOD grid1->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.
          v_tabix = sy-tabix.
          CASE ls_good-fieldname.
            WHEN 'QUANTITY'.
              CALL METHOD er_data_changed->get_cell_value
                  EXPORTING
                        i_row_id = ls_good-row_id
                        i_fieldname = 'MATNR'
                  IMPORTING
                        e_value = v_1303matnr.
              CALL METHOD er_data_changed->get_cell_value
                  EXPORTING
                        i_row_id = ls_good-row_id
                        i_fieldname = ls_good-fieldname
                  IMPORTING
                        e_value = v_qtytemp.
    *---> I validate here and if I find an issue I would like to reset or change the cell value.
          ENDCASE.
        ENDLOOP.
      ENDMETHOD.
    Thanks!!

    I have located the answer.
    When I do my validation routine if my error criteria has been reached I through a flag and then execute the method "modify_cell" to reset it to whatever value I choose.
                CALL METHOD er_data_changed->modify_cell
                    EXPORTING
                          i_row_id = ls_good-row_id
                          i_fieldname = <my fieldname>
                          i_value = <value to reset field to>.

  • How to validate table entries for that table

    i hav created one ztable se11.how to validate table entries for that table

    hi,
    create foreign key relation ships
    do the following way
    create a check table with key fields  the fields which you want to check
    create a foreign key relations with that table
    the procedure is as follows
    To create your check table:
    Begin at the Dictionary: Initial Screen.
    Type the table name in the Object Name field.
    Choose the Tables radio button.
    Press the Create button. The Dictionary: Table/Structure: Change Fields screen is displayed.
    Type a short text, choose delivery class A, and tickmark Tab. Maint. Allowed.
    Type the field and data element names at the bottom of the screen.
    Tickmark both fields to indicate that they both form the primary key
    Press the Save button on the Standard toolbar. The Create Object Catalog Entry screen appears.
    Press the Local Object button. You are returned to the Dictionary: Table/Structure: Change Fields screen
    Press the Technical Settings button on the Application toolbar. The ABAP/4 Dictionary: Maintain Technical Settings screen is displayed.
    In the Data Class field, enter APPL0 (APPL0 with a zero, not APPLO with an alphabetic O).
    Enter 0 (zero) in the Size Category field.
    Press the Save button.
    Press the Back button. You are returned to the Dictionary: Table/Structure: Change Fields screen.
    Press the Activate button on the Application toolbar. The message "was activated" appears in the status
    bar and the Status field contains the value Act..
    Choose the menu path Utilities->Create Entries to enter data into your newly created check table. Enter six rows with land1 values of US, CA, DE, IT, JP, and AU.
    Foreign Key Creation Procedure
    To create a foreign key:
    Begin at the Dictionary: Initial Screen.
    In the Object Name field, type the name of the table that is to contain the foreign key .
    Choose the Tables radio button.
    Press the Change button. The Dictionary: Table/Structure: Change Fields screen is displayed.
    Position your cursor on the field that is to become the foreign key
    Press the Foreign Keys button on the Application toolbar. The Create Foreign Key screen will be displayed
    Type a description of the foreign key in the Short Text field, for example, Country Code validation.
    Type the name of the check table (-t005) in the Check Table field, or click on the down-arrow and choose it from the list.
    The Change Foreign Key pop-up appears. It states Check table name was created or changed. Generate a proposal for field assignment? Press the Yes button.
    You are returned to the Create Foreign Key screen. The check table field names and the foreign key field names are displayed. (The check table field names are -t005-mandt and -t005-land1. The foreign key field names are -lfa1-mandt and -lfa1-land1).
    Press the Copy button. You are returned to the Dictionary: Table/Structure: Change Fields screen and the message "Foreign key was transferred" appears in the status bar. The Status fields contain the values Revised and Not saved.
    Press the Activate button on the Application toolbar. The message "was activated" appears in the status bar. The values in the Status fields are now Act. and Saved.
    reward if helpful
    prasanth

  • Validate Journal Entries using write back BADI (UJR_WRITE_BACK)

    Hi Experts
    I need to validate journal entries such that the total credit and debit postings for each COMPANY is equal. Also I need to do the same validation by PROFIT CENTER. After doing a bit of research I found out that the best way to do it is by coding it in the write back BADI.
    Has anyone faced such a situation before? Is there any better way to do it? Can anyone share the code?
    Thanks
    Edited by: Shisher Chakrabarty on Mar 1, 2012 10:22 AM

    Hi Shisher,
    Please check the below guide for Write Back BADI. The doc has also got the source code for the same.
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/f0309226-814f-2d10-61a6-ef8da29e3727?QuickLink=index&overridelayout=true&48056389302995
    Regards,
    Raghu

  • Validate form entries: does java support regular expressions?

    i want to validate form entries, does java support regular express like javascript?

    Just recently in 1.4 regex was finally introduced :)
    Take a look at http://developer.java.sun.com/developer/technicalArticles/releases/1.4regex/

  • How to validate an entry in a table?

    I have a (single column) table view linked to an NSArrayController that has a custom class definition as its 'Class Name'. I also have KVC compliant methods to populate the array controller within my 'model'. I can see the 'countOf...' and 'objectIn...AtIndex' methods being called and the table contains the correct data.
    I have the 'Validates Immediately' option set on both the table column binding and the controller content array binding.
    My problems come when I alter the contents of an entry in the table. Firstly, the only 'validate...:error:' method that is called is on the custom class for the field that is updated.
    Secondly, the 'insertObject:in...:AtIndex' and similar (especially the 'replaceObjectIn...AtIndex:withObject:') methods are not called.
    I have checked and rechecked that the KVC names include the correctly capitalised name of the class.
    How can I get the validation (and other) routines to be called?
    Thanks
    Susan

    Abandoned!!

  • Possible to validate data entries during Digital Signature?

    I have a form that was built from scratch using Adobe LiveCycle  Designer ES 8.2. I also have Adobe Acrobat Pro 9.3.2. (WinXP)
    I  see numerous articles online related to validating user input prior to  data submission for an online form via a Submit button, however, I  am trying to figure out how to implement the same sort of data  validation during the signing of a particular digital signature field in an offline pdf form. Simply, I want to perform data validation during a digital  signature instead of when user presses Submit button.
    Here's my  use-case:
    1. Form Originator fills out a large number of data fields  and signs form via a CAC cert.
    2. Another person will review,  possibly edit/add data, and sign another signature block with CAC.
    3.  Then there is one more final CAC signature on the form before it is  completed and then emailed to the right folks for processing.
    4. I  would like to be able to enforce the population of several Mandatory  data fields (at least one Radio button and one text input, possibly  others) before the 3rd signature can be applied to the document.
    Again, I  need to emphasize this is all happening in an offline form, no data  submission or database back-end. Also, everything with the digital  signatures (and locking up fields afterword) works totally fine, just interested  in adding Data Validation capability during Digital Signature.
    I am in no way a javascript expert, but I can  probably learn from a good example. Any help or guidance is very much appreciated. Thanks...

    If you are using SignatureField in the form then you will get two events preSign and postSign which you can use to validate the field input just like you do with a Submit button.
    Thanks
    Srini

  • Validate element entry at Element Entry Screen and BEE

    Hi,
    I would like to incorporate some validation at both the Element Entry screen and Batch Element Entry.
    The validation rule is user is only allow to enter one element between Element A and Element B, they are mutually exclusive.
    1) When user enter Element A, Element B should not exist in Element Entry screen.
    2) When user enter Element B, Element A shoudl not exist in Element Entry screen.
    The entry point for the element can be done via
    1) loading via BEE screen
    2) entry via Element Entry screen
    Thus, the validation rules should apply at both the entry point.
    I have tried to used the user hook via the pay_element_entry_api, however, it is not working (meaning no validation take place).
    And I also notice that the form PAYWSMEE.fmb is not using the pay_element_entry_api but is using hr_entry_api.
    Appreciate advise on this as this validation is really important to the clietn to ensure correct payment.
    Thanks,
    ShiauChin

    Thanx Sharath for your quick response.
    But I have run QuickPay for that employee.
    After running QuickPay the input values names are coming into element entry value screen.
    But it is not showing the value corresponding to the element input value names.
    Thanks,
    Pankaj Kedia

  • F4 help in ALV grid, how to check the entries?

    Hello,
    I have created F4 help on the cells in a ALV using OO ABAP. The F4 Help works fine and the user can select the entries from it. BUt in F4 help, the user can manually enter values also.
    I want to either disallow the user the enter values manually or validate his entries and ask him to choose from F4 only.
    How to achieve this??

    Use this in Top Include
    class local_event_handler definitin deferred.
    data handler type ref to local_event_handler
    After ALV Grid, register the edit event as shown below after the SET_TABLE_FOR_FIRST_DISPLAY and also set the handler as event handler
    if handler is initial.
      create object handler.
    endif.
    set handler handler->handle_data_changed
                                                    for main_grid. " Main Grid is your ALV Grid
    call method main_grid->register_edit_event
          exporting
            i_event_id = cl_gui_alv_grid=>mc_evt_modified.
    Class Definition / Implementation
    class local_event_handler definition.
      public section.
        methods
            handle_data_changed
               for event data_changed of cl_gui_alv_grid
                 importing er_data_changed.
        methods
           local_event_handler .
    endclass.                    "local_event_handler DEFINITION
    class local_event_handler implementation.
      method local_event_handler.
        " do nothing
      endmethod.                    "llocal_event_handler
      method handle_data_changed.
        read table er_data_changed->mt_mod_cells into ls_mod_cell index 1.
        perform handle_data_changed using er_data_changed.
        " ls_mod_cell-row_id contains the row number that changed. More details in er_data_changed
      endmethod.                    "handle_data_changed
    endclass.                  "handle_btn_click

  • Dynamic ALV columns in Web Dynpro ABAP

    Hello masters:
    Does anybody know how to build an ALV with dynamic columns in a WD4A?
    I know how to make an ALV with a dynamic context node (dynamic DDIC structure), but it isn't the problem. First, I need to validate data entries, and then I will know how many fields I have to show.
    I've been reading about interface IF_WD_CONTEXT_NODE_INFO. I think some of its methods can be useful to me. Can you help me to solve that?
    Thanks.

    Hi Rodrigo,
    There are two ways for it:
    1) Creating an attribute dynamically under the Staticly defined node.
    2) Creating a new node dynamically with your desired columns in it.
    I am explaining the second process, Here it as follows:
    1. Create a WDC, and use the component SALV_WD_TABLE.
    2. Create a node in the context to store the defined strucutre name.
    3. Read the node and set the structure name to that node from which you want to get the columns.
    4. Use this structure name and create a new node dynamically.
    5. Set the data to this dynamically created node.
    6. Set this context node to ALV.
    Here is the sample code:
    To get the strcutre from where you want to fecth the fields.
    tabname_node->get_attribute( Exporting name = 'TABLENAME'
                                  Importing value = tablename ).
    translate tablename to upper case.
    *create sub node named TEST1 of structure (tablename)
    cl_wd_dynamic_tool=>create_nodeinfo_from_struct(
       parent_info = rootnode_info
       node_name = tablename
       structure_name = tablename
       is_multiple = abap_true ).
    DATA: stru_tab type ref to data.
      field-symbols: <tab> type table.*Create Internal Table
    create data stru_tab type table of (tablename).
    assign stru_tab->* to <tab>.*Get table content
    select * from (tablename) into corresponding  fields of table <tab>.*get  instance of new node
    dyn_node = wd_context->get_child_node( name = tablename ).*Bind Internal table to context node.
    dyn_node->bind_table( <tab> ).*instantiate alv component
    data: l_ref_cmp_usage type ref to if_wd_component_usage.l_ref_cmp_usage =   wd_this->wd_cpuse_alv( ).
    if l_ref_cmp_usage->has_active_component( ) is initial.
      l_ref_cmp_usage->create_component( ).
    endif.*pass context node to alv
    data: l_ref_interfacecontroller type ref to iwci_salv_wd_table .
    l_ref_interfacecontroller =   wd_this->wd_cpifc_alv( ).
      l_ref_interfacecontroller->set_data( dyn_node ).
    Hope it helps..
    Good day!
    Regards,
    Shashikanth. D

  • How to restrict f4 help in non editable field in alv.

    Hi Experts,
    I Have one Column in ALV GRID which is non editable,but i have implemented f4 help in that column for new rows to be added.
    so, for already existing rows i want to restrict input through f4 help in that column.
    please help.
    thanks in advance
    surbhi

    Hi,
    Use FM REUSE_ALV_GRID_DISPLAY and implement the I_CALLBACK_USER_COMMAND for this as:-
    I_CALLBACK_USER_COMMAND = 'USER_COMMAND'   "<--in caps
    FORM user_command USING ucomm    LIKE sy-ucomm
                            selfield TYPE slis-selfield.
      CASE ucomm.
        WHEN '<function_code>'.
          "validate the entry done by user here.
      ENDCASE.
    ENDFORM.
    Hope this helps you.
    Regards,
    Tarun

  • How to validate Quantity field in TV - Inputfield ?

    Hello All,
            I'm using a table view to show the output .
    IN this table view I made 2 fields as Input fields.
    Both the fields are Quantity fields.
    Now when the user enters a value in this Quantity field I want to validate it with respect to it's units .
    How can I do that ?
    In my case if the user enters correct value it works but when he enters a wrong value my BSP is going for a dump.
    I tried to debug the<b> LIPS table</b> to verify how SAP was handling this checking for the field <b>LFIMG</b>. But there there is a statement called chain --endchain.
    SO there is no chance for debugging.
    My code is as follows :-
            LOOP AT gt_final INTO wa_final.
              CLEAR: gv_row,lv_qty,lv_string,gv_len,gv_cell_id1.
              gv_row = sy-tabix.
              gv_len = STRLEN( gv_row ).
              gv_len = gv_len - 1.
    * Modify the Third Column
              CONCATENATE 'INB01_TV_ID' '_' gv_row(gv_len) '_' '3' INTO gv_cell_id1 .
              lv_string = request->get_form_field( name = gv_cell_id1 ).
              WRITE lv_string TO lv_qty  UNIT wa_final-units.
              CLEAR :wa_final-del_quantity.
              wa_final-del_quantity = lv_qty.
              MODIFY gt_final FROM wa_final TRANSPORTING del_quantity.
            ENDLOOP.
    Can anyone tell me how to validate the entry for the Quantity filed ?
    Regards,
    Deepu.K
    I have one more Question .
    Whenever BSP goes for a dump in this case I want to handle this by a message .
    Is it possible ?
    Message was edited by:
            deepu k

    Hello Raja,
           I want to validate the entry in the QUantity field with respect to the Unit of the Quantity.
    I.e say for example I have a unit as PC (pieces) then the quantity must be only of thousands,lakks and so..on......but not in points i.e a piece quantity must be full either 200 ,2 lakhs or 2 pieces but not 2.5 pieces.
    SO now if the user enters 2.5 it's a wrong value as the quantity for the Unit PIECES can't have half-piece. (2.5 = 2 + 0.5) .SO i want to validate this .
    I hope I'm clear.
    How should I do ?
    Regards,
    Deepu.k

  • How to suppress 'spurious' update events where the entry is identical

    We often have clusters with event listeners on reference data caches. These caches are refreshed by calling putAll() to update values efficiently. Although this is efficient, and keeps refresh code simple, many unwanted 'spurious' update events are generated. Spurious in the sense that in most of update events the old and new values are the same.
    We considered using a MapTrigger to suppress these uninteresting update events. The problem is how to implement a 'veto' in the MapTrigger.process method. What we'd like to do from a trigger is:
    if (old value == new value)
      ignore new entry
    else
      process, enrich, or validate new entry as desired...
    end ifWe'd like a clean way to signal from a MapTrigger that an entry should be ignored (rather than rejected). The Javadoc shows two possibilities:
    *(1)* undo the pending change by resetting the entry value to the original value obtained from MapTrigger.Entry.getOriginalValue();
    *(2)* reject the pending change by throwing a RuntimeException, which will prevent any changes from being committed, and will result in the exception being thrown from the operation that attempted to modify the map
    Of these *(2)* Causes a put() failure in the client. That is appropriate for something like a validation failure, but not for simply ignoring an unwanted update. Option *(1)* unfortunately generates an update event!
    Our current workaround is a MapEventTransformer to suppress the spurious updates:
    public class UpdateSupressionTransformer implements MapEventTransformer {     
      /** Avoid sending an update event if the value is unchanged */
      public MapEvent transform(MapEvent e) {
        if (e.getId() == MapEvent.ENTRY_UPDATED) {
          if (e.getNewValue().equals(e.getOldValue())) {
            return null;
        return e;
    }This works well but requires client code to register event listeners correctly. It also means that the unecessary change is still generated in the cache. For example a cache stores will be called needlessly.
    Can a feature be considered to allow a clean way for identical updates to be ignored, or to not generate events?
    Ideally this would be before the update is made - like a trigger. It seems a pity the MapTrigger design does not allow this.
    Such a feature would allow simple cache refresh logic using putAll() - without having to check for deltas - avoiding large numbers of unwanted update events. We think this is likely to be a common requirement.
    Cheers,
    phil

    Hi,
    I dont think that this is the problem associated with portal.You are working on BI queries in portal but BI screen that you are working on is of SAP R/3 correct me is i am wrong??And the message you are getting is of R/3 screen,BI screens are shown in an iview and an iview cant show any message..
    Regards,
    Ameya

  • How to validate the field when i am populating the data cursor to block

    Hi,
    I am populating data cursor to multi record block.
    Block contain 5 items. I am populating data cursor to block for 4 items. User will enter one item value that is quantity field.
    If user enter negative values and decimal points in quantity filed i need to display message to user item level.
    Please do the needful how to do it.

    902434 wrote:
    Hi,
    I am populating data cursor to multi record block.
    Block contain 5 items. I am populating data cursor to block for 4 items. User will enter one item value that is quantity field.
    If user enter negative values and decimal points in quantity filed i need to display message to user item level.
    Please do the needful how to do it.If you want to validate at entry level then use When-Validate-Item trigger and check the input and show message. Like
    If :quentity <0 then
    message('do not enter negative value');
    message('do not enter negative value');
    raise form_trigger_failure;
    end if;Why u open same thread again ? not closing one.. check this one
    </a>
    How to validate the field when i am populating the data cursor to block
    Hopes this helps
    If someone's response is helpful or correct, please mark it accordingly.

Maybe you are looking for