‎2007 May 29 5:24 AM
I need to compare two fields(vpsta and pstat) in mara table and have to get the differences.
For example if vpsta = abcdzx and pstat = abcd then i need the output as zx.
I got the answer when i use the concept of getting offset values. but i need the solution by using string operations like CO, CS,CA.... is it possible?
Thankx in Advance,
Karthikeyan
‎2007 May 29 5:27 AM
Hi,
I think Offset is the best solution for this requirement.
Why are you looking for string operations ?
Best regards,
Prashant
‎2007 May 29 5:27 AM
Hi,
I think Offset is the best solution for this requirement.
Why are you looking for string operations ?
Best regards,
Prashant
‎2007 May 29 5:30 AM
Hi Prashant ,
I would like to know whether any options available other than this
Regards
Karthikeyan
‎2007 May 29 5:28 AM
try this...
data : len type i .
if vpsta CS pstat.
len = strlen(pstat).
clear vpsta+sy-fdpos(len).
write : vpsta.
endif.
‎2007 May 29 5:32 AM
Hi Karthikeyan ,
You can use the operation CP (Contains Pattern).
Regards
Arun
‎2007 May 29 5:35 AM
please go through this link for string operations ....
<a href="http://">http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3357358411d1829f0000e829fbfe/content.htm</a>
Girish
‎2007 May 29 5:38 AM
Hi,
Plesae refer to the below 2 options consider sy-fdpos value.
c1 contains only characters from the string c2.
If c1 or c2 is of type C, the comparison takes into
account the full length of the field, including blanks at
the end.
comparison.
If c1 is of type STRING and empty, the result of the
comparison is always positive.
If c2 is of type STRING and empty, the result of the
comparison is always negative, unless c1 is also an empty
string.
If the result of the comparison is negative, the field
SY-FDPOS
contains the offset of the first character in c1 which is
not
also included in c2.
If the result of the comparison is positive, the system
field SY-FDPOS contains the length of c1.
The comparison is case-sensitive.
Examples:
'ABCDE' CO 'XYZ' is false; SY-FDPOS = 0.
'ABCDE' CO 'AB' is false; SY-FDPOS = 2.
'ABCDE' CO 'ABCDE' is true; SY-FDPOS = 5.
********************************************************************
CP (Contains Pattern):
The complete string c1 matches the pattern c2 (c1 "matches"
c2).
The pattern c2 can contain ordinary characters and
wildcards.
'*' stands for any character string and '+' denotes any
character.
If the result of the comparison is positive, the system
field SY-FDPOS contains the offset of the first character
of c2 in c1. The wildcard character '*' at the beginning of
the pattern c2 is ignored when determining the value of
SY-FDPOS.
If the result of the comparison is negative, the system
field SY-FDPOS contains the length of c1.
Examples:
'ABCDE' CP 'CD' is true; SY-FDPOS = 2.
'ABCDE' CP '*CD' is false; SY-FDPOS = 5.
'ABCDE' CP '+CD' is true; SY-FDPOS = 0.
'ABCDE' CP '+CD*' is false; SY-FDPOS = 5.
'ABCDE' CP 'BD*' is true; SY-FDPOS = 1.
The character '#' has a special meaning. It serves as an
escape symbol and indicates that the very next character
should be compared "exactly".
This allows you to search for:
- characters in upper or lower case
e.g.: c1 CP '#A#b'
- the wildcard characters '*', '+' themselves
e.g.: c1 CP '#' or c1 CP '#+*'
- the escape symbol itself
e.g.: c1 CP '##'
- blanks at the end of c1
e.g.: c1 CP '*# '
If c2 does not contain the wildcard character '*', the
shorter field is padded with "soft blanks" to bring it up
to the length of the longer field.
Examples:
'ABC' CP 'ABC ' is true,
'ABC ' CP 'ABC' is true,
but
'ABC' CP 'ABC+' is false,
'ABC' CP 'ABC# ' is false,
because a "soft blank" is neither any character ('+') nor a
"real" blank ('# ').
The escape symbol does not affect the length of f2 ('A#a#B'
still has the length 3).
The comparison is not case-sensitive.
Regards,
IFF
Note: Reward Points to Suitable Answers.
‎2007 May 29 8:08 AM
Hi,
data : len type i .
if vpsta CS pstat.
len = strlen(pstat).
clear vpsta+sy-fdpos(len).
write : vpsta.
endif.
when i use the above coding...
if vpsta = kvelszx and pstat = kvels
here i got the correct output as zx
but if vpsta = kvezxls and pstat = kvels
here i could not get the answer as zx..
give me a solution for this...
Thanks in advance
Navaneeth