How to compare value in input field to value in database?

Hi all. I need to clear up if the value in the input field (e.g. input_field) is equal to at least one record in the field (e.g. name) in database table (e.g. customers), or not. The code should be like this:
IF...
  message001.  "(there's such a record in database)
ELSEIF...
  message002.  "(there's no such record in database)
ENDIF.
thanks all.

Hi,
I think u r asking about validating the selction screen and displaying a mess if that input is not in the DB right?
AT SELECTION-SCREEN ON s_matnr.
*Validate material no details
  PERFORM validate_matno.
FORM validate_matno.
  SELECT SINGLE matnr INTO v_matnr
         FROM mara
         WHERE matnr IN s_matnr.
  IF sy-subrc NE 0.
    MESSAGE i128.
    LEAVE LIST-PROCESSING.
  ENDIF.
ENDFORM.
Make sure that u are validating against the header table.
say eg if u wnat t validate matnr in marc, then do as below.
SELECT-OPTIONS: s_matnr FOR  marc-matnr.                  "Material No
AT SELECTION-SCREEN ON s_matnr.
*Validate material no details
  PERFORM validate_matno.
FORM validate_matno.
DATA: v_matnr LIEK mara-matnr.
  SELECT SINGLE matnr INTO v_matnr
         FROM <b>mara</b>
         WHERE matnr IN s_matnr.
  IF sy-subrc NE 0.
    MESSAGE i128.
    LEAVE LIST-PROCESSING.
  ENDIF.
ENDFORM.
Dont select from marc.
Hope this is clear.

Similar Messages

  • How to enable/disable the input fields based on the data entered/user action in the web dynpro abap?

    How to enable/disable the input fields based on the data entered in the web dynpro application abap?  If the user enters data in one input field then only the next input field should be enabled else it should be in disabled state. Please guide.

    Hi,
    Try this code.
    First create a attribute with the name readonly of type wdy_boolean and bind it read_only property of input field of which is you want to enable or disable.
    Next go to Init method.
    Set the readonly value as 'X'.
    DATA lo_el_context TYPE REF TO if_wd_context_element.
         DATA ls_context TYPE wd_this->element_context.
         DATA lv_visible TYPE wd_this->element_context-visible.
    *   get element via lead selection
         lo_el_context = wd_context->get_element( ).
    *   @TODO handle not set lead selection
         IF lo_el_context IS INITIAL.
         ENDIF.
    *   @TODO fill attribute
    *   lv_visible = 1.
    *   set single attribute
         lo_el_context->set_attribute(
           name =  `READONLY`
           value = 'X').
    After that Go to the Action  ENTER.
    First read the input field ( first input field, which is value entered field) , next give a condition
    if input value is not initial  then set the readonly value is '  '.
    DATA lo_nd_input TYPE REF TO if_wd_context_node.
         DATA lo_el_input TYPE REF TO if_wd_context_element.
         DATA ls_input TYPE wd_this->element_input.
         DATA lv_vbeln TYPE wd_this->element_input-vbeln.
    *   navigate from <CONTEXT> to <INPUT> via lead selection
         lo_nd_input = wd_context->get_child_node( name = wd_this->wdctx_input ).
    *   @TODO handle non existant child
    *   IF lo_nd_input IS INITIAL.
    *   ENDIF.
    *   get element via lead selection
         lo_el_input = lo_nd_input->get_element( ).
    *   @TODO handle not set lead selection
         IF lo_el_input IS INITIAL.
         ENDIF.
    *   get single attribute
         lo_el_input->get_attribute(
           EXPORTING
             name =  `VBELN`
           IMPORTING
             value = lv_vbeln ).
    if lv_vbeln IS not INITIAL.
        DATA lo_el_context TYPE REF TO if_wd_context_element.
        DATA ls_context TYPE wd_this->element_context.
        DATA lv_visible TYPE wd_this->element_context-visible.
    *  get element via lead selection
        lo_el_context = wd_context->get_element( ).
    *  @TODO handle not set lead selection
        IF lo_el_context IS INITIAL.
        ENDIF.
    *  @TODO fill attribute
    *  lv_visible = 1.
    *  set single attribute
        lo_el_context->set_attribute(
          name =  `READONLY`
          value = ' ' ).

  • How can we change the input field on a view stop showing zeros

    Hello,
           To make screen look consistent with other character input field. How can we change the input field on the view stop displaying zeros even though the data type is NUMC and data type should not be change?
    Edited by: sap_learner on Mar 25, 2010 5:44 PM
    Edited by: sap_learner on Mar 25, 2010 5:49 PM
    Edited by: sap_learner on Mar 25, 2010 5:55 PM

    hello Manas Dua,
                           Thanks for your help. I am able to resolve my problem.
    My code will help  the future comers to resolve this kind of issues.
    *The code is applied to method WDDOINIT of the default view.
      DATA lo_nd_terms_input    TYPE REF TO if_wd_context_node.
      DATA lo_nd_terms_input_i TYPE REF TO if_wd_context_node_info.
      DATA lv_zeros             TYPE wdy_attribute_format_prop.
      lv_zeros-null_as_blank = 'X'.
      lo_nd_terms_input = wd_context->get_child_node( name = wd_this->wdctx_input ).
      lo_nd_terms_input_i = lo_nd_terms_input->get_node_info( ).
      lo_nd_terms_input_i->set_attribute_format_props(
        EXPORTING
          name              = `ENTER THE ATTRIBUTE NAME`
          format_properties = lv_zeros     ).
    Edited by: sap_learner on Mar 26, 2010 5:02 PM

  • How to compare values in table control

    Hi Experts,
    How to compare two values of a field in table control. Like the frist row of feld1 with the second row of field1.
    because when ever two values are same i need to display error message that we are entring duplicate entry.
    i have been tring for a very log time but not getting any solution for this.
    Thanks and Regards,
    Ashwin.

    you need to write in code for this..
    A possible solution is given below..
    Suppose your internal table fields are col1 and col2.
    in the loop .....endloop of yout internal table in your PAI..there will be  following(if your table control is made using wizard. otherwise you might have to add it..
    loop at itab.
    chain.
    field col1.
    field col2.
    "some module
    endchain.
    endloop.
    now make changes as shown to the above code..
    loop at itab.
    chain.
    field wa-col1.
    field wa-col2.
    module table_modify on chain-request.
    endchain.
    now in your program add module table modify.
    module table_modify input.
    read table itab with key col1(which shud be unique) = wa-col1 transporting no-fields.
    if sy-subrc = 0. " there exists another record with the same value
    message e001(your message class).
    endif.
    endmodule.
    i guess that shud work. get back if it dosnt.
    regards
    Suzie

  • How to set  Date in input field by hard coding in application

    Hi all,
    1.I have to make a date(its my choice to set the date) to appear in input field which is date type.
    2.How to compare two numbers of type decimal. for example greatest of two numbers
    urgent requirement

    Hi
    Check the http://java.sun.com/j2se/1.4.2/docs/api/java/sql/Date.html
    http://java.sun.com/j2se/1.4.2/docs/api/java/util/Calendar.html
    Sample Code
    Date now = new Date();
          DateFormat df = DateFormat.getDateInstance();
          String s = df.format(now);
          System.out.println("Today is " + s);
    java.sql.Date descends from java.util.Date, but uses only the year, month and day values. There are two methods to create a Date object. The first uses a Calendar object, setting the year, month and day portions to the desired values. The hour, minute, second and millisecond values must be set to zero. At that point, Calendar.getTime().getTime() is invoked to get the java.util.Date milliseconds. That value is then passed to a java.sql.Date constructor:
        Calendar cal = Calendar.getInstance();
        // set Date portion to January 1, 1970
        cal.set( cal.YEAR, 1970 );
        cal.set( cal.MONTH, cal.JANUARY );
        cal.set( cal.DATE, 1 );
        cal.set( cal.HOUR_OF_DAY, 0 );
        cal.set( cal.MINUTE, 0 );
        cal.set( cal.SECOND, 0 );
        cal.set( cal.MILLISECOND, 0 );
        java.sql.Date jsqlD =
           new java.sql.Date( cal.getTime().getTime() );
    The second method is java.sql.Date's valueOf method. valueOf() accepts a String, which must be the date in JDBC time escape format - "yyyy-mm-dd". For example,
        java.sql.Date jsqlD = java.sql.Date.valueOf( "2010-01-31" );
    creates a Date object representing January 31, 2010. To use this method with a Calendar object, use:
        java.sql.Date jsqlD = java.sql.Date.valueOf(
                cal.get(cal.YEAR) + ":" +
                cal.get(cal.MONTH) + ":" +
                cal.get(cal.DATE) );
    which produces a Date object with the same value as the first example.
    Regards
    Ayyapparaj

  • How to compare values in resultset

    i am having problem in comparing result set values. Actually my store proc returns me the following resultset:
    Month | Year | Deductible | Troop | TDC | ReasonCode
    ------------|-----------|-----------------|------------|-------------|--------------------------
    January | 2008 | $100.0 | $0.0 | $0.0 | 1
    ------------|-----------|-----------------|------------|--------------|--------------------------
    January | 2008 | $0.0 | $10.0 | $0.0 | 1
    ------------|-----------|---------------- |-------------|-------------|-------------------------
    January | 2008 | $0.0 | $0.0 | $20.0 | 1
    ------------|-----------|-----------------|-------------|-------------|-------------------------
    March | 2008 | $150.0 | $0.0 | $0.0 | 2
    ------------|-----------|-----------------|-------------|-------------|--------------------------
    March | 2008 | $0.0 | $15.0 | $0.0 | 2
    ------------|-----------|-----------------|-------------|-------------|-------------------------
    March | 2008 | $0.0 | $0.0 | $30.0 | 2
    i will compare month and year fields. i.e if year is same the compare month and if month is same (e.g. January) the first three row of the above table will be clubbed in one row i.e.
    Month | Year | Deductible | Troop | TDC | ReasonCode
    ------------|-----------|-----------------|------------|--------------|--------------------------
    January | 2008 | $100.0 | $10.0 | $20.0 | 1
    how can i do it in my result set?

    Learn SQL
    "Select Month, Year, SUM(Deductible), SUM(Troop), SUM(TDC), ReasonCode from table Group By Month, Year, ReasonCode"Otherwise, loop through the resultset and compare the fields you want to compare using .equals() and sum the values yourself (of course).

  • How to do validation of input fields

    Hi all,
              I have a rquirement to do the validation of input fields.Can anybody explain me how to go for that???Please explain in detail.U can also give me a link where i can find the tutorial for doing this.

    Hi Amit,
    What everyone has said above is correct - in the method of your action simply test for whatever condition you need to validate for.  However, the following tutorial shows you how to use Web Dynpro's Message Manager to display the messages on the screen in an easy user-friendly way:
    <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webdynpro/wd%20java/wd%20tutorials/a%20simple%20input%20form%20with%20message%20and%20error%20service%20support.pdf">Enabling Message and Error Support</a>
    In addition, there are some validations that are done automatically depending on what you have your input fields set to - for instance, if you bind your input field to a date and a user enters words into the field instead of an actual date, it will automatically display an error message.  To learn how to turn this feature on and off, see this tutorial
    <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/uuid/edf6ea90-0201-0010-7696-a68662381c12">Using Validating and Non-Validating Actions</a>

  • How to compare table's date field with dropdown year field

    Hi All,
    I have one requirement to display the selected rows from a database table based on the selection of drop down.
    Here, I have one dropdown of year(like 2009,2010,....) and I have one database table which contains one field with "DATE".
    Now, I want to compare table's DATE field with my dropdown field.
    Problem is that table's DATE field is of type "DATS" and dropdown is of type INTEGER(or) STRING ...
    How to compare this fields?
    Can any one please give me solution for this...!
    Thanks in Advance!

    Hi  sreelakshmi.B,
    try the following:
    DATA lt_dats        TYPE TABLE OF dats.
    DATA l_dat_i        TYPE          i.
    DATA l_dat_c_4(4)   TYPE          c.
    DATA l_dat_c_12(12) TYPE          c.
    DATA l_dats_from    TYPE          dats.
    DATA l_dats_to      TYPE          dats.
    *Move Date from Integer to Char
    l_dat_c_4 = l_dat_i = 2005.
    *Create Date From use in WHERE-Clause
    CONCATENATE '01.01.' l_dat_c_4 INTO l_dat_c_12.
    CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
         EXPORTING
              date_external            = l_dat_c_12
         IMPORTING
              date_internal            = l_dats_from
         EXCEPTIONS
              date_external_is_invalid = 1
              OTHERS                   = 2.
    IF sy-subrc <> 0.
    ENDIF.
    *Create Date To use in WHERE-Clause
    CONCATENATE '31.12.' l_dat_c_4 INTO l_dat_c_12.
    CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
         EXPORTING
              date_external            = l_dat_c_12
         IMPORTING
              date_internal            = l_dats_to
         EXCEPTIONS
              date_external_is_invalid = 1
              OTHERS                   = 2.
    IF sy-subrc <> 0.
    ENDIF.
    * Select records in range
    SELECT *
           FROM [DBTAB]
           INTO TABLE [ITAB]
           WHERE [DATE] BETWEEN l_dats_from
                        AND     l_dats_to.
    Regards
    REA

  • How to delete Dynamically created input field UI Element

    Hi all,
              I want to delete dynamically created input field and label.
    Is there any method please tell.
    Thanks in advance
    Hemalatha

    Hi,
    In the WDEVENT parameter of the action handler you can find the event id.
    ***Variables
      DATA:
        lv_selected  type string.          "Selected tab value
    ***Structure and internal table for the Events and messages
      DATA:
        lt_events type WDR_EVENT_PARAMETER_LIST,
        ls_events type WDR_EVENT_PARAMETER.
    ***Field symbols
      field-symbols: <fs_value> type any.   "Attribute value in events table
    ***Move the event table to lt_events
      lt_events = wdevent->parameters.
      read table  lt_events into ls_events with key name = 'SAVE'.  "Button Id
      if sy-subrc eq 0.
        assign ls_events-value->* to <fs_value>.
        if sy-subrc eq 0.
          lv_selected  = <fs_value>.
        endif.                 "IF sy-subrc eq 0.
      endif.                 "IF sy-subrc eq 0.
    Regards,
    Lekha.

  • Please Help. How to access to an input field in a table with javascript

    Hi
    i�m trying to access to the content of an input field that is in an table with a javascript function in this way
    function Valida_Tabla()
    var centro = document.getElementById("form1:idcentro").value;
    alert("Centro es ["+centro+"]")
    var des = document.getElementById("form1:table1:0:textField2").value;
    alert("des ["+des+"]")
    The fisrt alert is ok and displays the value of a field that is in a table.
    The second alert is not displayed.
    Is the syntax wrong?
    what i�m doing wrong
    Please help

    The best bet is to look at the source of the generated HTML and then use the exactly generated ID in the HTML source. When I looked at the HTML source I see the ID of a textfied inside a table as
    form1:table1:tableRowGroup1:0:tableColumn1:textField1
    - Winston
    http://blogs.sun.com/roller/page/winston?catname=Creator

  • How do you change an xml field inside of a database?

    Please: can you tell me how do you update an xml file?
    I mean how do you edit an xml field?
    Paola
    @{---->>----->---------                                                                                                                                                                                                                                                                       

    It should work for Oracle 9.2 and 10.2
    Thank you Dany.
    Regards.
    Paola
    @{--->----->>----------                                                                                                                                                                                                               

  • How to popup values from database tables to SelectOneMenu

    Hi friends,
    I am doing a jsf application, in which there is a selectOneMenu
    control and I want that, iwhen this page is loaded after clicking button
    on the previous page, the selectOne Menu should be populated with
    the values from database.
    Also I want , if i will select any menu item from the menu , acccordingly
    another selectOneMenu control should be filled with respective values
    thanx,
    bye

    Oh dear. I don't think anybody can advise you until you are not "kinda" new to Java anymore. Learn Java itself (the language, the platform and the tools), only then should you start considering going into web development.

  • How to populate read only input field or text view form value help only

    Hi experts,
    I have one requirement to populate a read-only field or text view from value help.
    User cant put any value there.value comes only from the value help.
    For example,
    when we read context using Code Wizard,we cant type any value there.value only comes from value help.
    How to implement that functionality?
    Please reply.
    Thanks in advance,
    Subhasis.

    Yes it is possible.
    1.Create a context Attribute and then bind this attribute to the Text view UI element.
    2. read context attribute and then set value to the context attribute like this way.
    DATA:
        elem_context1                        TYPE REF TO if_wd_context_element,
        stru_context1                        TYPE if_first=>element_context ,
        item_potxt                          LIKE stru_context-potxt.
    get element via lead selection
      elem_context1 = wd_context->get_element(  ).
    stru_context1-potxt = 'PO'.
    elem_context1->set_attribute(
        VALUE  = stru_context1
        name   = 'POTXT'
    thanks
    Suman
    Edited by: suman kumar chinnam on Sep 9, 2008 12:12 PM

  • How to compare and copy the fields from repeating subform to another subform, same structure.

    Dear All,
    I am using LiveCycle Designer 8.2.
    I have the following requirement, and did not figure out the best way to implement it using JavaScript.
    The Form has, say, Subform A with Repeating Inner Subform, say it has the Education History of the Staff.
    I want to put another Subform B, with similar structure to From A, and create a button/function to copy the field data values from A to B.
    Subform A will show the user the fields of education with Read-Only Mode.
    Subform B will show the user the same data values with write-enable mode. This subform will allow the user update his Education Records.
    The fields are:
    0. Staff ID: Text (Key 1) (always read-only and hidden, becuase it is on the main form),
    1. Degree: Text,
    2. Specialization: Text,
    3. Institution: Text,
    4. Start Date: Date (Key 2),
    5. End Date: Date.
    Another function is needed is to compare the same records between form A and Form B.
    (Note: The Education record of a Staff has primary key of Staff ID and Start Date. Meaning, the Staff cannot have tow different degrees in starting on the same date.)
    The user may change the Institution in form B or change the Degree. I need to highlight, on Subform B, the row which was changed or added by the user. This means I need to do lookup against Subform B using the Key Values from Subform A.
    I have already developed the Form, and I have about 5 Subforms to allow updated by Staff: Education, Experience Inside the company, Experience Outside the company, Job Skills, Membership Record, ..etc. One thing I did is that the Field Names I used in Subform A are not the same of the fieldname in Subform B, but the have same suffix, and different prefix. For example, for the Education:
    Subform A - Original Values:
    1. Degree: OrgDegreet,
    2. Specialization: OrgSpecialization,
    3. Institution: OrgInistitution,
    4. Start Date: OrgDateStart (Key),
    5. End Date: OrgDateEnd.
    Subform B - Updated Values:
    1. Degree: UpdDegreet,
    2. Specialization: UpdSpecialization,
    3. Institution: UpdInistitution,
    4. Start Date: UpdDateStart (Key),
    5. End Date: UpdDateEnd.
    I understand if the Key field is updated, then it is like it was deleted, and added a new one.
    I know how to do that in ASP.NET, but need help in Adobe LiveCycle using JavaScript.
    Please help me to write these two functions, as they are very urgent requirement.
    Tarek.

    In the event Exit of the 1st subforum.invoice you will find the code to assign the value to it's "brother" on page4.
    Also, on the add button i added the code to add a record to the page4 subforum.
    To make this work you will have to copy/past the code of the exit event to all fields you want to copy and in the xfa.resolvenode("XXXXXXX[].fieldName") command replace fieldname with the actual name of the field you're at.
    I didnt't do anything to te remove line button because i don't know how you want it to work, but, if you want to control the p4 subform with the p1 subform, you shouldn't allow for lines to be removed directly in the p4 subform.
    Hope this helps.

  • How to compare two currency form fields and display a message if the fields do not equal?

    My form has 2 fields named Total_1 and Total_2. If one of the fields does not equal the other, a hidden field will display a message in red on the form alerting the user. Otherwise, the message does not display. Looks like a validation script but I would greatly appreciate help in getting it started. Any ideas?
    Thanks, Charlie
    charlie6067

    Since the field values that you want to compare are the results of calculations, you should not normally compare their string values, but rather their numeric values when rounded appropriately (and perhaps then converted to a string). For example, if you have two values that display as 3.14, one could be 3.1400000001 and the other could be 3.13999999999991234. When you get the field values as strings and compare them, they won't be equal though they appear to be. Even some values that are numerically identical won't be equal when compared as strings ("0.0" != "0.00") So the code could be changed to:
    // Get the two field values, rounded to two decimals
    var v1 = util.printf("%.2f", getField("Total_1").value);
    var v2 = util.printf("%.2f", getField("Total_2").value);
    // Hide/Show the error message
    event.value = (v1 === v2 || (+v1 === 0 && +v2 === 0)) ? "" : "Error message here.";

Maybe you are looking for

  • FILE-RFC ADAPTER problem

    Hi all, I am trying file->xi->rfc adapter scenario. My scenario is employee information is written to flat file n  will be kept on ftp server.THe file adapter will pickup the file and sends it to rfc adapter through pipeline service. This is going we

  • Webstart - Registering a custom file type

    I'm trying to use a jnlp file to register a custom file type (*.flf) with Windows XP / Vista. I have added the following line to the jnlp file near the bottom (right by the main class tag): <association extensions="flf" mime-type="application-x/flf"

  • Tablespace TEMP en Oracle 10g

    Hola, tengo un crecimiento excesivo del tablespace TEMP y no encuentro la causa, Consulte la v$sort_usage pero no muestra nada. Como puedo solucionarlo ? Gracias Jorge

  • SAP Inurance Claim Management

    Hi All, I'm new to SAP Claim Management in Insurance Industry. If anybody here worked on that, please throw some light on that like what are the T.Codes used, What is the process flow, what tables we use generally. some information on the technical s

  • CS3 has begun crashing unexpectedly

    I guess all crashes are unexpected, but this has begun only recently (2 months). We are running CS3 on an Intel Macbook Pro, system is OSX 10.4.11. Maximum RAM (3 mb). Any thoughts? Thanks Sean Kernan