Field length validation

hi all,
        i'm working on module pool, i got field called Mobile number, whose length is 10 chars.
if the user enters less then 10 chars it should give error, how to accomplish this one.
regards
suprith

Hi,
You can use one of the following function to determine the length of the characters.
strlen
numofchar-Same as for the function strlen, except that in this case when a non-Unicode double-byte code is used, a character that occupies 2 bytes is only counted once.
You can also use Get Cursor..Length Len where Len is of type i.
Regards,
Pavithra

Similar Messages

  • Field length validations

    Hi All,
    In my application, I have to give a set of inputs...and will get the output on the basis of range set. If I dont give any input, then also BAPI will fetch all the data.
    I have to set length validations(fixed, maximum) without using simple type.
    How this can be achieved ?
    Thanks,
    Nikhil

    hi Rocio, It works. But i'm doing the validation for a column in my table. So, i want the red mark to be in the right row (right now, its always in the last row). Also, i want to stop any other actions, navigations etcs when this validation fails even for a single row. How could i achieve this? Here is my code. I have written my code in wdModify view as i felt thats the best place to make the validation work in every instance.
    if (wdContext.nodeVn_ContactPersonaDetails().size() > 0) {
                        for (int size = 0;
                             size < wdContext.nodeVn_ContactPersonaDetails().size();
                             size++) {
                             String attrValue =
                                  wdContext
                                       .nodeVn_ContactPersonaDetails()
                                       .getVn_ContactPersonaDetailsElementAt(size)
                                       .getVa_lastName();
                             if (attrValue == null) {
                                  IPrivateCreateCustomerInputView
                                       .IVn_ContactPersonaDetailsElement neCnt =
                                       wdContext.currentVn_ContactPersonaDetailsElement();
                                  wdThis
                                       .wdGetAPI()
                                       .getComponent()
                                       .getMessageManager()
                                       .reportInvalidContextAttributeException(
                                            neCnt,
                                            wdContext
                                                 .nodeVn_ContactPersonaDetails()
                                                 .getNodeInfo()
                                                 .getAttribute(
                                                 "va_lastName"),
                                            "Last Name field must be filled!",
                                            false);
                                  break;

  • Control an Integer field Length without using Validation ??

    Hi,
    I have Couple of fields where I need to configure them as Integers.
    Now each one has a fixed length that i need to limit to.
    But when i create a field of type: integer, i cannot select teh length!!!
    To achive this the idea i have is to write a validation which checks length..
    But can i achive it without going for a validation on each field???
    PS: I am aware that TEXT field can limit the length But it also allows me to enter text values, my requirement clearly says that to allow users to only enter Numeric values..
    Did anyone face a similar Case?
    Kind Regards
    Eva

    Hi Eva,
    I didn't try in the system, but I feel there are two solutions to achieve your requirement (*of course in both cases you will need to write a simple validation)
    Solution 1 : When field is defined as "Integer" in Console.
    lets take an example, you want to restrict an integer field with a limit of max 4 characters.
    Maximum value of a 4 character integer can be "9999". So, you can put a simple validation to compare the field value with 9999. if the value is less then this means fields values is less than 4 characters, else more than 5 characters.
    In this case Your validation expression in expression editor will be:
    FIELD NAME<= "9999"
    Solution 2 : When field is defined as "Text" in Console.
    In this case you can restrict the maximum field length through Console. But you will also need to write a validation to ensure that user is not entering any alphabets or special characters in this field.
    In this Case you can use below validation:
    HAS_ALL_CHARS(FIELD NAME, "0","9")
    This will ensure that field has all characters between 0 and 9 and doesn't hold any special character or alphabets.
    In Both cases you will need to set  "Automatic Execution" property as "Error". Also please do not manually type any function or value in expression editor. use drop down for fields, operators, functions etc.  and enter numeric values using the first blank box before dimension list.
    Kindly revert if you face any issues.
    -Shiv

  • Want to change length validator message and change field format.

    I want to override Length Validator Message as I want to tell the user that phone number
    must contain 10 numbers
    I've added this validator on the phone field
    af:validateLength minimum="10" maximum="10"
                                   hintMinimum="11" hintMaximum="22"
                                   hintNotInRange="33" messageDetailMinimum="44"
                                   messageDetailMaximum="55"
                                   messageDetailNotInRange="66" id="lengthval"/>and this when I enter less than 10 numbers the error message tell that you must enter 10 characters
    I want to override this message to be "you must enter 10 numbers"
    And I want to make this number format like
    XXXX,XXX,XX
    How can I make this.

    Strictly speaking a number in this format is no number. It's a phone number and you should use a regular expression validator for this.
    Check http://docs.oracle.com/cd/E15051_01/apirefs.1111/e12419/tagdoc/af_validateRegExp.html for more info.
    Timo

  • Idoc segment field length changes

    Hi friends,,
    I am new to idoc.
    My requirement is in my segment
    i am having 5 fields and also this segment is already realeased one.
    i wnat to change the field length from 10 to 20 . how to do this ?
    actually what i did is
    1. i cancel the release for that segment.
    2. in that field inside the dataelement i changed the field length from 10 to 20.
    3. data elemnt get chaged from 10 to 20 but Export length for that field in Idoc segment still retain the 10 only
    can you plz how to resolve this
    deva

    Hi,
    The way you used is right. ( cancel release or create a new segment )
    After you cancel release, try delete that field, and insert a new one.
    If it isn't valid still,  create a new segment instead.
    Regards
    Sam

  • Getting correct field length when creating formats for delimited flat files

    Using Data Services 3.2 to pull in tsv and Excel source files.
    When creating a new format for each file, DS tries to intelligently set the field size for each column. However, it seems to sample only a portion of the file. The end result is that it often determines too short a length for a field.
    Is there a way to force it to scan an entire file before it sets the field length? Or alternatively, how to get it to at least throw an error instead of silently truncating my data?

    I am not aware of any way to force DS to scan the whole file, or to log a warning when it truncates.  The field sizes DS sets by using a sample of the data is only really to give you a starting point, you need to try and determine the maximum possible lengths preferably from someone who understands the source of the data or through profiling.  But the profiling method will obviously only be based on the data you have at the time of profiling, new data added to the source later could exceed the field lengths.  The way I prefer to handle this is to set all the field lengths to longer than expected, eg. varchar(999) and then use a validation transform immediately after reading the file to check for any fields that exceed the maximum allowed for the target system and send these to an error file/table.

  • How can I restrict field lengths in a field?

    I have a field that I want the user to only enter a 5 character response, not a 4 or 6 character response. Is '?????' field validation the only option?

    There is a LEN function that you can use to validate the entry. It returns the length of the field. You could build a validation rule to ensure the field length is 5 and that anything other than 5 characters returns an error message. You would need to build more specific validation rules if your result needed to be numeric or non-numeric. The LEN function only rerturns the length.
    Good Luck,
    Thom

  • Field level Validation in SAP PI

    Hi All,
    I am integrating with a 3rd Party system (File to Proxy scenario). Source file contains around 30 fields. I was asked to do field level validations for each of this field in PI. Is this a good practice. Do we do field validation in PI Integration development? I think PI should contain more of integration logic than field level validations. Please suggest.
    Also out of all the 30 fields few are numeric, some are text and some are dates. While creating data types do I need to created all as string or based on their nature I need to use integer,date etc? Please suggest which is the best practice.
    Thanks.

    I agree with Rahul.
    Yes we can perform validation in PI (most of the cases we do by request of the Business team).
    But always have a thumb rule for your self.
    1. Check first weather the source system is capable of doing the validation at its end.
    2. If YES make sure the source system does the validations required. (I am sure most of the app would be able to the validation).
    3.If NO then accept the validation process to be done in PI end.
    One Important thing:
    What kind of validation are you taking about? i assume this is field level validation rite?
    and this is a Proxy to file scenario rite.
    I will strongly suggest you to do following things at source and receiver Business systems.
    1.gather a meeting the with the end business teams (source and receiver).
    2.Force them to create data type at their end (sorce and target)with  same data type structure- with same field length even.
    ie, if source first field is integer with maxlen25  corresponding reciver field is also integer with maxlen25, if source has char field then in reciver also its char.
    If you make both the source and reciever business to have same data type at there end, NO VALIDATION would be required to be done in PI
    also in this case you can declare all the data type as STRING in PI and pass the data to receiver system. (which has the same data type as sender).
    Regards,
    Senthilprakash.

  • GL Account Field length

    Hi,
    My client wants to change the account field length in the doc entry. Standard account field is length is 16 or 17 digits. Its length has to be reduced to 10 digits.
    How can i do this ?  Can I do this in the configuration (or) customisation ? If it is customisation what are the tables I need to touch ?
    Awaiting for the reply
    Thanks,
    Krishna

    Use Transaction code OB13 to maintain maiximum length of GL account length as 10 apart from this you can also write validation so that if any gl account with more that 10 digits is entered system gives error.
    Regads,
    Manish Jain
    Assign points if it serves your purpose.

  • Get table control field length

    in table control i have a field with with char length 15  but i have to give a validation if lenght not equal to 6 giv error messgage with out changin the field length of table control
    i used    
                    DESCRIBE FIELD gi_pmpb_bchid-batchid LENGTH ln IN CHARACTER MODE.
                     IF ln <> 6.
                         MESSAGE e013(zc8isms).
                      ELSE.
    but here length is coming as 15 only even if i enter 6 digits in field on TC
    plz help

    DESCRIBE returns the attributes of a data object. Length operators, like STRLEN, on the other hand, return a length of the data content.
    if strlen( <mytable-fieldname> ) gt 6.
    etc...
    or lv_len = strlen( <mytable-fieldname> ).
    if lv_len (of type i) gt 6.
    etc...
    put this in code, press F1 on STRLEN for informative help on finding lengths, whether field or table.

  • Fields Lengths (Mapping)

    Hi,
    My cenario is: POS calls RFC enabled function module from SAP trough EAI.
    So a function module Z* is called. When this function is Tested in SAP with transaction SE37 everything seems to be fine. There are one table returned and all the data is in correct fields.
    But, when this function is called trough EAI data is misaligned accordingly to difference of field lengths. For example ITEMS_OUT (used in my FM) table fields DOC_NUMBER in xml has 20 characters in function module 10, and so on.
    Do you have any idea? Where should be the problem? In mapping or should be a function module problem?
    Example:
    In xml file i get this:
    HEADERS_OUT>
    - <item>
    <DOC_NUMBER>00000007030040000000</DOC_NUMBER>
    <SOLD_TO>Test client Sales</SOLD_TO>
    <NAME1 />
    <NET_VAL_HD>0.000000000</NET_VAL_HD>
    <TAX_AMOUNT>0.000000000</TAX_AMOUNT>
    <BR_VAL_HD>0.000000000</BR_VAL_HD>
    <_FILLER />
    <CURRENCY />
    </item>
    </HEADERS_OUT>
    Regarding the DOC_NUMBER for example. In my RFC i have '0000000703', SOLD_TO = 0040000000; NAME1 = Test client Sales, and in xml is totally misaligned.
    Thanks
    BR

    Hi
    I think there is only 1 solution
    1) you will have to edit the XML structure so as to ristrich the field lengths to that needed by FM . As SAP will simply truncate the value if the length of the field is more than the required.
    The changes can be made in SAP FM also if the altered length is valid as per the SAP data type for that certain field.
    hope this helps
    Regards
    Nikhil

  • Field length change in Web Dynpro Components iView

    Hi,
    We are using SAP MDM Web Dynpro Components - Configuration Manager (NW7.3) to develop the UI. One of the issue while disply field is, Though field maintained in MDM has only 2 charaters UI that displays a full-screen-width field.
    I would like to display actual field length maintained in reposiroy for each field. Is it possible??
    Cheers,
    Rc

    This is closed.
    By mistake Raised Twice....I guess I need break

  • Changing field length of a standard field in standard table VBEP

    Hi,
    Please advice the possibility and the possible repercussions of changing field lengths in a standard table. Table in concern is VBEP.
    Thanks & Rgds,
    Pradeep

    No you cannot change the field length
    thanks
    G. Lakshmipathi

  • Type conflict when calling a function module (field length)

    Dear All,
                I am getting this following error while executing:  Type conflict when calling a function module (field length)
    This is piece of coding i have writern in my action button.
    method SEARCH_MATERIAL .
      data:
            node_mat_input TYPE REF TO  if_wd_context_node,
            node_mat_output TYPE REF TO if_wd_context_node,
            material TYPE BAPIMATDET-MATERIAL,
            itab TYPE TABLE OF BAPIMATDOA.
      node_mat_input = wd_context->get_child_node( 'NODE_MAT_INPUT' ).
      node_mat_output = wd_context->get_child_node( 'NODE_MAT_OUTPUT' ).
      node_mat_input->get_attribute( EXPORTING name = 'MATERIAL'
                                     IMPORTING value = material ).
      CALL FUNCTION 'BAPI_MATERIAL_GET_DETAIL'
        EXPORTING
          material                    = material
        PLANT                       = plant
        VALUATIONAREA               =
        VALUATIONTYPE               =
        MATERIAL_EVG                =
       IMPORTING
         MATERIAL_GENERAL_DATA       = itab
        RETURN                      =
        MATERIALPLANTDATA           =
        MATERIALVALUATIONDATA       =
      node_mat_output->bind_table( itab ).
    endmethod.
    Attributes are:
    Node name = INPUT its structure is BAPIMATDET
    INPUT attributes = MATERIAL of type BAPIMATDET-MATERIAL
    Thanks,
    Gopi.

    Hi Amit,
               I have used service call to fetch records from that bapi..
    The following is the code generated by service call:-
    METHOD execute_bapi_material_get_deta .
    declarations for context navigation
      DATA:
        node_bapi_material_get_de   TYPE REF TO if_wd_context_node,
         node_exporting   TYPE REF TO if_wd_context_node,
         node_material_general_dat   TYPE REF TO if_wd_context_node,
         node_importing   TYPE REF TO if_wd_context_node,
          lri_element    TYPE REF TO if_wd_context_element.
    declarations for fuba parameters
      data:
        stru_c_material_general_dat    TYPE if_componentcontroller=>element_material_general_dat.
      DATA:
        attr_material    TYPE bapimatdet-material,
        attr_plant    TYPE bapimatall-plant.
    get all involved child nodes
      node_bapi_material_get_de = wd_context->get_child_node( `BAPI_MATERIAL_GET_DE` ).
      node_exporting = node_bapi_material_get_de->get_child_node( `EXPORTING` ).
      node_material_general_dat = node_exporting->get_child_node( `MATERIAL_GENERAL_DAT` ).
      node_importing = node_bapi_material_get_de->get_child_node( `IMPORTING` ).
    get input from context
      node_importing->get_attribute(    EXPORTING      name = `MATERIAL`
                                                         IMPORTING      value = attr_material ).
      node_importing->get_attribute(  EXPORTING       name = `PLANT`
                                                              IMPORTING       value = attr_plant ).
    the invocation - errors are always fatal !!!
      CALL FUNCTION 'BAPI_MATERIAL_GET_DETAIL'
        EXPORTING
          material =                        attr_material
          plant =                           attr_plant
    "      valuationarea =                   wd_This->Valuationarea
    "      valuationtype =                   wd_This->Valuationtype
    "      material_Evg =                    wd_This->Material_Evg
        IMPORTING
          material_general_data =           stru_c_material_general_dat
    "      return =                          wd_This->Return
    "      materialplantdata =               wd_This->Materialplantdata
    "      materialvaluationdata =           wd_This->Materialvaluationdat
      node_material_general_dat->bind_structure( stru_c_material_general_dat[] ).
    ENDMETHOD.
                                 but the problem is I  am getting the following error while compiling...
    " stru_c_materialplantdata " is not an internal table - the " OCCOURS n"  specification is missing.
    Thanks,
    Gopi.
    Edited by: Yegalaivan on Nov 18, 2009 8:30 AM

  • How to create an infotype with one of its field length eq 1000.??

    hi ,
    i need to create a infotype where one of the field length is 1000 characters how do i achieve this. if i give more than 255 in the PS structure it will not allow. then how do i get a text field of 1000 chars in the screen ( which is an input field)

    You can use those function calls even inside a PA Infotype.. they just invoke the text ediotr table control.. I gave you the reference of the PD infotype 1002 just for an idea. I don't think you will able to meet your 1000 char reqt without using the text editor.
    ~Suresh

Maybe you are looking for