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

Verify SSN in the string

Hi ,

I have a requirement while reading the input file.

Input file is mixed up with several header records and data records

Every data record has SSN starting at fixed position.

So we need to identify the SSN in the data record and store that entire record and skip other records.

SSN format is xxx-xx-xxxx . All are numbers .

I think there might be easier to way to compare and identify this format.

Could anyone suggest the best way to do these.(May be comparing patterns,some string operation etc).Also i need to check all the 'X' are numbers.

Thanks for the help.

Regards

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Aug 12, 2009 at 09:53 PM

    Hi Kumar,

    First Grab those SSN number in a variable of type CHAR11 say var_ssn.

    Then if var_ssn+4(1) = '-'

    and var_ssn+7(1) = '-'

    and var_ssn+0(3) CO '1234567890'

    and var_ssn+5(2) CO '1234567890'

    and var_ssn+8(4) CO '1234567890'.

    Then it contains SSN number and is confirmed to be a data record.

    endif.

    Hope this helps!

    Regards,

    Vimal.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 13, 2009 at 08:52 PM

    Or you can use FM BCA_US_VALIDATE_SSN

    Rob

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 12, 2009 at 09:28 PM

    >

    > Every data record has SSN starting at fixed position.

    > So we need to identify the SSN in the data record and store that entire record and skip other records.

    If the SSN is at a fixed position, then that position identifies it.

    Rob

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 13, 2009 at 01:07 AM

    Try this code by cut & paste into a test program and try

    report zars
      no standard page heading line-size 255.
    parameters : ssn(15) type c.
    data matcher type ref to cl_abap_matcher.
    matcher = cl_abap_matcher=>create(
                 pattern = `^d{3}-d{2}-d{4}$`
                 ignore_case = 'X'
                 text = ssn ).
    
    if matcher->match( ) is initial.
      message 'Invalid ssn Format' type 'I'.
    else.
      message 'Valid ssn format' type 'I'.
    endif.
    

    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.