ABAP CO

 

In ABAP (Advanced Business Application Programming), CO is a string comparison operator for “Contains Only.” It is used to check if a string variable or literal contains only the characters present in another string variable or literal.

How it works:

  • The CO operator performs a case-sensitive comparison, meaning that uppercase and lowercase letters are treated as different characters.
  • Trailing blanks are also taken into account in both operands.
  • If the second operand is an empty string, the result is false unless the first operand is also an empty string.

Example:

ABAP

DATA: text1 TYPE string VALUE ‘Hello World’,

text2 TYPE string VALUE ‘Helo ‘,

result TYPE abap_bool.

result = text1 CO text2. “ result will be false (since ‘w’ is not in text2)

result = ‘Helloworld’ CO ‘oellH’. “ result will be true

result = ‘Hello’ CO ‘Hello’. “ result will be true

result = ‘’ CO ‘’. “ result will be true

result = ‘Hello’ CO ‘’. “ result will be false

Applications:

  1. Validating User Input: You can use CO to validate user input, ensuring that it contains only valid characters from a predefined set.
  2. Filtering Data: It can filter data based on specific character sets, helping to narrow down results in a dataset.
  3. Creating Conditional Expressions: Combine CO with other logical operators (AND, OR, NOT) to create complex conditional expressions that check multiple conditions simultaneously.

Key Points:

  • For case-insensitive comparison, convert both operands to uppercase or lowercase before using CO.
  • You can use the sy-fdpos system variable to find the position of the first character in the first operand that is not present in the second operand (if the result is false).

SAP ABAP Training Demo Day 1 Video:

You can find more information about SAP ABAP in this SAP ABAP Link

Conclusion:

Unogeeks is the №1 IT Training Institute for SAP ABAP Training. Anyone Disagree? Please drop in a comment

You can check out our other latest blogs on SAP ABAP here — SAP ABAP Blogs

You can check out our Best In Class SAP ABAP Details here — SAP ABAP Training

Follow & Connect with us:

— — — — — — — — — — — -

For Training inquiries:

Call/Whatsapp: +91 73960 33555

Mail us at: info@unogeeks.com

Our Website ➜ https://unogeeks.com

Follow us:

Instagram: https://www.instagram.com/unogeeks

Facebook: https://www.facebook.com/UnogeeksSoftwareTrainingInstitute

Twitter: https://twitter.com/unogeeks

#unogeeks #training #ittraining #unogeekstraining

Comments

Popular posts from this blog

Success Fac

SAP SF Employee Central

SAP Fiori SD