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

Comparison of String

Hi,

I need to compare 2 string variables want to now which is the best method

str1 = str 2.

Or there is some other better method available.

It should compare every character of the string and if it matching then only it need to allow further processing.

Thanks in Advance,

Irfan Hussain

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 Jan 09, 2007 at 03:47 AM

    use str1 CO str2 statement or use CS operator

    Message was edited by:

    Kalpanashri Rajendran

    Add a comment
    10|10000 characters needed characters exceeded

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

    you can use your method or CO in if condition if str1 and str2 are of same length.

    other wise if you want to check some partial part of the string use CS.

    regards

    shiba dutta

    Add a comment
    10|10000 characters needed characters exceeded

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

    Hi,

    You can use = operator to compare strings..

    Example

    -


    DATA: V_STRING1 TYPE STRING.

    DATA: V_STRING2 TYPE STRING.

    V_STRING1 = 'ABC'.

    V_STRING2 = 'ABC'.

    IF V_STRING1 = V_STRING2.

    WRITE: / 'TRUE'.

    ELSE.

    WRITE: / 'FALSE'.

    ENDIF.

    Thanks,

    Naren

    Add a comment
    10|10000 characters needed characters exceeded

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

    Hi ,

    I think the method you are using is better , check this in an if condition , if the condition is satisfied the continue with processing else exit .

    Regards

    Arun

    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.