Inputfields validaion

Hi
I want to validate my input fields which i m using in mu webdynpro java application
here i m using sample application to display flightlistdetails..
here context i m having like this
context(contextnode)
  bapi_flighlist_input(node)
        destinationfrom(childnode)
     city(attribute)
        destinationto(childnode)
     city(attribute)
   bapi_flightlist_output(node)
        flightlist(childnode)
              (some attributes)
here those city is input field
i m having button called submit
when i click on buttun, i should get flightlist details in a table
till here i got the output
but i wanna maintain city is madatory field
if i dont give any input...out put should not generate
for this i wrote the below code
i create a message at messagepool also
method:Checkmanditory
  public void CheckMandatory( java.lang.String FieldName )
    //@@begin CheckMandatory()
     IWDMessageManager messageMgr = wdComponentAPI.getMessageManager();
     Object attributeValue = wdContext.currentDestination_FromElement().getAttributeValue(FieldName);
     IWDAttributeInfo attributeInfo = wdContext.getNodeInfo().getAttribute(FieldName);
     messageMgr.reportSuccess(wdContext.getNodeInfo().getAttribute(FieldName).toString());
     if (((String) attributeValue).length() == 0)
     messageMgr.reportContextAttributeMessage(
                                             wdContext.currentContextElement(),
                                             attributeInfo,
                                             IMessageFlightList_Comp.MISSING_INPUT,
                                             new Object[] { "City" },
                                             true);
    //@@end
action button: submit
  public void onActionsubmit(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
    //@@begin onActionsubmit(ServerEvent)
    this.CheckMandatory(IPrivateFlightList_View.IDestination_FromElement.CITY);
             wdThis.wdGetFlightList_CompController().executeBapi_Flight_Getlist_Input();
    //@@end
now after executnig n click on submit button, i m getting below error:
java.lang.NullPointerException
     at com.sccl.FlightList_View.CheckMandatory(FlightList_View.java:149)
     at com.sccl.FlightList_View.onActionsubmit(FlightList_View.java:169)
     at com.sccl.wdp.InternalFlightList_View.wdInvokeEventHandler(InternalFlightList_View.java:205)
     at com.sap.tc.webdynpro.progmodel.generation.DelegatingView.invokeEventHandler(DelegatingView.java:87)
     at com.sap.tc.webdynpro.progmodel.controller.Action.fire(Action.java:67)
     at com.sap.tc.webdynpro.clientserver.window.WindowPhaseModel.doHandleActionEvent(WindowPhaseModel.java:420)
     at com.sap.tc.webdynpro.clientserver.window.WindowPhaseModel.processRequest(WindowPhaseModel.java:132)
     at com.sap.tc.webdynpro.clientserver.window.WebDynproWindow.processRequest(WebDynproWindow.java:335)

Hi,
For this you have to link your input field with error message.
Create a message pool with message key and error message. after write code like this, here I am giving you the generic code, change as you want
//Report a message with reference to the context (links message to the offending field)
        msgMgr.reportContextAttributeMessage(
                              nodeElement,
                              attrInfo,
                              IMessage{nc}.{MessageKey},
                             new Object[] {p1,u2026,pn},
                            boolean);
// Metadata of context attribute {ca}, containing the erroneous value 
     IWDAttributeInfo attrInfo =
                  wdContext.node{cn}.getNodeInfo().getAttribute({ca});
// Reference to element at lead selection, having {ca} as a child
     I{cn} Element nodeElement = wdContext. node{cn}.current{cn}Element();
Checking the Exception Manager for stored messages and terminate user coding processing
     wdComponentAPI.getMessageManager()
          .raisePendingException();
here is the step by step procedure for doing the above one
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/70361a88-d6ce-2a10-b1bc-c357097a7d26
http://help.sap.com/erp2005_ehp_03/helpdata/EN/36/d4528e6dbf084b9d79a50fb8d08e86/frameset.htm
regards,
Pradeep

Similar Messages

  • Getting Values from RFC into inputfield

    hi all,
    I want an inputfield with the list of values from an RFC
    like there should be an inputfield in which i can enter my onw value or select a value from combobox like list
    that means a combo box with inputfield is required
    please help
    thanks
    Gaurav

    Hi Gaurav,
    As far as I know there is no UI element provided that fits your requirement.
    Regards,
    Murtuza

  • How to change attribute "read_only" of a inputfield in a table?

    Hi, experts,
    action:
    1.Create a table with name " A_TABLE" in the layout in a view.
    2.Binding some fields from a structure to the table.
    3.Field "Checkbox" is a checkbox type and field "input" is a inputfield type with readonly in the table "A_TABLE" .
    4.I hope: When selecting a checkbox in the "Checkbox" colume in a row in the table, the field "input"  corresponding will be changed readonly.
    The follow is my code: When select Field "Checkbox" , the method is invoked.
    method ONACTIONCLICK4DISDESC .
       data view           type ref to if_wd_view.
       DATA input_desc     TYPE REF TO CL_WD_INPUT_FIELD.
       data tab            type if_BIDDING_LIST_VIEW=>elements_ONSURVEY.
       data struct         type if_BIDDING_LIST_VIEW=>element_ONSURVEY.
    I have set "wd_this->m_view = view" in the method wddomodify and add m_view to the attribute of the
      "viewBIDDING_LIST_VIEW" .
       view ?= wd_this->m_view.
       input_desc ?= view->GET_ELEMENT( `TABLE_INPUT_EDITOR` ).
       input_desc->SET_READ_ONLY(  EXPORTING  value = abap_false ).
    endmethod.
    result:
    when I select a checkbox in the "Checkbox" colume in a row in the table, all field "input" is read and write.
    How can I do it ?
    Best regards,
    tao

    Hello Wang,
    You need to bind the readOnly attribute of the input field to a newly to created attribute beneath the dataSource node of the table within the context. That way, each input field of each row of the table can have a different value for readOnly.
    Best regards,
    Thomas

  • How to set mandatory a InputField in standard Web Dynpro component?

    Hi guys.
    A very weird thing is happening. I am trying to validate that a non-mandatory STANDARD input field (COST_ASSIGNMENT) does not to be empty. This input field belongs to GENERAL_DATA_VIEW, FITE_VC_GENERAL_DATA WD component. The entry fields at screen belong to this GENERAL_DATA_VIEW, but navigation is allocated in buttons that belong to another component (LAYOUT_VIEW in the FITV_FPM WD component). All the views and components are standard and they seem to be in the same screen from user's point of view. I was able to put my own code at WDDOAFTERACTION method in LAYOUT_VIEW to raise an error message.
    Incredibly, my error text message appears in the MESSAGEAREA, and the UI components from GENERAL_DATA_VIEW are rightly still in the screen waiting for user answer since I set CANCEL_NAVIGATION = 'X', but the UI components from LAYOUT_VIEW (the buttons with navigate functions) changed like they had accepted my entry in spite of I set the code in this view. In fact, below my error text displayed, there is other (success) text which communicates "Standing approval for business trips exists" with a green tick.
    The success text should not be displayed since I raised an error message, even after (I think so) the system created the success message.  I suspect that the standard positive message with the green tick indicates that my error is being taking into acccount by the system to be displayed but the LAYOUT_VIEW UI components dont stop navigation and the data is wrongly saved from the code where the success message was generated.
    I think there would be another way to define an standard inputfield mandatory, but I dont know how to do it. Do you know that? I really appreciate all help. Thanks

    hi,
    just make the input feild as mandatory in properties and use the following code.
    data:
    lo_view_controller type ref to if_wd_view_controller,
    lo_dyn type ref to cl_wd_dynamic_tool.
    Create Object
    create object lo_dyn.
    data lt_messages type lo_dyn->t_check_result_message_tab.
    Get view controller reference
    lo_view_controller = wd_this->wd_get_api( ).
    Call Method to verify the element has the value or not
    call method cl_wd_dynamic_tool=>check_mandatory_attr_on_view
    exporting
    view_controller = lo_view_controller
    display_messages = ABAP_TRUE
    importing
    messages = lt_messages .
    endmethod.
    Regards,
    Kranthi

  • Wdr:select_options and highlight Error Message with a Link to Inputfield

    Hi,
    I have created a InputField on a View using WDR_SELECT_OPTIONS. I want to validate this Input Field and give
    Error Message, when User fill it with wrong Values. How can we achieve this and important is to mark it on Screen WITH a RED STAR. ( e.g. highlighted )
    Thanks!
    Best Regards
    Beserithan Malabakan

    I've not tried it with select options before, but you might wan to have a look at setting the REPORT_ATTRIBUTE_ERROR_MESSAGE method of the message object.  This way the message gets attached to any UI element bound to the context attribute you issue the message for. But as I type this and think about it some more; I see where the problem lies.  The Select Options component doesn't follow an approach of cross component context binding.  It dynamically generates its own context.
    If I had a little more time I would test this out; but it might be worth your while to research.  When you initialize the Select-Options, you normally get access to the interface controller:
    data: l_ref_cmp_usage type ref to if_wd_component_usage.
      l_ref_cmp_usage =   wd_this->wd_cpuse_select_options( ).
      if l_ref_cmp_usage->has_active_component( ) is initial.
        l_ref_cmp_usage->create_component( ).
      endif.
    * get a pointer to the interface controller of the select options
    *component
      wd_this->lv_wd_select_options =
           wd_this->wd_cpifc_select_options( ).
    * init the select screen
      wd_this->lv_sel_handler =
           wd_this->lv_wd_select_options->init_selection_screen( ).
    This interface controller (LV_WD_SELECT_OPTIONS in my case). Has a GET_API method that returns the component controller.  In turn you might be able to access the context of the Select-Options directly. Its a crazy idea, but worth a try.

  • Addition of a inputfield as column to item level table in shopping cart

    Dear Experts
    i added a new inputfield to item level table as columen of Shopping cart and binded a variable from context. that column is displayed in the table but it is displayed in Disabled mode im not able to give input to the column(as it is a inputfield).
    I checked the table column property it is enabled and i aslo configure on the SPRO, nothing is woring for me.
    Please giude me to make the table column enabled so that i can give input..
    Regards
    Arun.K.P

    Hi  Arun ,
    you need to maintain the Meta data entries ,
    Navigate path
    spro->sap implementation guide->Supplier Relationship Management->SRM server->cross application basic settings-> extension and field control->create table extension and supply with data->control table extension and there field action-> configure control of fields of table extension .
    Thanks & Regards
    Pradeep Kumar Dondeti

  • In webdynpro for abap, how to set the component of "inputfield" resizable??

    hi,expert.
      there is a property 'resizable' both in components: TEXT and INPUTFIELD,  but it only effected in TEXT component,and not in INPUTFIELD component
      i don't know how to make inputfield resizable.....hope anyone can give  some suggestions.
    thanks in advanced.

    What release level are you working on? I checked my local 7.02 system and I checked SAP's internal developement system where Web Dynpro Froundation gets created and neither had a resizable property on the inputfield.
    What do you mean by TEXT?  There is no UI element called TEXT. We have TextView and TextEdit. Neither of those have a resizable property either.

  • InputField focus issue in ECC 6.0

    We are upgrading from 4.7 to ECC 6 - I have a BSP app which is behaving differently in ECC 6.  When tabbing between inputFields within an iterator, the first tab will place the cursor focus around the inputField, then the second tab will place the focus inside the inputField.  You cannot start typing into the inputField until the 2nd tab.  This is very annoying and confusing to the user.  Is there anyway to change this behavior so that the cursor focus moves inside the field on the first tab?  This does not seem to happen with inputFields which are not within an iterator.  This does not happen with 4.7.  Any insight would be greatly appreciated.
    Lisa

    Raja,
        Thanks for your reply.  But I have about 9 different data screens, and do not wish to hard-code the tabbing via javascript for each one.  This seems like alot of work to make tabbing to the next field work correctly (like it does in any normal HTML page).  I would like to be able to tab thru all data entry fields within my iterator, moving to the next field with only one TAB.  This works outside of an iterator, and works in previous versions of SAP.  But I have to TAB twice now to get to the next field.  Is there a new parameter on the inputField or Table definition which might override this behavior?  I can't imagine any situation where I would want to TAB to the cell holding the inputField, rather than to the inputField itself.  Has anyone else encountered this behavior?
    Thanks,
    Lisa

  • Dynamic thtmlb:inputField .../ in a loop will not be bound

    Hi together,
    I want to generate a count of input fields with this code
    <%
    DATA:
    lv_num_prods TYPE string,
    lv_count    TYPE string.
    DO 5 TIMES.
    lv_count = lv_count + 1.
    CONCATENATE '//PRODUCTS/PROD_NO_' lv_count INTO lv_field_value.
    CONDENSE lv_field_value NO-GAPS.
    %>
    <thtmlb:inputField id            = "products.prod_no_<%= lv_count %>"
                           value         = "<%= lv_field_value %>"
                           tooltip       = "Eingabe der Produktnummer Position <%= lv_count %>."
                           disabled      = "FALSE"
                           width         = "90%"
                           encode        = "X"
                           submitOnEnter = "X" />
    <%
    ENDDO.
    %>
    The "lv_field_value" contains e.g. '//PRODUCTS/PROD_NO_1' in the first iteration. The context node "products" and attribute "prod_no_1" exists.
    -> PROBLEM: The input field will not be bound to the attribute
    If I use the following code instead, it will be bound! So where is the difference???
    <thtmlb:inputField id            = "products.prod_no_<%= lv_count %>"
                           value         = "//PRODUCTS/PROD_NO_1"
                           [...] />
    Thanks for your help!!!

    Hi Taiga,
    You cannot do the binding using the "Value" attribute. There's a blog by Thomas Jung that talks about this bit, but I can't seem to find it now. Generate the input field using the factory class "cl_thtmlb_inputfield=>factory" and specify the binding string via the "_Value" instead of "Value". Include other attributes as is necessary. Use the returned bee to render the field.
    ip ?= cl_thtmlb_inputfield=>factory( id = lv_string
      _value = lv_bind_string ).
    <bsp:bee bee="<%= ip %>" />
    Regards,
    Arun Prakash

  • Javascript Error in InputField Date Type

    Hi,
    We have migrated the Enterprise Portal Application EP5SP6 to NW2004s SP6.Everything works fine except one issue in a Manager Reports, Where we are using Date type InputField.
    Code used:
    <hbj:inputField
    id="otherdate1"
    type="DATE"
    showHelp="TRUE"
    size="10"
    maxlength="10"
    jsObjectNeeded="true"
    disabled="TRUE"
    >
    <%
    JSP-scriptlet-START----
    otherPeriodFrom=myContext.getParamIdForComponent(otherdate1);
    JSP-scriptlet-END----
    %>
    </hbj:inputField>
    Javascript Error : Line : 3958 code: 2 Error: 'Undefined' is null or not an object
    Above Error appears when the below option in IE is selected.And also, Error appears only when the user enters the date.Also, I cannot ask users to uncheck the settings in IE as most of the users doesn't have administrator access to their amchines
    Error doesn't seem to appear when user selects the date from DataPicker component irrespective whether the below option in IE is selected or not.
    IE Setting option :
    Display a Notification about Every Script Error
    I'm not able to find what could be the problem in EP 7.0 as it works perfectly in EP5.0.
    Any ideas would be appreciated !!
    Thanks,
    Jojo

    Sent an OSS message to SAP.SAP found the problem and fixed the issue and will be available in NW2004s SPS9.
    Jojo

  • Date in InputField/TextView

    Hi all,
    I was wondering if anyone knows how a date value gets formatted to a string before it's displayed in an InputField or TextView. I believe the conversion uses the current session locale you can obtain by calling WDResourceHandler.getCurrentSessionLocale(). However, using DateFormat.getDateInstance and passing it the locale and any of the predefined styles does not produce the same results. Even using WDResourceHandler.formatDate yields different results. I'm in Australia and for this locale I get dates displayed in format d/MM/yyyy and if I switch to US locale, I get dates in format M/d/yyyy. Is there any means to obtain the pattern and/or SimpleDateFormat (if they use one) they use in Web Dynpro internally. I need this to be able to display dates consistently.
    Thanks,
    Martin

    Hi guys,
    Thanks for your answers. Not sure we understood each other completely. What I meant was this. I know how to format a date value to my desired pattern. The problem is, I don't know what my desired pattern is. I'm trying to write an application that should be internationalized. For the start, it should work both with Australian and US customers. So there's different date formats involved. When I bind a date attribute to a textview element Web Dynpro formats it for me automatically. If the language setting in the browser are US, it formats it using this pattern (as specified by SimpleDateFormat) "M/d/yyyy". If I switch to en_AU, then it uses format "d/MM/yyyy". Now these patterns don't seem to be the default ones that you can get by calling java.text.DateFormat.getDateInstance(). I was wondering if there is any way to retrieve the date format pattern that Web Dynpro is using by default (and that is locale specific) so that I can use it elsewhere.
    Thanks,
    Martin

  • How to disable the inputfield using radio button dynamically in module pool

    How to disable the inputfield on the screen using radio button dynamically in module pool.
    Please suggest .
            Thanks.
    Edited by: Lavanya YH1504 on Jul 30, 2010 1:20 PM

    I got it thank you.
    LOOP AT SCREEN.
        if  screen-GROUP1 = 'LA1'.
           If RADIO1 = 'X'.
            SCREEN-INPUT = '0'.
            MODIFY SCREEN.
         ELSEIF RADIO2 = 'X'.
           screen-input = '1'.
          ENDIF.
          MODIFY SCREEN.
        ENDIF.
      ENDLOOP.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    Edited by: Lavanya YH1504 on Jul 30, 2010 1:51 PM

  • How to make the frame of the inputfield colored?

    Hi everyone,
      I have a problem here: I have a table on the screen, there are two columns which are inputfield,when user type something and press the "Enter" button,  my program will check whether the value is correct or not. And when the input is wrong I want to point out the specific cell which is wrong by make the frame of the cell red, green or something else.
      How can I achieve this?
    Thanks in advance.

    hi,
    check out this thread :
    Re: Can we Change the backround color of an Input field in Webdynpro for ABAP.
    Thanx.

  • Problem: Value in Inputfield empty

    Hello,
    I use the htmlb:tableView and defined one column as editable where a dropdown-list is assigned (by iterator).
    In the "OnInputProcessing" I read the new selected value of the edit-column and write this value to my internal table.
    Here the Coding of this:
    Get Data for tv_cols, the current edited row, and update table
    DATA: tab_view TYPE REF TO CL_HTMLB_TABLEVIEW.
    DATA: tab_data TYPE REF TO CL_HTMLB_EVENT_TABLEVIEW.
    DATA value TYPE STRING.
    DATA: inputfield TYPE REF TO CL_HTMLB_INPUTFIELD.
    FIELD-SYMBOLS: <row> TYPE ZSEM_0APPR_REQU_1.
    tab_view ?= CL_HTMLB_MANAGER=>GET_DATA(
                            request      = runtime->server->request
                            name         = 'tableView'
                            id           = 'tab_APPR_REQU_status' ).
    get changes into internal table
    get changes into internal table
    IF NOT tab_view IS INITIAL.
      tab_data = tab_view->data.
      IF NOT last_selected_rowIndex IS INITIAL.
        READ TABLE gtab_APPR_REQU_1
           INDEX last_selected_rowIndex
           ASSIGNING <row>.
        value = tab_data->GET_CELL_ID(
                      row_index    = last_selected_rowIndex
                      column_index = '3' ).
        inputfield ?= CL_HTMLB_MANAGER=>GET_DATA(
                            request      = request
                            name         = 'inputField'
                            id           = value ).
        IF inputField->value is not initial.
            <row>-STATUSIQMS = inputField->value.
        ENDIF.
      ENDIF.
      last_selected_rowIndex = tab_data->SelectedRowIndex.
    ENDIF.
    Now my problem:
    If I select a new line in the tableView the value of the line selected before is in the variable "inputField->value" and everything is working fine.
    But if I had selected a line and changed the editable column and then push an save-button on the BSP-Site the variable "inputField->value" is empty. Though the "inputfield" itself was assigned correct.
    What's going wrong here? How can I get the new value of last changed line?
    Thanks in advance
    Christian

    Whenever you select a new line the OnInputProcessing fires and you can read the value and store it then when the screen is rendered again the value is there and they are now on the new line to edit.
    When you build the element into your table it is assigned the [tablename]_[cell]_[row] and if you know those items then you can do a simple get_form_field call.
    Then you have the value and you can do a table UPDATE to save the value.

  • How to enable the InputField when press the Button

    My sceanrio is by default the InputField is in disable .when ever i press the button it should enable.

    Here is the sample code for HTMLB :
    <hbj:inputField
        id="InputText"
        jsObjectNeeded="true"
        type="string"
        maxlength="30"
        value="Text" >
    <% String text = myContext.getParamIdForComponent(create_group); %>
    <SCRIPT> var jsText = '<%=text%>'; </SCRIPT>
    </hbj:inputField>
    <hbj:button id="Enable_Button"
           text="Enable"
           tooltip="Enable InputField"
           onClick="onEnableClick"
           onClientClick="enableInputField()"
           width="30px" >
    </hbj:button>
    </hbj:page>
    </hbj:content>
    <script language="javascript">
         function enableInputField()
              var funcName = htmlb_formid+"_getHtmlbElementId";
              func = window[funcName];
              var inputfield = eval(jsText);
                                    inputfield.setEnabled();
    </script>
    Refer to the following links for more info...
    http://help.sap.com/saphelp_nw04/helpdata/en/53/9d0e41a346ef6fe10000000a1550b0/content.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/43/067941a51a1a09e10000000a155106/content.htm
    Regards,
    Rajiv

Maybe you are looking for

  • Sales order billing with EMI

    Hi All, the scenario is :  when customer comes to store and book a product then some amount is taken as down payment and rest of the payment is divided in installments. The system should allow to do billing if a fixed no of installments are paid by c

  • CSS to move division from center.

    Hello all, i need a bit of help with some CSS code. I am creating a webpage where the background graphic is a television and the content sits on the screen. My screen is not exactly centered on the page, so the interior content div is about 30 pixels

  • File conversion for more than one level of substructure

    I have the following file format that needs to be converted into XML, but because it has more than one level of substructure I'm not able to give the correct file conversion parameter source file sample: 1headeryyyyyyyyyyyyy 2itemsyyyyyyyyyyyyyy 2ite

  • Cursor should be at Current checkbox

    Hi All, I have written the coding.If i check the record,and do some calculations affter click on Pre-Calculate Button again the cursor is going to 1st record. plss can any one help me in this issue.. In WHEN_BUTTON_PRESSED trigger i have written the

  • Mail broken since security update 2008-004, multiple symptoms

    Unfortunately, I can't sum this up in a snappy headline. To get this started: the machine is an iMac 800MHz, which is running Mac OS X Server 10.4.11. It's not running Leopard, which might cure several issues, because it can't be installed on that ma