Validating Input field in Web Dynpro

Hi All,
Could you please tell me how do I use set_attribute and get_attribute methods to get the user input from the dynpro screen?
The user enters some data in the input field. I need to get this data and validate it.
Please tell me how to get the user input.
Thanks & Regards,
Srilakshmi B

hi,
you can go through it,might be your problem solve.
Example for Using Messages
The following example shows how you can use messages created in the Message Editor. In the example, both messages with static text and messages that are dependent on user inputs – that is, messages with dynamic text – are defined.
Description of Example
Users can create a domain in this sample application. They can then enter a number in the next input field and press Click here to validate. If the specified number lies in the previously specified range, the user is informed of this fact in a standard message. If the number does not lie within this domain, the user sees a warning message.
Prerequisites
You have created a Web Dynpro application and defined view “MainView” within a Web Dynpro component.
Procedure
Creating the View
Define the view as illustrated below:
Context Creation:
The context that provides the data is created as follows:
       1.      Create a context node, UIElem
       2.      Set the propertycardinality to 1..1 for the context node.
       3.      Create the context attributes a, b, and TypeField.
       4.      Set the Type of the context attributes to Integer.
Data Binding
To make the messages dynamic with regard to specification of the domain, the user inputs have to be saved. To do this, the input fields have to be bound to the context.
sss
Object
Object ID
Data Binding to Attribute
Path Within the Context Structure
a
Input Field
A
  MainView.UIElem.a
b
Input Field
B
  MainView.UIElem.b
Children_2
Input Field
TypeField
  MainView.UIElem.TypField
In addition, bind the Children_3 pushbutton to action ValidateAction, which you also have to create.
Creating Messages in the Message Pool
The Web Dynpro tools provide a special message editor for defining messages of different types. 
A message is defined by a specified key, message type, and message text. The message types  error,  warning, and  standard are predefined.
Create the following messages:
Messages Defined in the Message Editor
Message Key
Message Type
Message text
key1
warning
Please enter a number between the range of and !
  and are placeholders for the user input (the domain), which changes dynamically.
key2
standard
The value entered is within the valid range.
Implementation
Because the messages are only displayed when the user Chooses Click here to validate, the messages must be implemented in the method onActionValidateAction:
Implementierung der Methode onActionValidateAction()
//@@begin imports
import com.sap.tc.webdynpro.progmodel.controller.MessageManager;
import com.sap.test.errorhandlingtest1.wdp.IMessageErrorhandlingTest1;
import com.sap.test.errorhandlingtest1.wdp.IPrivateMainView;
//@@end
public void onActionValidateAction(
                       com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent)
    //@@begin
   int i = wdContext.currentUIElemElement().getTypField();
   int a = wdContext.currentUIElemElement().getA();
   int b = wdContext.currentUIElemElement().getB();
   MessageManager msgMgr =
         (MessageManager)wdThis.wdGetAPI().getComponent().getMessageManager();
   if (a < i && i < b)
         msgMgr.reportMessage(IMessageErrorhandlingTest1.KEY2, null, true);
   else
         Object[] arg ={new Integer(a), new Integer(b)};
         msgMgr.reportMessage(IMessageErrorhandlingTest1.KEY1, arg, true);
    //@@end
The following tasks have been implemented in this method:
       1.      Read user inputs:
int I = wdContext.currentUIElemElement().getTypField();
int a = wdContext.currentUIElemElement().getA();
int b = wdContext.currentUIElemElement().getB();
1.       Read messages from the Message Manager:
MessageManager msgMgr =
             (MessageManager) wdThis.wdGetAPI().getComponent().getMessageManager();
2.       Does the input lie within the defined domain?
if (a < i && I < b)
3.       Call the  standard message when the input lies within the domain:
MsgMgr.reportMessage(IMessageErrorhandlingTest1.KEY2, null);
Method reportMessage can be used to read the messages from the Message Manager. In this way you define the key and the objects that you want to change dynamically in the messages. Because no dynamic text was defined in your standard messages, you define null as a parameter.
4.       Call the  warning messages when the input does not lie within the domain:
Object[] arg ={new Integer(a), new Integer(b)};
MsgMgr.reportMessage(IMessageErrorhandlingTest1.KEY1, arg);
Because the warning messages ( Please enter a number between the range of  and !) contain text that depends on the user input, you also have to define the parameters for the domain in an object array. In the messages, the first object is then called from the array with (and the second with , and so on).
Result
After you have built and deployed your application, you can call it by choosing Run.
If the user enters a number that lies within the defined domain, a standard message is displayed:
If the user enters a number that does not lie within the defined domain, a warning message is displayed:

Similar Messages

  • Input field in Web Dynpro ALV does not have correct focus

    Hello Friends,
    Our client's SAP system is recently upgraded with ECC 6.0 SP 18.
    After that the focus in the editable field of Web Dynpro ALV does not working properly by down arrow navigation.
    The common scenario:
    The ALV has more than one rows and one column is editable...
    when user is selecting field of first row and making some entries...
    after that pressing down arrow it is going to next row and coloring the field like focusing...
    but the 'cursor' is not blinking so user can not make entry without clicking by mouse...
    this was working Ok before upgrade...
    Could you please anyone have a look and propose a suitable solution?
    Thanks
    Krish

    Hello,
    The problem was with Javascript....which play an important role in layout of web dynpro ALV...
    which resides in MIME repository -> SAP ->PUBLIC - >BC ->NW5 ->JS ->SAPURI_Ie6....
    We wrote to SAP for giving us the fix...
    after we got a new file from SAP the problem is solved...
    also we have to clear server cache through SMICM and client cache...
    Thanks.
    K.

  • Adding a field in Web dynpro java in Travel Request application

    Hi All,
    How to add a field in Web dynpro java in Travel Request application or can we copy the Web dynpro java application to Web dynpro ABAP and add a field. Experts, Can you please suggest me step by step in resolving the problem.
    Thanks & Regards,
    Kumar

    Hi Kumar,
    First, in order to customise the ESS webdynpro Java iViews you need to be aware that, you are about to change the SAP standard iviews. In order to avoid this you can make a copy of the SAP standard one's and then try to customise the copied one's.
    Now, you should have NetWeaver Development Infrastructure(NWDI) installed. Once it is installed you should also install the Netweaver Developer Studio (NWDS) on your computer.
    Once you have these two installed, you should deploy the ESS Business Package onto the NWDI by creating tracks. There is a cookbook available on SAP Service Marketplace for configuring NWDI for ESS.
    Once you have all the above mentioned tools, have a look at the following blog which clearly explains about the procedure of customising ESS iviews.
    /people/vinoth.murugaiyan/blog/2007/08/24/essmss-customization-150-make-it-simple
    Also check the following Wiki, this might be useful!
    https://www.sdn.sap.com/irj/scn/wiki?path=/display/erphcm/employee%252bself%252bservice
    I hope this helps. Let me know if you have any issues.
    Dont forgett to contribute points if this is useful! All the Best.
    Regards,
    PG

  • Clear/refresh(F5) fields in web dynpro application view

    How to clear or refresh(F5) fields in web dynpro application abap while redirecting to another view? I have tried using "context_node->invalidate()" but it's not working for all the fields, some are getting initialised and some not. Is there any other method to refresh all the fields in the view all at once. Please guide.

    Hi,
    For the Context node( to which the drop down is bound) create a supply function as shown below:
    Now populate the drop down in supply function method instead of WDDOINIT method.
    Go to methods tab and write the below code in supply function method:
    DATA lo_nd_drop TYPE REF TO if_wd_context_node.
        DATA lt_drop TYPE wd_this->elements_drop.
        DATA ls_drop TYPE wd_this->element_drop.
    *Fill Drop down
        ls_drop-val = 'ABC'.
        APPEND ls_drop to lt_drop.
        ls_drop-val = 'DEF'.
        APPEND ls_drop to lt_drop.
    * bind all the elements
       node->bind_table(
         new_items            =  lt_drop
         set_initial_elements = abap_true ).
    Now once you call invalidate( ) the drop down will automatically be initialized( since the supply function will be called again) And you don't have to write the code again to populate the drop down.
    hope it's clear now.
    Regards,
    Kiran

  • Custom seach help for standard field in Web dynpro application

    Hi All,
    I have a requirement in SRM portal where in I have a to add a custom search help to the 'WBS_ELEMENT' field in the the 'ACCOUNT ASSIGNMENT' tab of the Shopping cart creation screen with some input parameters on the search help.
    As the SRM Shopping cartcreation screen is a standard web dynpro application.
    Can anyone help me in this regard for addition of search help for a field with some custom fields in the Search help screen.
    Any inputs will be very helpful.
    Thanks in advance.
    Regards,
    Ahmed.

    Hi Ahmed,
    If it is an standard application then you will have to do ENHANCEMENT in the component. And for using customised value help you will have to declare attribute in CONTEXT and dynamically change the binding of the Value property of UI element inside post-method of WDDOMODIFY. You can create your own customised value help for newly added attribute.
    Thanks,
    Vishesh

  • How to mapped Gray out field in web dynpro for ABAP.

    Hi,
    While preparing a WD Application i m using a RFC,which has one input parameter as MODE.
    IF MODE = 'DIS' (DIS stands for Display) then all fields of layout in web dynpro should be gray out.
    and
    IF MODE = 'MOD' (MOD stands for Modification) then all fields of layout in web dynpro should be opened of entering the data.
    Can anyone help me to solved this scenario.
    Regards,
    <b>Seema</b>

    Hi Seema
    I had the same issue a while ago.  I ended up with an assistance class with  set/get read only methods.  I then used the following type code to set the read only property in the WDDOMODIFYVIEW:
    DATA: lr_start_date TYPE REF TO cl_wd_input_field,
            lr_end_date TYPE REF TO cl_wd_input_field,
            lr_pernr TYPE REF TO cl_wd_input_field,
            lv_read_only TYPE abap_bool.
    lr_start_date ?= view->get_element( 'INP_START_DATE' ).
      lr_end_date ?= view->get_element( 'INP_END_DATE' ).
      lr_pernr ?= view->get_element( 'INP_PERSON' ).
    lv_read_only = wd_assist->get_read_only( ).
      IF lv_read_only = abap_true.
        lr_end_date->set_read_only( abap_true ).
        lr_start_date->set_read_only( abap_true ).
        lr_pernr->set_read_only( abap_true ).
      ELSE.
        lr_end_date->set_read_only( abap_false ).
        lr_start_date->set_read_only( abap_false ).
        lr_pernr->set_read_only( abap_false ).
      ENDIF.
    All my business logic is within my assistance class so it makes it easier to maintain. 
    Regards
    Ian

  • Srm 7.0 - Hide field in web dynpro using configurations

    Hello to all,
    I'm trying to hide some fields on PO web dynpro. In this example on web dynpro /SAPSRM/WDC_DODC_PO_I_BD I start the component configuration /SAPSRM/WDCC_DODC_PO_I_BD, I search for the fields I want to hide and put the visibility attribute to Invisible and I mark final check box.
    The fields don't dessapear from the web dynpro. Am I missing something?
    Best regards,
    Nacho

    Thanks for your reply.
    I have here two situations:
    SPRO. If I add the field on Configure Field Control at Header Level/Item Level it disapears but not all fields appear on this transaction. For example, I can't do that to tolerance group (TOL_GP)
    Webdynpro. Using Component Configuration of the dynpro. I guess that it is in two actions:
       - Change the value of visibility to Invisible on Web dynpro Built-In
       - Add field to context. I put for this example:
             Attributes of the Element usagesDefinition (ITEM_TOL.TOL_GP)
                     usageName ITEM_TOL.TOL_GP
                     componentName ITEM_TOL.TOL_GP
                     ConfigurationName /SAPSRM/WDCC_DODC_PO_I_BD
    The webdynpro way doesn't work, Am I missing something?
    Best regards,
    Nacho

  • Error Input table in web dynpro java

    Hi expert
    I'm trying to create a service order via web dynpro java, but i can't use the input parameter of type table;
    With this implementation of the method init of the custom controller ,on the table i can insert only an element, because the table have only a row.    wdContext.nodeIt_Input_Items().size() = 1
      public void wdDoInit()
        //@@begin wdDoInit()
         Crm_Wap_Order_Create_Input input = new Crm_Wap_Order_Create_Input();
              wdContext.nodeNode_custom_controller().bind(input);
         Crm_Wap_Input_Items table = new Crm_Wap_Input_Items();
                   wdContext.nodeIt_Input_Items().bind(table); 
              input.setIv_Bp(input.getIv_Bp());
                   input.setIv_Currency(input.getIv_Currency());
                   input.setIv_Description(input.getIv_Description());
                   input.setIv_Offline_Luid_Order(input.getIv_Offline_Luid_Order());
                   input.setIv_Ord_Delivery_Date(input.getIv_Ord_Delivery_Date());
                   input.setIv_Order_Guid(input.getIv_Order_Guid());
                   input.setIv_Pers_Resp(input.getIv_Pers_Resp());
                   input.setIv_Po_Number_Sold(input.getIv_Po_Number_Sold());
                   input.setIv_Proc(input.getIv_Proc());
                   input.setIv_Save(input.getIv_Save());
                   input.setIv_Selected_Prod(input.getIv_Selected_Prod());
                   input.setIv_Ship_To(input.getIv_Ship_To());
              for(int i=0;i<wdContext.nodeIt_Input_Items().size(); i++) {
                   table.setOrder_Qty(wdContext.nodeIt_Input_Items().getIt_Input_ItemsElementAt(i).getOrder_Qty());
                   table.setProd(wdContext.nodeIt_Input_Items().getIt_Input_ItemsElementAt(i).getProd());
                   table.setDelivery_Date(wdContext.nodeIt_Input_Items().getIt_Input_ItemsElementAt(i).getDelivery_Date());
                   table.setSequence(wdContext.nodeIt_Input_Items().getIt_Input_ItemsElementAt(i).getSequence());
                   table.setUom(wdContext.nodeIt_Input_Items().getIt_Input_ItemsElementAt(i).getUom());
                   table.setLine_Guid(wdContext.nodeIt_Input_Items().getIt_Input_ItemsElementAt(i).getLine_Guid());
                   if(wdContext.nodeIt_Input_Items().getIt_Input_ItemsElementAt(i).getProd()!= null)
                    input.addIt_Input_Items(table);
        //@@end
    I've tried, with a button, to insert more row, and i do that, but the additionals rows are not passed to the function, but only the row created with the method wdDoInit();
    How can i bind the additional row at the context??
    Somebody know a tutorial for create an order via web dynpro java??
    Please Help me
    Best regards
    Marco

    hi Bhargava
    sorry for the late..
    no in the init method i do the binding of the parametere, because if i'dont it in the init mothod the parameters are not editable..
    Link:[http://img29.imageshack.us/i/56a7250185252a1d06af141.png/]
    in me button metho i execute the BAPI....
      public void wdDoInit()
        //@@begin wdDoInit()
         Crm_Wap_Order_Create_Input input = new Crm_Wap_Order_Create_Input();
        wdContext.nodeNode_custom_controller().bind(input);
             //input.setIt_Input_Items(new AbstractList());
         Crm_Wap_Input_Items table = new Crm_Wap_Input_Items();
         wdContext.nodeIt_Input_Items().bind(table); 
              input.setIv_Bp(input.getIv_Bp());
                   input.setIv_Currency(input.getIv_Currency());
                   input.setIv_Description(input.getIv_Description());
                   input.setIv_Offline_Luid_Order(input.getIv_Offline_Luid_Order());
                   input.setIv_Ord_Delivery_Date(input.getIv_Ord_Delivery_Date());
                   input.setIv_Order_Guid(input.getIv_Order_Guid());
                   input.setIv_Pers_Resp(input.getIv_Pers_Resp());
                   input.setIv_Po_Number_Sold(input.getIv_Po_Number_Sold());
                   input.setIv_Proc(input.getIv_Proc());
                   input.setIv_Save(input.getIv_Save());
                   input.setIv_Selected_Prod(input.getIv_Selected_Prod());
                   input.setIv_Ship_To(input.getIv_Ship_To());
              for(int i=0;i<wdContext.nodeIt_Input_Items().size(); i++) {               
                   //wdContext.nodeIt_Input_Items().ge
                   table.setOrder_Qty(wdContext.nodeIt_Input_Items().getIt_Input_ItemsElementAt(i).getOrder_Qty());
                   table.setProd(wdContext.nodeIt_Input_Items().getIt_Input_ItemsElementAt(i).getProd());
                   table.setDelivery_Date(wdContext.nodeIt_Input_Items().getIt_Input_ItemsElementAt(i).getDelivery_Date());
                   table.setSequence(wdContext.nodeIt_Input_Items().getIt_Input_ItemsElementAt(i).getSequence());
                   table.setUom(wdContext.nodeIt_Input_Items().getIt_Input_ItemsElementAt(i).getUom());
                   table.setLine_Guid(wdContext.nodeIt_Input_Items().getIt_Input_ItemsElementAt(i).getLine_Guid());
                   input.addIt_Input_Items(table);
        //@@end
    this is the init...
    in the button method
      public void CreateOrder( )
        //@@begin CreateOrder()
         try
              wdContext.currentNode_custom_controllerElement().modelObject().execute();
              wdContext.nodeOutput().invalidate();
              catch (Exception ex)
               ex.printStackTrace();
        //@@end

  • Getting Data from Input Structure (in Web Dynpro)

    Hi All,
    in my Web Dynpro Application, i have problems to get the data form my Input-Structure. In the execution-method I implement the following code, to show the input parameters in my form (in context-nodes):
    IGPStructure inputStructure = executionContext.getInputStructure;
    node.setSolution((String)inputStructure.getStructure("FRS").getAttribute("Solution"));
    But that doesnt work I, my exception handler throws an exception. Exception.getMessage() returns null, so I cannot show the error-message. What is the problem?
    Hope someone can help me.
    Really thanks
    Bye Steve

    I solved it my own.
    It was an Null-Pointer exception, cause getStructure can also return null, when no structure is added.
    In my code I didnt catch null-structures, result was the error message.
    Right code example:
    IGPStructure inputStructure = executionContext.getInputStructure.getStructure("FRS");
    if(inputStructure != null){
        node.setSolution((String)inputStructure.getAttribute("Solution"));

  • Sum hidden fields in web dynpro ALV reports

    Hi everyone
    Could anyone tell if it is possible to sum a field that is hidden in an ALV Report in Web Dynpro?
    I need to hide a row so as not to be seen by the user (like the filter option) but with the need that the value that is stated in that hidden row must still impact in the Column Total.
    Thanks!
    Fede

    Hi everyone
    Could anyone tell if it is possible to sum a field that is hidden in an ALV Report in Web Dynpro?
    I need to hide a row so as not to be seen by the user (like the filter option) but with the need that the value that is stated in that hidden row must still impact in the Column Total.
    Thanks!
    Fede

  • Adding text field to Web Dynpro

    Hi Experts,
    I need to add new text field on Standard SAP Dynpro for standard field . In standard it has two value : "01" or "02". And I nedd to add near "Material" or "Service" depending on value of  standard field. I checked standard field in F4.
    It's info about field:
    General Information About the Application and Component
    Application: /SAPSRM/WDA_L_FPM_OIF
    Web Dynpro Component: /SAPSRM/WDC_DODC_SC_I_BD
    Window Information: IV_L_FPC_CA_DETAILS
    View Information: V_DODC_SC_I_BD
    Configuration ID: /SAPSRM/WDCC_FPM_DODC_SC_I_BD_PR
    Information on Field
    Field ID: ZZI_PRODUCT_TYPE_ATTR
    Type of UI Element: INPUT_FIELD
    UI Element Library: STANDARD
    But when I go to Component /SAPSRM/WDC_DODC_SC_I_BD I can't found this field. I think this field as dynamic field created.
    Also question: How I can call this field (for example in method modifyview) and add new field on the right side?
    Thanks in Advance.
    Evgeniy

    Hi Evgeny 
    I dint understand your question , I am able to see componet /SAPSRM/WDC_DODC_SC_I_BD and view V_DODC_SC_I_BD .
    you can create enhancement for this view and can add your field here.

  • Input element in web dynpro java not working

    Hi,
    Iam new to webdynpro java. iam trying on external context mapping example from sap help.when i run the application i have assigned a context to a input element that should be accessed  by another other component's window view .when i follow steps given in diagram for external context mapping when i run the application i am not able to enter the data into the input textbox.it became read only.plz suggest me a good example for external context mapping and some times i am not able to enter a value for input field when i assign a context attribute to it.i have assigned a node context to the input element.
    Thanks and regards
    prasad

    Hi Prasad,
    An externally mapped node always exists within the context of a component interface controller and have its isInputElement property set to true.
    External context mapping is possible only for independent nodes of a component interface controller not independent attributes.
    Also, for external context mapping, look at below thread -
    external context mapping
    Regards,
    Sen

  • Validating Input fields in Interactive Adobe Forms with Webdynpro ABAP

    Dear Friends,
    Am new to Interactive Adobe forms with Webdynpro Abap,
    My scenario is, I have few Input fields, i need to handle the Messages when am not entering values in any of the Input Field,
    and raise the message when i click on Save Button.
    I have tried with setting the field as Required in Form itself, but i can't set the Field as Mandatory.
    I don't know how to do, Please give some needed points, as well needed some Script/Formcalc code.
    Thanks,
    Pradeep.

    Hi Pradeep,
    You can validate the fields by using javascript/formcalc logic in onclick event of button.
    Please refer the below links
    Adobe Form -How to make an Input Field Mandatory
    Validate Intercive Adobe Form
    Hope it helps you.
    Regards,
    Rama

  • Data validation for Date Field in Web Dynpro ABAP

    Hi ,
    In my WDA i want to perform data validation for date filed. (i.e. While creating a new record i have to check the Start Date should be always lesser than End Date.)
    If u ll enter the wrong date it should validate the Date and throw an error message.
    Please Reply soon its urgent.
    Thanks,
    Deepika

    Hi,
    First read the two attributes start date and end date.
    Then write the following condition.
    IF item_start_date > item_end_date.
    Error message.
    Endif.
    For pop up error message you need to use Create_window method of the Interface if_wd_window.
    Thanks.

  • Date field in Web Dynpro ABAP

    Hi All,
    I want to implement the Input Date Field on my WebdynPro Application in the same way as it is availble at "SCN - Contribution Points / filter criteria" .
    I want to give the user the option to change the year , past or future easily.
    I have tried to call that date UI Element , but unable to do so.
    Please help me which UI Element to use as am new in WebDynPro ABAP...
    Thanks and Regards
    Hemachandran

    hello,
    One way of doing is  -  declare two attributes(DATE_LOW and DATE HIGH ) in the context node of type DATS.Place two input feilds in the view INPUT1 and INPUT2 , bind the two attributes to the two input feilds.
    The other way is use  OVS ( object value selector ) Search Help.
    Regards,
    Naga

Maybe you are looking for

  • Background report list download to excel

    I run an ALV hierarchical sequential report in background. Then when I download the report output ( thro SM37 ) to excel, the whole output of the report comes in one cell ( excel ). In other words the columns of the report will not appear in excel. f

  • How can i do different colors for the category in business graphics

    Hi everybody, i have a business graphics and i need different colors for the category. my business graphics is a gantt. for example category1 category2 category2 and so on. Is there a solution for this? How can i do it? Best regards, Markus

  • Flash MX Professional 2004 Activation Problems

    I am having trouble activating Flash MX Professional 2004. I have had the product for many years, but it is asking again to be reactivated, probably because I have moved the vmWare virtual machine on which it is installed to a new host computer. I ha

  • Exceptions in a stored procedure

    Hi I am writing a stored procedure and I am running a select statement. On NO_DATA_FOUND exception, I want to raise another exception called NO_EMP_FOUND. Question is where in the stored procedure I have to define this. Remember that the select state

  • I just installed RH 10 and it doesn't work

    Hello, I apologize for my poor english. I used to run RH 6 and it worked very well for the past 6 years. My compagny purchased RH 10 a few days ago. I installed RH 10 and after running a few seconds, it shuts without any message. Just a nice shutdown