CO- Contains Only
-------------------------------------------------------------------------------------------------------------------------
* contains only: true, if operand1 only contains characters from operand2.
* it is case-sensitive and trailing blanks are respected in both operands.
*IF the comparison IS false, sy-fdpos contains the offset
* of the first character in operand1 that is not contained in operand2.
* IF the comparison IS true, sy-fdpos contains the length of operand1.
DATA res TYPE string VALUE 'SAP ABAP PROGRAM'.
IF 'GRA' CO res.
WRITE :/ 'Success', sy-fdpos. " Success -> sy-fdpos = strlen ( 'GRA' )
ELSE.
WRITE :/ 'Failure', sy-fdpos.
ENDIF.
ULINE.
IF 'GRAPX' CO res.
WRITE :/ 'Success', sy-fdpos.
ELSE.
WRITE :/ 'Failure', sy-fdpos. " Failure-> sy-fdpos = offset position of X
ENDIF.
-----------------------------------------------------------------------------------------------------------------------
Output:
-----------------------------------------------------------------------------------------------------------------------
CN Contains Not Only
-----------------------------------------------------------------------------------------------------------------------
* contains not only->
* If true, sy-fdpos contains the offset of the first
* character in operand1 that is not contained in operand2.
* If false, sy-fdpos contains the length of operand1.
DATA res TYPE string VALUE 'SAP ABAP PROGRAM'.
IF 'GRA' CN res.
WRITE :/ 'Success', sy-fdpos.
ELSE.
WRITE :/ 'Failure', sy-fdpos. " Failure-> sy-fdpos = strlen ( 'GRA' )
ENDIF.
ULINE.
IF 'GRAPX' CN res.
WRITE :/ 'Success', sy-fdpos. " Success -> sy-fdpos = offset position of X
ELSE.
WRITE :/ 'Failure', sy-fdpos.
ENDIF.
-----------------------------------------------------------------------------------------------------------------------
Output:
-----------------------------------------------------------------------------------------------------------------------
CA- Contains Any
-----------------------------------------------------------------------------------------------------------------------
* contains any->
* True, if operand1 contains at least one character from operand2.
* then sy-fdpos contains the offset of the first character in operand1
* that is also contained in operand2
* If the comparison is false, sy-fdpos contains the length of operand1.
DATA res TYPE string VALUE 'SAP ABAP PROGRAM'.
IF 'ZYGRA' CA res.
WRITE :/ 'Success:', sy-fdpos. " Success -> sy-fdpos = offset OF 'G'
ELSE.
WRITE :/ 'Failure:', sy-fdpos.
ENDIF.
ULINE.
IF 'YX' CA res.
WRITE :/ 'Success:', sy-fdpos.
ELSE.
WRITE :/ 'Failure:', sy-fdpos. " Failure-> sy-fdpos = strlen ( 'GRA' )
ENDIF.
-----------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------
NA- Contains Not Any
-----------------------------------------------------------------------------------------------------------------------
* contains not any->
* True, if operand1 does not contain any characters from operand2.
* If the comparison is false,sy-fdpos contains the offset of the first
* character in operand1 that is also contained in operand2.
* If the comparison is true, sy-fdpos contains the length of operand1.
DATA res TYPE string VALUE 'SAP ABAP PROGRAM'.
IF 'ZYGRA' NA res.
WRITE :/ 'Success:', sy-fdpos.
ELSE.
WRITE :/ 'Failure:', sy-fdpos. " Failure-> sy-fdpos = offset of 'G'
ENDIF.
ULINE.
IF 'YXZ' NA res.
WRITE :/ 'Success:', sy-fdpos. "Success -> sy-fdpos = STRLEN ( 'YXZ' )
ELSE.
WRITE :/ 'Failure:', sy-fdpos.
ENDIF.
-----------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------
CS- Contains String
-----------------------------------------------------------------------------------------------------------------------
* contains String->
* True, if operand1 contains the string in operand2 and not case sensitive
* If the comparison is false,sy-fdpos contains the length of operand1
* If the comparison is true, sy-fdpos contains the offset of the operand2 in operand1
DATA res TYPE string VALUE 'SAP ABAP PROGRAM'.
IF RES CS 'PrO'.
WRITE :/ 'Success:', sy-fdpos. "Success -> sy-fdpos = Offset of 'P' in res
ELSE.
WRITE :/ 'Failure:', sy-fdpos.
ENDIF.
ULINE.
IF RES CS 'YXZ'.
WRITE :/ 'Success:', sy-fdpos.
ELSE.
WRITE :/ 'Failure:', sy-fdpos. " Failure-> sy-fdpos = strlen ( res )
ENDIF.
-----------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------
NS- Contains No String
-----------------------------------------------------------------------------------------------------------------------
* contains no string->
* True, If operand1 does not contains the string operand and not case sensitive
* If the comparison is TRUE,sy-fdpos contains the length of operand1
* If the comparison is FALSE, sy-fdpos contains the offset of the operand2 in operand1
DATA res TYPE string VALUE 'SAP ABAP PROGRAM'.
IF res NS 'PrO'.
WRITE :/ 'Success:', sy-fdpos.
ELSE.
WRITE :/ 'Failure:', sy-fdpos. " Failure-> sy-fdpos = offset of 'P' in res
ENDIF.
ULINE.
IF res NS 'YXZ'.
WRITE :/ 'Success:', sy-fdpos. "Success -> lengeth of ( res )
ELSE.
WRITE :/ 'Failure:', sy-fdpos.
ENDIF.
-----------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------
CP- Contains Pattern
-----------------------------------------------------------------------------------------------------------------------
* contains Pattern->
* True, If operand1 contains pattern operand2 and not case sensitive
* If the comparison is TRUE,sy-fdpos contains the offset of operand2 in operand
* If the comparison is FALSE, sy-fdpos contains the length of operand1
DATA res TYPE string VALUE 'SAP ABAP PROGRAM'.
IF res CP '*Ro*'.
WRITE :/ 'Success:', sy-fdpos. "Success -> sy-fdpos = Offset of 'R' in res
ELSE.
WRITE :/ 'Failure:', sy-fdpos.
ENDIF.
ULINE.
IF res CP '*XY*'.
WRITE :/ 'Success:', sy-fdpos.
ELSE.
WRITE :/ 'Failure:', sy-fdpos. " Failure-> sy-fdpos = length of ( res )
ENDIF.
-----------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------
NP- Contains No Pattern
-----------------------------------------------------------------------------------------------------------------------
* contains no Pattern->
* True, If operand1 does not contains pattern operand2 and not case sensitive
* If the comparison is TRUE,sy-fdpos contains the length of operand1
* If the comparison is FALSE, sy-fdpos contains the offset of operand2 in operand1
DATA res TYPE string VALUE 'SAP ABAP PROGRAM'.
IF res NP '*Ro*'.
WRITE :/ 'Success:', sy-fdpos.
ELSE.
WRITE :/ 'Failure:', sy-fdpos. " Failure-> sy-fdpos = Offset of 'R' in res
ENDIF.
ULINE.
IF res NP '*XY*'.
WRITE :/ 'Success:', sy-fdpos. "Success -> sy-fdpos = length of ( res )
ELSE.
WRITE :/ 'Failure:', sy-fdpos.
ENDIF.
-----------------------------------------------------------------------------------------------------------------------