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: 

ABAP/4 Open SQL statement with WHERE ... LIKE and pattern too long

Former Member

Dear All,

I am getting an error "ABAP/4 Open SQL statement with WHERE ... LIKE and pattern too long" while executing the following statement:

CLEAR LS_RANGE.

LS_RANGE-SIGN = 'I'

+LS_RANGE-OPTION = 'CP' +

LS_RANGE-LOW = 'S_ADMI_FCD'

LS_RANGE-HIGH = 'S_ADMI_FCD'

COLLECT LS_RANGE INTO LT_RANGE.

SELECT *

FROM UST12

INTO CORRESPONDING FIELDS OF TABLE LT_OBJECT_VALUES

WHERE FIELD IN LT_RANGE

AND AKTPS = 'A'.

For options like BT(Between), EQ(Equal) in range table, this above query is executing without dump. But for option CP, it simply dumps & in dump what i found is, it is concatenating the value in low & high.

Does anyone have any idea regarding open sql using range tables.

Thanks,

Bhupinder

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Fist - clear LS_RANGE-HIGH when you use CP. It makes no sense with it.

Rob

6 REPLIES 6

Former Member
0 Kudos

HI,

Try fetching all the data in internal table and then delete from internal table using pattern option as it seems to be problem in fetching data from database comparing pattern.

Regds,

Anil

0 Kudos

Hi Anil,

Thanks for quick reply!

its easy to fetch the data into internal table first & then delete all data who field doesn't match to the value given in range table. But this will lead to big performance issue. may be with CP (compare pattern) range table only works with low value.

BR, Bhupinder

Former Member
0 Kudos

Hi, in your range the low and high are the same, so why no WHERE FIELD = :WA_XX. I am not sure but I think the IN will not work in native SQL. I never used it. Succes

0 Kudos

Hi Rob,

There is a requirement in which i need to fetch the data from DB using range table. it dumps only when i am providing the values for both low & high but in case empty value for HIGH, SQL is executing successfully.

BR, Bhupinder

Former Member
0 Kudos

Hi,

I commented as follows:

If LS_RANGE-HIGH is empty, you can use EQ, NE, GT, LE, LT,CP, and NP. These operators are the same as those that are used for logical expressions. Yet operators CP and NP do not have the full functional scope they have in normal logical expressions. They are only allowed if wildcards ( '*' or '+' ) are used in the input fields. If wildcards are entered on the selection screen, the system automatically uses the operator CP.

If LS_RANGE-HIGH is filled, you can use BT (BeTween) and NB (Not Between). These operators correspond to BETWEEN and NOT BETWEEN that you use when you check if a field belongs to a range. You cannot use wildcard characters.

You can try:

CLEAR LS_RANGE.

LS_RANGE-SIGN = 'I'.

  • +LS_RANGE-OPTION = 'CP' +

LS_RANGE-LOW = 'S_ADMI_FCD'.

LS_RANGE-HIGH = 'S_ADMI_FCD'.

FIND '*' IN LS_RANGE.

IF sy-subrc = 0.

LS_RANGE-OPTION = 'CP'.

ELSE.

LS_RANGE-OPTION = 'EQ'.

ENDIF.

COLLECT LS_RANGE INTO LT_RANGE.

SELECT *

FROM UST12

INTO CORRESPONDING FIELDS OF TABLE LT_OBJECT_VALUES

WHERE FIELD IN LT_RANGE

AND AKTPS = 'A'.

If you use wildcards the LS_RANGE length should not exceed 10 characters.

Hope this information is help to you.

Regards,

José

Former Member
0 Kudos

Fist - clear LS_RANGE-HIGH when you use CP. It makes no sense with it.

Rob