Skip to Content
author's profile photo Former Member
Former Member

validation urgent.

Hi All,

My requirement is to do validation on a certain field.

Consider,

Field -- ZVARASTO-VARASTO.

Rule-- 1. Field given must be in 5 digit format ( only numbers ).

2. No leading zeros.

I have implemented code for checking 5 digits.

Following is the code.

var = STRLEN( zvarasto-varasto ).

IF var NE 5 .

MESSAGE e003(zmlo_msg).

LEAVE TO SCREEN 100.

ENDIF.

Im not able to proceed ahead with how to check non numeric values and leading zeros

Kindly help with the same.

Thanx in advance,

Amruta.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

6 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Nov 30, 2007 at 08:56 AM

    Hi

    Use the String Compareing commands like CS (contains string) CN (contains not string)

    data: v_str(9) type c value '123456789'.

    if ZVARASTO-VARASTO CN v_str.

    message ' field contains non numeric digits'.

    endif.

    for eliminate leading zeros move it to TYPE I field and can use.

    Regards

    anji

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Nov 30, 2007 at 08:59 AM

    hi Amruta,

    IF ZVARASTO-VARASTO(5) CO '0123456789'.

    • 5 five chars only numbers

    ELSE.

    • 5 five chars not only numbers

    ENDIF.

    IF ZVARASTO-VARASTO(1) EQ '0'.

    • Leading zero

    ELSE.

    • Not leading zero

    ENDIF.

    hope this helps

    ec

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 30, 2007 at 09:00 AM

    parameters: ch(10) type c.

    data: ch1(5) type c.

    data: ty type DD01V-DATATYPE.

    if strlen( ch ) > 5.

    write: 'not perfect'.

    exit.

    endif.

    *deleting leading zeros.

    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

    EXPORTING

    INPUT = ch

    IMPORTING

    OUTPUT = ch1.

    CALL FUNCTION 'NUMERIC_CHECK'

    EXPORTING

    STRING_IN = ch1

    IMPORTING

    STRING_OUT = ch1

    HTYPE = ty.

    .

    if ty = 'NUMC'.

    WRITE:' perfect'.

    else.

    write: 'not perfect'.

    endif.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 30, 2007 at 09:02 AM

    var = STRLEN( zvarasto-varasto ).

    IF var NE 5 .

    MESSAGE e003(zmlo_msg).

    LEAVE TO SCREEN 100.

    endif.

    SHIFT <yourField> LEFT DELETING LEADING '0'.

    if sy-subrc = 0.

    MESSAGE e003(zmlo_msg).

    exit.

    endif.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 30, 2007 at 09:03 AM

    <b>*delete leading zeros.... </b>

    data: str type string.

    str = '00000000000000654654'.

    call function 'CONVERSION_EXIT_ALPHA_OUTPUT'

    exporting

    input = str

    IMPORTING

    OUTPUT = str.

    write:/ str.

    <b>* only 5 digit output</b>

    NUMC is the datatype which allows only digits.

    ex: parameters: str(5) type NUMC.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Nov 30, 2007 at 09:17 AM

    Hi,

    parameters fname(5). " Length five is only allowed

    AT SELECTION-SCREEN ON fname.

    IF fname ca sy-abcde.

    message e000(zz) with 'alphabets'. "alphabets will be tracked

    ENDIF.

    start-of-selection.

    pack fname to fname."Leading zeros will be ignored

    write fname.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.