Application Development 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: 

use fo wild card in IF statement.

Former Member
0 Kudos

Hi experts ,

I wanna use wild cards to check a pattern in an IF statement.

What is the syntax for that.

my code is as follows:

IF I_TEMP_TAB-ELEMENT = 'Description'

>>>> AND I_TEMP_TAB-VALUE = 'SCHEDULE+'

>>>> OR I_TEMP_TAB-VALUE = 'PART+'.

i wanna check the occurence of "schedule........" and "part....." in i_temp_tab-value.

urgent pls reply?

3 REPLIES 3

Former Member
0 Kudos

As per my knowledge U can not use wildcard char's............ in conditions.

santhosh_patil
Contributor
0 Kudos

Hi,

use Relational Operators ,,,

check this out..

data: char(90) type c,

char1(20) type c.

char = 'schedule line data and part of the data -- for test'.

if char cp 'schedule*'.

write 'yes schedule present'.

endif.

if char cp 'part'.

write : / 'yes part present'.

endif.

  • ---- any characters

+ --- one characters.

Possible Expressions:

CO (Contains Only):

CN (Contains Not only):

CA (Contains Any):

NA (contains Not Any):

CS (Contains String):

<b>CP (Contains Pattern):</b>

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.

-


patil

Former Member
0 Kudos

Example of general comparision and finding the data .

operator

Meaning

CO

Contains only

CN

Contains not only

CA

Contains any

NA

Contains not any

CS

Contains string

NS

Contains no string

CP

Suits pattern

NP

Does not suit pattern

DATA: f1(5) TYPE c VALUE <f1>,

f2(5) TYPE c VALUE <f2>.

IF f1 <operator> f2.

WRITE: / 'Compare true, SY-FDPOS=', sy-fdpos.

ELSE.

WRITE: / 'Compare false, SY-FDPOS=', sy-fdpos.

ENDIF.

PLease go thorugh this link ... it gives with examples

<a href="http://">http://help.sap.com/saphelp_nw2004s/helpdata/en/fc/eb3516358411d1829f0000e829fbfe/content.htm</a>

reward points if it is usefull ..

Girish