Data Validation in web dynpro

Hi,
Can anyone explain how to do data validation for the i/p fields in the WD View???Pleasegive an example with coding.
Thanks!

Hi,
As Thomas pointed out in his reply that do the validation at WDDOBEFOREACTION method
say you have a date to validate:
DATA lo_nd_importing TYPE REF TO if_wd_context_node.
  DATA lo_el_importing TYPE REF TO if_wd_context_element.
  DATA ls_importing TYPE wd_this->element_importing.
  DATA lv_startdate LIKE ls_importing-startdate.
navigate from <CONTEXT> to <IMPORTING> via lead selection
  lo_nd_importing = wd_context->get_child_node( name = wd_this->wdctx_importing ).
get element via lead selection
  lo_el_importing = lo_nd_importing->get_element(  ).
get single attribute
  lo_el_importing->get_attribute(
    EXPORTING
      name =  `STARTDATE`
    IMPORTING
      value = lv_startdate ).
if lv_startdate is initial.
get message manager
DATA lo_api_controller     TYPE REF TO if_wd_controller.
DATA lo_message_manager    TYPE REF TO if_wd_message_manager.
lo_api_controller ?= wd_this->wd_get_api( ).
CALL METHOD lo_api_controller->get_message_manager
  RECEIVING
    message_manager = lo_message_manager
report message
CALL METHOD lo_message_manager->report_error_message
  EXPORTING
    message_text             = 'Please input start date'
   params                   =
   msg_user_data            =
   is_permanent             = ABAP_FALSE
   scope_permanent_msg      = CO_MSG_SCOPE_CONTROLLER
   view                     =
   show_as_popup            =
   controller_permanent_msg =
   msg_index                =
    cancel_navigation        =  'X'    "this parameter will stop the program at the same view
endif.
this will stop the user at the same view and will give the error message out.....
you can also check the code wizard and try different type of methods to give out the error messages....the code wizard is right beside the external break point button...
Thanks...
AS.

Similar Messages

  • How to do date validation in Web Dynpro java

    Hi
    We have one requirement that One input field with date type is there.When we take Date type input field then in web dynpro Date navigater is appearing by default.Our requirement is if user enters the date manually in the input filed instead of chossing the date from the Date navigator then how we will do the following date validations manually:
    a. If user is entering the date in any format then it should convert it to dd.mm.yy format.
    b. How to do leap year validation?Suppose user is entering   29.02.20007 then it should display Invalid date.
    c. How to do the follwing date validation:
        Let's say that current running hours(Text Vie
    w) on a given engine is 100, entered on 10-Jun-2008(Running hour date-Text view)).
    -On 15-Jun-2008(New Running Hour Date-input field), I try to enter a value of 300 hours(New running hour-input field).
    -This is impossible, because only 5x24=120 hrs has passed from the previous update.
    -Hence, in this case the maximum value I can enter is 100+120=220.
    Can anybody help me in solving the above 3 date validation?

    Hi Susmita,
    For your 3 rd requirement...
    Initially you will be storing the first date entered by the user right???
    Say that date is D1. and user entered hours is H1.
    now after some days at day D2 user again trying to enter some hours say H2. Now you have to restrict user from entering hours which are
    greater than 24*D2-D1....
    so now you have to get D2-D1....
    For this....
    long l1=youdate1.getTime();   // This will convert your Date D1 into long...
    then,
    Date d=new Date(System.currentTimeMillis());
    long l2=d.getTime();  //which is a long value of current date...
    So Now l2-l1 will give you number of days between past date and today's date...
    So On Save you check for
    if((l2-l1)*24<(H2-H1))
    message("Please enter valied number of hours");
    Hope this will help you....
    Regards,
    Srinivas.

  • What kind of data types in Web Dynpro can be bound to Interactive Form?

    Hello
    Apparently it is not possible to bind a Web Dynpro Context variable of type boolean to a checkbox in an interactive form. We get the PDF Document Render Exception until the data type is changed to string, then the generation seems to work. Does anyone know what data types in Web Dynpro other than String can be bound to an Interactive Form Document? Is there any information about this in help.sap.com/adobeforums.com/elsewhere? I have researched a bit, but couldn't get a general statement on this topic.
    Thank you for your help!
    Kind regards
    Bettina Hepp

    Hi,
    You can Bind the Boolean type of webdynpro to the CheckBox in Adobe Interactive Form.
    Just define the value Attribute in the Context of type Boolean and bind the Checkbox in Aif with this attribute.
    Sample Code:
    if (wdContext.currentContextelement.reason == true)
    ur validations.....
    Regards
    Mustafa

  • How can I set the data binding between Web Dynpro & Database table

    Dear friend,
    I am a beginner of Web Dynpro. I want to develop my simple project like these:
    1. Create my own database table via Dictionary Project such as TAB_USER and have 3 fields: USER_ID, USER_NAME, USER_POSITION and I have already deployed & archived it.
    2. Create my own Web Dynpro Project, and create the input fields as User ID, User name, User position and icon 'Save' on the selection screen and I have deployed it already.
    For the process, I want to input data at the screen and save the data in the table, please give me the guide line like these:
    1. How can I set the data binding between Web Dynpro and Database table ?
    2.  Are there any nescessary steps that I will concern for this case?
    Sorry if my question is simple, I had try  to find solution myself, but it not found
    Thanks in advances,
    SeMs

    Hi,
    You can write your own connection class for establishing the connection with DB.
    Ex:
    public class  ConnectionClass {
    static Connection con = null;
    public static Connection getConnection() {
    try{
    Context ctx = new InitialContext();
    DataSource ds = (DataSource) ctx.lookup("jdbc/TSPAGE");
    con = ds.getConnection();
    return con;
    }catch(Exception e){
    return null;
    You can place the above class file in src folder and you can use this class in webdynpro.
    You can have another UserInfo class for reading and writing the data into the DB .
    Regards, Anilkumar
    PS : Refer
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/java/simple java bean generator for database.pdf
    Message was edited by: Anilkumar Vippagunta

  • How to get the ep user information data in the web dynpro?

    Hi all
      I want to create a web dynpro application on EP.I want to get the ep user information data in the web dynpro.How can I do?Thanks.

    Lin,
    Two steps to achieve this:-
    <b>Step 1:</b> Add the following code in your view Controller:-
    IWDClientUser user = WDClientUser.getCurrentUser();
    IUser objUser = user.getSAPUser();
    wdContext.currentContextElement().setXXXX(objUser.getUniqueName());
    wdContext.currentContextElement().setYYYY(objUser.getFirstName());
    wdContext.currentContextElement().setZZZZ(objUser.getLastName());
    where XXXX, YYYY , ZZZZ are the context names.
    getUniqueName : Gives Login id of Portal user.
    getFirstName : Gives First Name of the Portal user.
    getLastname : Gives Last Name of the Portal user.
    <b>Step 2 : </b>Use "Organize imports" and make sure that you have the following two libraries added in the build path of your project. You can do these by right clicking on your project name ==> Properties ==> Java Build Path ==> Libraries ==> Add External jars.
    The external jars are :
    <b>com.sap.security.api.jar
    com.sap.security.api.perm.jar</b>
    Finally rebuild your project and deploy.
    Regards,
    <b>Chintan Virani.</b>

  • Range validations in web dynpro

    Hi experts,
    can you please tell me How to perform Range validations in web dynpro applications ?
    Advance Thanks,
    Namrata.

    Hi Namrata,
    Create a Simple Type (Local Dictonary -> DataTypes -> SimpleTypes). Enter either Length constraints / value constraints in the simple type. Bind this simple type to the context attribute. Whenever you are performing an action framework generated error message will be displayed based on the constraints you designed in simple type.
    Thanks
    Madhu

  • Client side validations in web dynpro

    Hi experts,
    can anybody tell me How we perform client side validations in web dynpro ?
    Thanks,
    Prasad.

    Hi Prasad,
    Validations are generally required during some events or calls to a functions. So there are bascially two ways:
    1) You do the validation is the onActionEvent of the UI element. However this is some time time is not a right approach (depends upon your scenario).
    2) There is another method called wdDoBeforeAction(). Do all you validations for the actions in this method. read the java doc for the same functions, here:
       * Hook method called for additional validation of user input. <p>
       * @param validation Interface for reporting validation errors
    You can catch the particualr action in this emthod and then can write you validation code before the action is called.
    For gettiong the action use this code:
    if(validation.getCurrentAction().equals(IPrivate<Your_View_Name>.WDActionEventHandler.<ACTION_NAME>)){
    // write your validation code here.           
    I hope this will help you. Please revert back in case you have further issues.
    Thanks and Regards,
    Pravesh

  • 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.

  • How to do the feild validations in web dynpro abap

    dear all,
    how to do the feild validations for the screen in web dynpro abap.
    thanks,
    jyothi.

    hi jyothi,
    There are diffrent ways of doing validations for fields of screen in webdynpro abap depending on the requirements.
    I am giving simplest way of doing this validation(it may fullfil your requirement also)
    For e.g you want that without entering value in particular field user should not proceed to submit the data in screen.
      DATA lo_message_manager    TYPE REF TO if_wd_message_manager.
      DATA lo_api_controller     TYPE REF TO if_wd_controller.
      lo_api_controller ?= wd_this->wd_get_api( ).
      lo_message_manager = lo_api_controller->get_message_manager( ).
      DATA var1 type string.
      DATA: node TYPE REF TO if_wd_context_node.
      node = wd_context->get_child_node( 'DATA' ).
      node->get_attribute( EXPORTING name = ' VALUE'
                             IMPORTING value =     var1 ).
    IF var1  IS INITIAL.
        CALL METHOD lo_message_manager->report_error_message
          EXPORTING
            message_text = 'Please enter the value'.
          EXIT.
      ENDIF.
    Now in above code VALUE is the attribute with whome your input field is bound .So if user doesnt enter any value into it he will get above msg (u have to use message are ui element to use this method)
    If you have any other doubt feel free to ask.
    regards
    Panky

  • Exchanging data between a Web Dynpro application and SAP Web Shop

    I'll try to keep this as clear as possible:
    1) We have the SAP Internet Sales system running, which has a series of Business Object classes and corresponding Backend Layer objects that can return data from several sources.
    2) We are able to create our own Backend Layer objects that would return data from a component called IPC, which is a Java component.
    3) I would like a Web Dynpro application to retrieve data from this backend layer object, but I am not experienced enough with Java to know if what I want to do is possible. I don't think that I can use JCo, because I am trying to get a Java component (class?) in Web Dynpro to access a Java class remotely.
    4) I think I am asking is this: is there a way for a Java to Java connection to be created, much like Web Dynpro can use JCo to connect Java to ABAP systems?
    If this is a glaringly obvious question to Java programmers, my apologies!
    - Tony.

    Somebody on another forum recommended using RMI. Which would be the better option in terms of ease of implementation?
    - Tony

  • Updated data in a web dynpro application

    hi
    when we develop a web dynpro application using a model from an  R/3 as a backend access system , how is the data updated in the application, in the portal whenever there is a change in the source OLTP data tha we used?
    thanks in advance
    krishna chaitanya

    Hi,
    Do you want to change the message server name thriugh coding then use the below code.
    Store the message server name in a customizing table.
    use the below code to replace the MS name:
    DATA    lv_temp_str TYPE char255.
      DATA    lv_split1 TYPE char255.
      DATA    lv_split2 TYPE char255.
    DATA :  lv_string TYPE string,
              lv_application TYPE string.
    DATA    lv_dns_str TYPE /mrss/t_rm_dns_str.
    CALL METHOD cl_wd_utilities=>construct_wd_url
        EXPORTING
          application_name = lv_application " webdynpro application name
        IMPORTING
          out_absolute_url = lv_string."url of the application.
    lv_dns_str = message server name form the customizing table
    lv_temp_str = lv_string.
      SPLIT lv_temp_str AT '//' INTO lv_split1 lv_split2.
      CLEAR lv_split1.
      lv_temp_str = lv_split2.
      SPLIT lv_temp_str AT '.' INTO lv_split1 lv_split2.
      lv_temp_str = lv_split1.
      REPLACE lv_temp_str IN lv_string WITH lv_dns_str.
    Regards,
    MAdhu

  • Data access in web dynpro

    Hi all,
    I'm new to web dynpro, i ve to develop web dynpro appliation which has to interact to oracle database(read/write). For example, if i give certain search criteria the application should display matched data in table format. I dont know how to start & where to start. Please help me out.
    thnx regards
    ilan

    Hi
    You can use the Table UIElement for this
    1.Create a node with cardinality 0..n
    2.Create attributes with the same type of database.
    3.Bind the node attributes with the database values
    4.bind the node to the Table UI Element
    See this thread
    Re: problem with displaying records from the database in a table ui element
    See this sample application and help
    https://www.sdn.sap.com/irj/sdn/downloaditem?rid=/library/uuid/f0b0e990-0201-0010-cc96-d7ecd2e51715
    Kind Regards
    Mukesh

  • Data storage in web dynpro

    Hey people!
    Im pretty new in web dynpro, and i want to store the data i input in the inputfields somewhere.. either in a database (oracle) or xml file.. someone got any tips? and if i choose to go for oracle, do i have to create an EJB as well? or could i just write the connections and queries in the views?

    I think that suggested way is to use SQLJ in a EJB and then use that EJB in your web dynpro project.
    Check out this thread.
    Accessing Dictionary devlopment component in Web dynpro component
    Regards,
    Rich Heilman

  • Logical data base in Web dynpro

    Hi all,
    I want to add LDB (PNP) into my web dynpro program.by which i can get the data from database to the Application server.After Authrization check.
    I also want to use Infotypes 0082 in my program.
    Points will be sured.
    Thanks.

    use hr_infotype_operation to insert,update,delete

  • Validations in Web Dynpro Java

    Hello,
    I'm trying to create a lot of validations in a web dynpro App.
    Examples:
      - An inputfield must not pass 6 characters of length. (I can set the inputfield length of 6 characters but I can't force the inputfield to accept only 6 characters).
    - Some fields (inputfield, textEdit, dropdownByKey) are mandatory. (I can see the property state = "required" but I don't know how it works)
    - Some field are mandatory depending in a previous selection.
    I'm finding that adding this validation logic to the form is very heavy and implies a lot of work. I want to ask if someone knows an easy and automatically way to add this validation logic to the app, or I can't escape of programing everything.
    Please help.
    Regards
    SU

    Hi SU,
    I wrote the following code just to check if this method works or not. Well, this method does work.
    Ceate a message in the message pool and use the following code
    IWDNode node = null;
    wdControllerAPI.checkAndReportRequiredFields(node ,IMessageNew1Comp.VALIDATION__MESSAGE, new Object[]{"test"});
    " in my case the attribute bound to the input - whose state is required - is in root container.
    "That's why I am passing null as first parameter.
    Validation_Message is the message key
    "test" is the message which you could pass to the passholder
    I hope it helps.
    Edited by: Arjun Singh Thakur on Dec 9, 2011 11:32 AM

Maybe you are looking for

  • Deleting photo's that were imported to my iphone from a computer I can no longer access

    I have not got my mac that I had used to import a photo album to my iphone. I am now using a different computer, and when I plug phone in to do the usual de-selecting of photo's I wish to change that option is not available. My memory is full and del

  • Wireless has stopped working on my Apple TV. What can I do with it?

    All of a sudden my 20 month old Apple Tv stopped working with Wireless. Doesn't see the network at all. Tried restting but no luck.  I can either try and convince Apple to replace this (unlikley even with the UK's consumer protection legislation) or

  • PO Release Status

    How can we check the release status of Purchase Orders - pending release at different levels Regards, Param

  • Error in export

    Subject: exp query=\"where to_char\(DATE_FIELD\,\'MMYYYY\'\)=\'032006\'\" RDBMS Version: 9.2.0.7 Operating System and Version: AIX 5 Error Number (if applicable): LRM-00101 Product (i.e. SQL*Loader, Import, etc.): export Product Version: 9.2.0.7 exp

  • How many states are too much?

    Hi, Is 20 to 35 states in an application considered too many?  Each state will reveal a different interactive dialogue box with two clickable icons. Thanks.