Mandatory for Date field

Hi All,
     I want to display to Mandatory field if date field is blank or null...
But this code only valiadate ,the Entered date correct or not...
So how to display the Mandatory date field..
Please suggest me ...What is the error..
     IWDMessageManager msgMgr = wdComponentAPI.getMessageManager();
          Object attributeValue = wdContext.currentDateFieldsElement().getAttributeValue(fieldName);
          Date theDate =
               (Date) wdContext.currentDateFieldsElement().getAttributeValue(
                    fieldName);
          IWDAttributeInfo attributeInfo =
               wdContext.nodeDateFields().getNodeInfo().getAttribute(fieldName);
          Calendar c = Calendar.getInstance();
          c.set(Calendar.HOUR_OF_DAY, 0);
          c.set(Calendar.MINUTE, 0);
          c.set(Calendar.SECOND, 0);
          c.set(Calendar.MILLISECOND, 0);
          Date currentDate = new Date(c.getTimeInMillis());
          if (theDate.before(currentDate)) {
//       Throw an error message
            msgMgr.reportContextAttributeMessage(
                           wdContext.currentDateFieldsElement(),
                           attributeInfo,
                           IMessageRequisitionForm.MISSING_INPUT,
                           new Object[] { fieldLabel },
                           true);
Please Tel me ......
Thanks & regards
Mathi

Hi,
Thanks for ur reply...
I tel u what i do..
1.first i set property...(reauired and set th label for)
2.i code in method take a current date
IWDMessageManager msgMgr = wdComponentAPI.getMessageManager();
          Object attributeValue =
               wdContext.currentDateFieldsElement().getAttributeValue(fieldName);
          Date theDate =
               (Date) wdContext.currentDateFieldsElement().getAttributeValue(
                    fieldName);
          IWDAttributeInfo attributeInfo =
               wdContext.nodeDateFields().getNodeInfo().getAttribute(fieldName);
          Calendar c = Calendar.getInstance();
          c.set(Calendar.HOUR_OF_DAY, 0);
          c.set(Calendar.MINUTE, 0);
          c.set(Calendar.SECOND, 0);
          c.set(Calendar.MILLISECOND, 0);
          Date currentDate = new Date(c.getTimeInMillis());
          if (theDate instanceof Date) {
          <b>removeLeadingZeroes</b>(
                              wdContext.currentDateFieldsElement().getAttributeAsText(
                                   fieldName));
               if (theDate.before(currentDate))
                         //       Throw an error message
                         msgMgr.reportContextAttributeMessage(
                              wdContext.currentDateFieldsElement(),
                              attributeInfo,
                              IMessageRequisitionForm.DATE_IS_IN_PAST,
                              new Object[] { fieldLabel },
                              true);
public java.lang.String <b>removeLeadingZeroes</b>( java.lang.String fieldName )
              if (fieldName == null)
               return null;
          int i = 0;
          int n = fieldName.length();
          while (i < n) {
               if (fieldName.charAt(i) != '0')
                    break;
               ++i;
          return fieldName.substring(i);
if could not give removeLeadingZeroes it produced error (runtime exception) (Null pointer exception)..
My Question is...Mandatory is worked if date is incorrect....
I want to set mandatory if that field name is null or balnk...
Please suggest me ....what is my mistake...
Thanks & regards
Mathi

Similar Messages

  • Select-options for date field.

    Hi all,
    i need to give select options for Date field.How can i give that.
    Thanks & Regards
    Ravi.

    Hi Ravi,
    Use the Component WDR_SELECT_OPTIONS to include select options in Web Dynpro ABAP. Follow these steps:
    1. In your Component , "Used Componet" tab add Component WDR_SELECT_OPTIONS . Component Use can be any name that you want to give, eg SELECT_OPTIONS
    2. Go to the View where you want to include the Date Select Options. I am assuming that you already have an Attribute of Type DATS in your context.
    3. View: Properties Tab:Create Controller Usage and select
    SELECT_OPTIONS     WDR_SELECT_OPTIONS                   
    SELECT_OPTIONS     WDR_SELECT_OPTIONS     INTERFACECONTROLLER
    4. View Layout Tab:Include a View Container. In this view container we will show the Date Select Options.
    5. View Attributes Tab: Create Following two attributes:
    M_HANDLER type IF_WD_SELECT_OPTIONS
    M_WD_SELECT_OPTIONS type IWCI_WDR_SELECT_OPTIONS
    6: View Methods Tab: Create a method eg CREATE_SELECTION_SCREEN. Call this method in the WDDOINIT of the view.
    7:CREATE_SELECTION_SCREEN: Write following Code:
    * Data Declaration
      data:
            lt_range_table TYPE REF TO DATA.
      data:
            lr_componentcontroller TYPE REF TO IG_COMPONENTCONTROLLER,
            lr_componentusage TYPE REF TO IF_WD_COMPONENT_USAGE.
    * Execution
    *  Create Used Component
      lr_componentusage = wd_this->wd_cpuse_select_options( ).
      if LR_COMPONENTUSAGE->HAS_ACTIVE_COMPONENT( ) is initial.
        lr_componentusage->create_component( ).
      endif.
    *  Get pointer to interface controller of select options
      wd_this->M_WD_SELECT_OPTIONS = wd_this->wd_cpifc_select_options( ).
    * initialize selction screen
      wd_this->M_HANDLER = wd_this->M_WD_SELECT_OPTIONS->init_selection_screen( ).
    *  Create Range Table for: Date
      CALL METHOD WD_THIS->M_HANDLER->CREATE_RANGE_TABLE
        EXPORTING
          I_TYPENAME     = 'DATS'
        RECEIVING
          RT_RANGE_TABLE = lt_range_table.
    * Add Selection Field for: Date
      CALL METHOD WD_THIS->M_HANDLER->ADD_SELECTION_FIELD
        EXPORTING
          I_ID                         = '<name of date attribute in the context>'
    *      I_WITHIN_BLOCK               = MC_ID_MAIN_BLOCK
    *      I_DESCRIPTION                =
    *      I_IS_AUTO_DESCRIPTION        = ABAP_TRUE
          IT_RESULT                    = lt_range_table
    *      I_OBLIGATORY                 = ABAP_FALSE
    *      I_COMPLEX_RESTRICTIONS       =
    *      I_USE_COMPLEX_RESTRICTION    = ABAP_FALSE
    *      I_NO_COMPLEX_RESTRICTIONS    = ABAP_FALSE
    *      I_VALUE_HELP_TYPE            = IF_WD_VALUE_HELP_HANDLER=>CO_PREFIX_NONE
    *      I_VALUE_HELP_ID              =
    *      I_VALUE_HELP_MODE            =
    *      I_VALUE_HELP_STRUCTURE       =
    *      I_VALUE_HELP_STRUCTURE_FIELD =
    *      I_HELP_REQUEST_HANDLER       =
    *      I_LOWER_CASE                 =
    *      I_MEMORY_ID                  =
    *      I_NO_EXTENSION               = ABAP_FALSE
    *      I_NO_INTERVALS               = ABAP_FALSE
    *      I_AS_CHECKBOX                = ABAP_FALSE
    *      I_AS_DROPDOWN                = ABAP_FALSE
    *      IT_VALUE_SET                 =
    *      I_READ_ONLY                  = ABAP_FALSE
    *      I_DONT_CARE_VALUE            =
    *      I_EXPLANATION                =
          I_TOOLTIP                    = 'Select Date'.
    8: To Fetch Data entered in the selection field, write following code on action of button click:
      data:
            lt_date type REF TO DATA.
    FIELD-SYMBOLS:
                     <fs_date> TYPE table.
      *  retrieve Date from Select Options
      CALL METHOD WD_THIS->M_HANDLER->GET_RANGE_TABLE_OF_SEL_FIELD
        EXPORTING
          I_ID           = '<attrib_name>'
        RECEIVING
          RT_RANGE_TABLE = lt_date.
    *  assign Date Field Symbol
      ASSIGN lt_date->* to <fs_date>.
    9: Windows Window Tab: In the View Conatiner, embed the WND_SELECTION_SCREEN view from SELECT_OPTIONS component Usage of  WDR_SELECT_OPTIONS component.
    Regards,
    Reema.

  • How to set a date range for date field ?

    Dear Experts,
    Scenario:
    I have a query in validating the date field in my BSP application. My application is for maintain infotype 0023 Other/Previous Employers online by employees in the company.
    As per our design we are maintaining the all employment details of the employee both ( with in the current company / previous employment outside the company) in the same infotype.
    Every employee will have a hiring date within the SAP HR system. We consider this date as the cutoff date between current and previous employment in our application. When the employee updating the details wia BSP page I need to check the following.
    Record inside current company: Validation that, the user should only able to enter BEGIN DATE (BEGDA)  greater than or equal HIRING DATE and END DATE(ENDDA) should be greater than FROM  DATE (BEGDA).
    Record outside current Company: Validation that, the user should only able to enter BEGIN DATE (BEGDA)  less than or equal HIRING DATE and END DATE (ENDDA) should be greater than FROM  DATE (BEGDA) and less than HIRING DATE.
    Technical Requirement:
    How to set a date range for date field, i.e. how we can limit the date range in a HTMLB date field? Can this it be achieved via standard functionality of HTMLB?
    Following is the code to describe date field in my application.
        <htmlb:inputField id= "ENDDA_NEW_IN"
                          type= "date"
                    doValidate= "TRUE"
                      showHelp= "TRUE"
                      disabled= "FALSE"
                         width= "183"
                         style= "cssTextAreadate"
                         value= "<%='99991231'%>"/>
    Thanks a lot in advance for your assistance and help.
    Cibinu2026
    Edited by: cibin kuruvilla on Nov 12, 2008 11:13 AM

    Hi,
    This functionality is known to be very important and is a key part of the next major release of the JRC planned for the first half of 2008.
    Regards,
    <p>Blair Wheadon</p>
    <p>Product Manager, Crystal Reports</p>

  • Search help for DATE field

    HI all,
    I want to attach search help for a DATE field created in screen painter.
    For PERNR, PREM is attached. Similarly what is the statndard search help name for DATE field?
    Thanks,
    Shanthi.

    Hi ,
    Declare the date field as sy-datum ,
    parameters : date type sy-datum .
    This shud bring the standard search help for date .
    Thanks ..Get back for any issues.
    Anil

  • When we give wildcard for date field

    can we give wild card for date field in range table.
    my code is this
    RAnges r_erdat for mara-erdat
    r_erdat-sign = 'I'.
    r_erda-option =  'CP'.
    r_erdat-low = '2009'.*
    append r_erdat.
    select erdat from mara
      INTO CORRESPONDING FIELDS OF TABLE itab
      where erdat
      in
       r_erdat.
    Moderator Message: Basic date questions are not allowed.
    Edited by: kishan P on Oct 5, 2010 10:46 AM

    <<Don't answer questions that break the rules. Date questions are not permitted>>
    Hi,
           Instead you can take the entire range for that particular year.
    r_erdat-sign = 'I'.
    r_erda-option = 'BT'.
    r_erdat-low  = '20090101'.   <- begin date
    r_erdat-high = '20091231'.   <- end date
    append r_erdat.
    Regards,
    Srini.
    Edited by: Matt on Oct 5, 2010 12:46 PM

  • Problem in output for date field

    Hi experts...
    i have one requirement like if string is initial i need to display blank for date field in  out put...
    but it is showing 00.00.0000..
    My code is...
    data: V_TEMP TYPE sy-datum,
          V_TEMP1 TYPE sy-datum,
          v_str type string,
          v_str1 type string.
      v_str1 = '2008091123457'.
      v_str = '0'.
      REPLACE ALL OCCURRENCES OF ',' IN v_str WITH SPACE.
      CONDENSE v_str NO-GAPS.
      v_TEMP1 = v_str1+0(8).
      if v_str <> 0.
    v_TEMP = v_str+0(8).
      else.
    v_temp = ''.
       endif.
         write:/ v_temp1 ,V_TEMP.
    output is: 11.09.2008   00.00.0000(BUt i want space here just blank...)
    can any body plz help me.....

    Hi,
    You can use something like that:
    WRITE: date NO-ZERO.
    Best regards.

  • F4 help for date field

    Hello All,
    I am using DATS 8 as a domain for date field but f4 help is not coming
    Help me.
    What to do ?
    Thanks ....................

    HI,
    If u are in Diallog Program then use 'F4_DATE' FM.
    Example :
    CALL FUNCTION 'F4_DATE'
        EXPORTING
          date_for_first_month         = sy-datum
        IMPORTING
          select_date                  = wa_asgntkts-begda
        EXCEPTIONS
          calendar_buffer_not_loadable = 1
          date_after_range             = 2
          date_before_range            = 3
          date_invalid                 = 4
          factory_calendar_not_found   = 5
          holiday_calendar_not_found   = 6
          parameter_conflict           = 7
          OTHERS                       = 8.
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    Or
    If u are in Report Program then maintain ur data type as sy-datum.
    Please give neccessary points if u help this..
    Ranjith

  • Mandatory for Visable field but not for hidden field

    Hi All,
    I have a couple of radio buttons (Yes and No) when the user selects Yes they are then prompted for the date this happend.
    How can i make the Date field mandatory if they select yes but not if they select no. I have tried making the date field mandatory but it throughs the obvious error if it is hidden.

    Hi George, thanks for your reply.
    The way i hide and show the date box at the moment is by using the Show/Hide field action under the properties of the radio buttons.
    Thx

  • SQL Query for Date field updation

    I want a query from u.. Hope u help me with a
    solution soon..
    My Q: I want to update a date field in Oracle
    database. But the condition is that i shouldnt change
    the hours, minutes & seconds of the date field.
    generally , if we update the date field then it takes
    the default values for hours, min's & sec's to
    00:00:00.
    EX : if we have a value 21-SEP-2002 04:54:44 in a date
    field. I want to update it to 22-SEP-2002 04:54:44.
    But it updates to 22-sep-2002 00:00:00 if we use
    UPDATE command.

    Use a PreparedStatement:
    PreparedStatement ps = conn.prepareStatement("SELECT * FROM TEMP WHERE TDATE > ? AND TDATE < ?");
    // note: month numbers start at 0, so 1 is february
    GregorianCalendar c1 = new GregorianCalendar(2002, 1, 11, 11, 0);
    GregorianCalendar c2 = new GregorianCalendar(2002, 1, 18, 22, 0);
    Date d1 = c1.getTime();
    Date d2 = c2.getTime();
    java.sql.Timestamp sqlDate1 = new java.sql.Timestamp(d1.getTime());
    java.sql.Timestamp sqlDate2 = new java.sql.Timestamp(d2.getTime());
    ps.setTimestamp(1, sqlDate1);
    ps.setTimestamp(2, sqlDate2);
    ResultSet rs = ps.executeQuery();
    // get results from the result setJesper

  • Search help for date field in Editable ALV

    Hello Friends,
    I am using editable alv using 'reuse_* '.
    I have used date as input field. While creating fieldcatlog also i have  declared dat as a mkpf-budat.
    But i am not getting serach help for date in output.
    Is it possible with reuse or i have to go by object oriented ?

    Hi,
    Just pass the Edit option of the fieldcatalog for those specific fields...
    fcat-edit = 'X'.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program       = sy-cprog
          i_callback_pf_status_set = 'PF_STATUS_SET'
          i_callback_user_command  = 'USER_COMMAND'    "<----  pass this
          i_callback_top_of_page   = 'TOP'
          is_layout                = it_layout
          it_fieldcat              = it_fcat
          i_default                = 'X'
          i_save                   = 'A'
          it_events                = it_event
        TABLES
          t_outtab                 = it_final
        EXCEPTIONS
          program_error            = 1
          OTHERS                   = 2.
    *&      Form  USER_COMMAND
    *       text
    *      -->R_UCOMM      text
    *      -->RS_SELFIELD  text
    FORM user_command USING r_ucomm LIKE sy-ucomm
                            rs_selfield TYPE slis_selfield.
      CASE r_ucomm.
        WHEN '&DATA_SAVE'.                "<-------check this
          PERFORM save_data.
      ENDCASE.
    ENDFORM.                    "USER_COMMAND

  • Help for date field not working after upgrade

    hi experts,
    In our BSP application for a page we had an inputfield (date).
    Onvaluehelp for input field we were calling the saphelpdate function.
    however after upgrade this functionality is not working properly as no pop up comes after clicking on the icon.
    we have upgraded to SPS 16 recently.
    please help me.
    regards,
    Arvind.

    Hi, I try upper case but nothing happen. This is all my code by far, I hope you can help me:
    DATA: BEGIN OF T_PCONT OCCURS 0,
          PCONT LIKE ZPSPERMISOS-PSOBKEY,
    END OF T_PCONT.
    DATA: BEGIN OF T_FIELDS OCCURS 0.
            INCLUDE STRUCTURE help_value.
    DATA END OF T_FIELDS.
    DATA: BEGIN OF T_VALUES OCCURS 0,
          VALUE(60) TYPE c.
    DATA: END OF T_VALUES.
    DATA: N TYPE i.
    SELECTION-SCREEN BEGIN OF BLOCK  b20 WITH FRAME TITLE text-b02.
      SELECT-OPTIONS:
        P_CONT FOR  ZPSPERMISOSH-PSOBKEY OBLIGATORY NO-EXTENSION NO INTERVALS,
        P_INT  FOR  ZPSPERMISOSH-PARTNER OBLIGATORY NO-EXTENSION NO INTERVALS,
        P_FEC  FOR  ZPSPERMISOSH-ZFINICN NO-EXTENSION NO INTERVALS,    
        P_RAZ  FOR  ZPSPERMISOSH-ZRAZONFINIC NO-EXTENSION NO INTERVALS.
    SELECTION-SCREEN END OF BLOCK b20.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_CONT-LOW.
      PERFORM P_HELP_P_CONT USING P_CONT-LOW.
    *&      Form  P_HELP_P_CONT
    FORM P_HELP_P_CONT  USING P_P_CONT.
      DESCRIBE TABLE T_PCONT LINES N.
      IF N EQ 0.
        T_FIELDS-FIELDNAME  = 'PSOBKEY'.
        T_FIELDS-TABNAME    = 'ZPSPERMISOS'.
        T_FIELDS-SELECTFLAG = 'X'.
        APPEND T_FIELDS.
        CLEAR T_FIELDS.
        SELECT PSOBKEY FROM ZPSPERMISOS
        INTO  TABLE T_PCONT.
        SORT T_PCONT BY PCONT.
      CALL FUNCTION 'HELP_VALUES_GET_WITH_TABLE'
        EXPORTING
          CUCOL        = 10
          CUROW        = 1
          TABNAME      = 'T_PCONT'
          FIELDNAME    = 'PCONT'
        IMPORTING
          SELECT_VALUE = P_P_CONT
        TABLES
          FIELDS       = T_FIELDS
          VALUETAB     = T_VALUES.
    ENDFORM.                    " P_HELP_P_CONT
    Edited by: J. Garibaldi on Nov 25, 2009 11:14 AM
    Edited by: J. Garibaldi on Nov 25, 2009 11:16 AM

  • F4 help for Date field and Validation

    Hi Friends,
    I am new to BSP programming .I knew getting F4 help in normal ABAP.But i don't know in BSP .
    I want simple steps to get F4 for a field on Page as well as date field .
    and How to valid those entered dates.
    Presently i am using length 10 character variable for DATE without F4 help and No validation.
    I think you guys will help me out.
    Thanks,
    Venkat.O

    Welcome to SDN.
    for F4 help with validation for dates you can use the following code.
    <htmlb:inputField id         = "wf_ad_date"
                                    type       = "date"
                                    showHelp   = "TRUE"
                                    value = "<%= sy-datum  %>"
                                    visible    = "true"
                                    disabled   = "false"
                                    required   = "true"
                                    maxlength  = "10"
                                    size       = "10"
                                    doValidate = "true"
                                    design     = "standard" />
    For other type of fields check out this weblog by Thomas Jung
    <a href="/people/thomas.jung3/blog/2005/08/22/bsp-value-input-help-popups-version-30 Value Input Help Popups Version 3.0</a>
    Regards
    Raja

  • F4 help for date field in ITS

    hi all;
    I was working on ESS Leave Request, i am using the standard program SAPMWS20000081H and the service template WS20000081.
    Now in the EP view i am unable to get the F4 help for the date field 'Absence From' & 'Absence To'. i have checked the data element used it is 'DATS'.
    How to get the F4 help in the view, please help me its of high priority.

    Hi, I can tell you what we have done.  I can see that the original template displays the "Absence from" field this way :
    <tr>     <td>`SAP_TemplateEditableField("FromDay", fieldLabel=ABSENCEFROM030150.label, fieldLabelWidth="170", name="ABSENCEFROM030150", value=ABSENCEFROM030150, size="10", maxlength="10", marginTop=9, inspectionText=ABSENCEFROMDAY,  align="",
    required="", width="", onchange="update_checkn(this.SAP_value, this)" )` </td>
         </tr>
    We modified the template to display it like this :
    <tr><td> `SAP_Field("ABSENCEFROM030150","ABSENCEFROM030150", DynproLabelWidth="170")` </td></tr>
    We did the same for ABSENCETO040150. So you can play around with the template to generate the F4 button. ( Note that we also added the ~webgui parameter in the service file and set it to 1, this in order to generate the calendar ). Good luck !

  • How to display this 2 character for date field (    \   \       )

    hi friends
    it's possible to display the character format in text field after you run the form
    plz I need your help
    thanks

    Hello,
    So you mean for the date field you want to show slashes by default. I don't think that forms will support this type of things.
    BTW may i know what is the purpose to show like this?
    If you use the normal format which is DD/MM/RRRR it will add the slashes automatically. When user will enter date like this 01012010.
    -Ammad

  • F4 ( Search Help ) for date field  on the selection screen

    Hi Freinds,
    i have used WDR_SELECT_OPTIONS In my component, i have one date field on selection screen(BUDAT), for this date field i want seach help 
    this is my code
    create a range table for Posting Date
    lt_range_table = wd_this->m_handler->create_range_table(
                                                              i_typename = 'BUDAT' ).
    add Posting Date  to the selection
    wd_this->m_handler->add_selection_field( i_id = 'BUDAT'
         i_value_help_type = if_wd_value_help_handler=>CO_PREFIX_SEARCHHELP
                                               I_VALUE_HELP_ID = '??????'
                                               I_DESCRIPTION = 'Posting Date'
                                               it_result = lt_range_table ).
    can any one help me
    Thanks
    Srini

    hi sarbjeet 
    i created search help in dictionary and i used that search help in my program, but still its now working , any other ideas
    Thnx
    srini

Maybe you are looking for

  • How do I use "LabVIEW dll import wizard" to import NETAPI32.dll

    I am trying to use the LabVIEW dll import wizard for the first time. I am not very familiar in C-coding so this might be a good help instead of configuring CallLibraryFunction nodes myself. I want to import NETAPI.dll. I am interested in several func

  • Automatically Running a Java Program

    I have a Java program which converts a text file to a XML file. I would like to be able to automatically run this program once every 8 hours or to have it run at set times. Has anybody done this before or does anybody know how to do this?

  • Need to extract data from R/3 to BI...

    Hi Friends, We need to extract some data available in the R/3 side to BI. I have written code in a function module which brings the output into the table e_t_data. now by attaching this function module, we created a Data source also. and then from BI

  • Can you connect MacBook Air (2010) to Dell Display S2440L?

    Hi, I have a MacBook Air from mid 2010, uses an HDMI to mini display port cable.  I am trying to use a new Dell Display S244OL but it just flashes that it is going to go into power saving mode.  Is there something I can do to make it work?

  • An age old bug - GarageBand not updating

    It is actually both iPhoto & GarageBand that are not being updated. The exact message is this: This update is not available. You must have previously purchased the item being updated. Tap Buy to purchase it now. which doesn't make much sense to me. D