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

Selection Criteria

Former Member
0 Likes
861

Hi All,

i  have a requirement that i have to fetch records only which are not started with special character i.e. '!'. So could you please do let me know how to write in select statement for this requirement.

Regards,

Jyotsna

7 REPLIES 7
Read only

Former Member
0 Likes
826

Hi Jyotsna,

From which table which fields you have to fetch..

I think you can use the advantage of comparison statements

or you can refer the link below

Comparisons Between Character Strings and Byte Strings (SAP Library - ABAP Programming (BC-ABA))

Regards Ashwin kv

Read only

Former Member
0 Likes
826

Hi,

     Select <fldlst> into table <itab> from (dbtab) where fldname NP '!*'

Read only

0 Likes
826

Hi Somendra,

I'm afraid this is a wrong statement for this requirement.

You cannot use NP in select statement.

Sam

Read only

0 Likes
826

Hi Sam,

     Yes Inplace of NP their will be Not Like as u have used , NP is used in Internal table while reading.

Read only

0 Likes
826

Hi,

Use like this.

SELECT <fields>

       FROM <Table> INTO TABLE <IT Table>

       WHERE <Field> NOT LIKE '!%'.

This will fetch the records which are not started with '!'.

Regards,

Pavan

Read only

Former Member
0 Likes
826

Hi jyotsna,

SELECT *

   FROM xxxx

   into TABLE itab

   WHERE xxxxx NOT LIKE '!%'.

if you have many special characters to exclude,you can use a range table.

data r_xxxxx type range of xxxxx with header line.

r_xxxxx-sign = 'I'.

r_xxxxx-option = 'NP'.

r_xxxxx-low = '!*'.

APPEND r_xxxxx.

r_xxxxx-low = '$*'.

APPEND r_xxxxx.

.......

SELECT *

   FROM xxxx

   INTO TABLE itab

   WHERE xxxxx IN r_xxxxx.

But I don't think it's efficient way to fetch records...Maybe you can filter the data after fetching them with some criteria.

LOOP AT itab.

IF itab-xxxxx NOT IN r_xxxxx.

   DELETE itab.

ENDIF.

....

ENDLOOP.

Thanks,

Sam

Read only

yogendra_bhaskar
Contributor
0 Likes
826

Hi jyotsna,

Use

Select *

  from <db_table>

    into table <int_table>

      where field not like '!%'.

Regards

Yogendra Bhaskar