Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Logical Expression (Rel Operators)

Former Member
0 Likes
1,717

Hi,

Can any Please provide the more Detailed information and

Example Programs on Logical Expressions Operators( CO, CA, CN ,NA .... )

Regards,

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,277

hi,

*Contains any (ca) case sensitive *


		If u2018SAPu2019 ca u2018ABAP/4u2019.
			Write:/ u2018Trueu2019.
		Else.
			Write:/ u2018Falseu2019.
		Endif.
			Output	True

Contains only (co) case sensitive


		
		If u2018SAPu2019 co u2018ABAP/4u2019.
			Write:/ u2018Trueu2019.
		Else.
			Write:/ u2018Falseu2019.
		Endif.
			  Output  False

Contains string (cs) not case sensitive


		If u2018ABAP/4u2019 cs u2018Abu2019.
			Write:/ u2018Trueu2019.
		Else.
			Write:/ u2018Falseu2019.
		Endif.

			Output True

Contains pattern (cp) not case sensitive


		If u2018ABAP/4u2019 cp u2018*aP++u2019.
			Write:/ u2018Trueu2019.
		Else.
			Write:/ u2018Falseu2019.
		Endif.
			Output True

Regards,

Santosh

11 REPLIES 11
Read only

Former Member
0 Likes
1,277
Read only

Former Member
0 Likes
1,278

hi,

*Contains any (ca) case sensitive *


		If u2018SAPu2019 ca u2018ABAP/4u2019.
			Write:/ u2018Trueu2019.
		Else.
			Write:/ u2018Falseu2019.
		Endif.
			Output	True

Contains only (co) case sensitive


		
		If u2018SAPu2019 co u2018ABAP/4u2019.
			Write:/ u2018Trueu2019.
		Else.
			Write:/ u2018Falseu2019.
		Endif.
			  Output  False

Contains string (cs) not case sensitive


		If u2018ABAP/4u2019 cs u2018Abu2019.
			Write:/ u2018Trueu2019.
		Else.
			Write:/ u2018Falseu2019.
		Endif.

			Output True

Contains pattern (cp) not case sensitive


		If u2018ABAP/4u2019 cp u2018*aP++u2019.
			Write:/ u2018Trueu2019.
		Else.
			Write:/ u2018Falseu2019.
		Endif.
			Output True

Regards,

Santosh

Read only

Former Member
0 Likes
1,277
Read only

Former Member
0 Likes
1,277

This message was moderated.

Read only

Former Member
Read only

Former Member
0 Likes
1,277

hi,

Please refer to this link.

[http://help.sap.com/saphelp_nw70/helpdata/en/fc/eb3516358411d1829f0000e829fbfe/content.htm]

Hope this will help.

Regards

Sumit Agarwal

Read only

bpawanchand
Active Contributor
Read only

Former Member
0 Likes
1,277

thanku all

actually i have one string data object

my requirement is

if it contains only ',' s i need to put in differnt count.

if it contains any values other than ',' s i need to put in differnt count.

so i will try .

Read only

Former Member
0 Likes
1,277

Hi,

Logical expressions

A logical expression compares the value in one field with the value in another field. Although the most common logical expressions compare the contents of two numeric fields, string fields can also be compared. It is important to understand (and remember) the different types of logical expression for strings as they can make it much easier to work within the string processing model.

A logical expression would be:

if logical expression.

code goes here

endif.

There are 8 relational operators for strings

CO - contains

Use this to test if field a contains field b. For example:

CUSNM = 'Mrs. Johnson'

TEST = 'Mrs.'

CUSNM CO TEST returns a true value.

Note:Test that CUSNM contains a value. If the field is blank ABAP returns a false true.

if ( p_matnr co ' 0123456789' ).

shift p_matnr right deleting trailing ' '.

overlay p_matnr with '00000000000000000'.

else.

shift p_matnr left deleting leading ' '.

endif.

CN - does not contain

Inverse of contains

CA - contains any

NA - contains none

Inverse of contains any

CS - contains string

NS - does not contain string

Inverse of contains string

CP - contains pattern

Allow you do do some rudimentary pattern matching. Use "" to match any string and "+" to match a single character. "#" is used as the escape character, allowing you to match "","+" or "#" itself. The comparison is not case-sensitive.

CN - does not contain pattern

Inverse of contains pattern

Regards,

Sravanthi

Read only

Former Member
0 Likes
1,277

Hi,

The one and only one SAP HELP: Here's the link->

http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3516358411d1829f0000e829fbfe/content.htm

and

http://help.sap.com/saphelp_46c/helpdata/en/fc/eb3523358411d1829f0000e829fbfe/frameset.htm

http://www.abap2java.com/String_Comparison_Operator

Regards

Harsh

Edited by: Harsh Dave on Jul 8, 2008 7:02 PM

Edited by: Harsh Dave on Jul 8, 2008 7:05 PM