‎2008 Nov 19 9:22 AM
Hi everyone,
Is there any function to ignore case of two alphanumeric strings while their comparison.For ex.
string1: M23456n
string2:m23456n
When i compare these two strings,i want them to be equal,i.e. the case to be ignored.
Please help.
Thanks in advance,
Meena.
‎2008 Nov 19 9:27 AM
Hi
Try
DATA : VAL1 TYPE STRING VALUE 'M23456n',
VAL2 type string value 'm23456n'.
TRANSLATE VAL1 TO UPPER CASE.
TRANSLATE VAL2 TO UPPER CASE.
IF VAL1 = VAL2.
WRITE 'Same'.
ENDIF.Regards
‎2008 Nov 19 9:23 AM
you have to use temp variables for that. copy the values to the tempory variables, translate them to uppercase and comapre them.
data:
s1 type string,
s2 type string,
t1 type string,
t2 type string.
start-of-selection.
s1 = `M23456n`.
s2 = `m23456n`.
t1 = s1.
t2 = s2.
translate t1 to upper case.
translate t2 to upper case.
if t1 = t2.
perform do_something.
endif.
‎2008 Nov 19 9:25 AM
Use the two strings one by one in the function module 2054_TRANSLATE_2_UPPERCASE and store them in say str1 and str2
then compare them
‎2008 Nov 19 9:27 AM
Hi
Try
DATA : VAL1 TYPE STRING VALUE 'M23456n',
VAL2 type string value 'm23456n'.
TRANSLATE VAL1 TO UPPER CASE.
TRANSLATE VAL2 TO UPPER CASE.
IF VAL1 = VAL2.
WRITE 'Same'.
ENDIF.Regards
‎2008 Nov 19 9:33 AM
Hi Meena,
Go for the following code snippet.
DATA: a TYPE string VALUE 'M23456n',
b TYPE string VALUE 'm23456N'.
IF a CS b.
WRITE 'true'.
ENDIF.
For detailed info refer this.
NS (contains No String)
The logical expression
<f1> NS <f2>
is true if <f1> does not contain the string <f2>. Trailing spaces are ignored and the comparison is not case-sensitive. If the comparison is true, the system field SY-FDPOS contains the length of <f1>. If it is false, SY-FDPOS contains the offset of <f2> in <f1> .
Thanks
NItesh
‎2008 Nov 19 9:37 AM
Hi all,
Scenario is like this:
I have an interface,XI team sends an idoc.This idoc name is a sring. I have my own idoc ,so we have to compare the two idocs,i.e. the strings are suppose to be passed at run time.
‎2008 Nov 19 11:37 AM
Thanks a lot guys....but TRANSLATE helped me and i got the desired result.