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: 

Comparison operator in select query

Former Member
0 Kudos

Hi,

 

I am retrieving USOBJ from AEOI table.

* CONCATENATE '%' '000000010010553' '%' INTO va_usobj.

* r-sign = 'I'.

* r-option = 'CP'.

* r-low = '000000000010010553*'.

* APPEND r.

SELECT * FROM aeoi

   INTO TABLE gt_aeoi

  WHERE usobj LIKE va_usobj.

IF sy-subrc EQ 0.

  1. ENDIF.

I have tried out with CP, by passing range , LIKE . None is working.

Since large no of entries are existing in AEOI.

we cant select all the entries from table and again looping the table

will create performance issue.

Please let me know any other possibility if exist.

Thanks.

Best Regards,

Mallesh

11 REPLIES 11

former_member196593
Participant
0 Kudos

SELECT * FROM AEOI INTO TABLE GT_AE0I WHERE usobj  LIKE '000000010010553%'.-->this is importnt

IF sy-subrc = 0.

    LOOP  AT GT_AEOI INTO GS_AEOI.

----whatvr u whant here u can.

    ENDLOOP.

Regards

Tk Srithar.

Former Member
0 Kudos

with ranges

* r-sign = 'I'.

* r-option = 'CP'.

* r-low = '000000000010010553*'.

* APPEND r.

that you have given ...it is working for me.

may be precedng zeros have a problem.

can you try '*10010553*'    something like this.....

Former Member
0 Kudos

Hi ,

Below code working Fine using "LIKE " , can you try below code  just as a reference .

TABLES : AEOI.

TYPES BEGIN OF TY_AEOI,

     AENNR LIKE AEOI-AENNR,

     AETYP LIKE AEOI-AETYP,

     USOBJ LIKE AEOI-USOBJ,

END OF   TY_AEOI .

DATA: ITAB TYPE STANDARD TABLE OF TY_AEOI INITIAL SIZE 0,

       WA TYPE TY_AEOI .

PARAMETERS srch_str TYPE c LENGTH 40.

CONCATENATE  srch_str'%' INTO srch_str.

BREAK-POINT.

SELECT AENNR AETYP USOBJ INTO CORRESPONDING FIELDS OF TABLE ITAB FROM AEOI

   WHERE USOBJ LIKE srch_str.

   LOOP AT ITAB INTO WA .

     ENDLOOP .

Regards

SRM

Former Member
0 Kudos

Hi,

The operator LIKE should work.

When you are using LIKE statement you are concatenating only 7 zeros whereas when you are giving in RANGES you are giving more than 7 zeros.

Make sure of the no of the zeros, then LIKE and RANGES and CP should work.

Hope this helps.

Thanks,

Tooshar Bendale

uppu_narayan
Active Participant
0 Kudos

i have tried your code using like.......it working as expected.......try giving space between quotes........

my suggestion is try using either "IN" or "FOR ALL ENTRIES" and instead of range table try using select option as shown below.......

SELECT-OPTIONS r FOR ls_aeoi-usobj.

SELECT * FROM aeoi

    INTO TABLE gt_aeoi

   WHERE usobj IN r.

IF sy-subrc EQ 0.

             "print details............

  1. ENDIF.

Former Member
0 Kudos

Hi All,

Many Thanks for reply.

Sorry. Its not parameter.

USOBJ is select-option.

For ex: 10010563 to 10010569  is passed in selection screen select option

I need all the below records.

00000000001001056301021

00000000001001056301024

000000000010010563

...

....

0 Kudos

Hi mallesh,

     use the following query

     SELECT * FROM aeoi INTO TABLE gt_aeoi  WHERE usobj IN <selectoption_name>.

it will solve your problem...

thanks & regards,

narayan

0 Kudos

Hi Narayan,

If i pass  10010563 ( select option ) to select query.

I will get only 000000000010010563.

But I need 

00000000001001056301021

00000000001001056301024 also.

0 Kudos

Hi mallesh,

         enter 10010563* as input in the select option and the query remains the same as below

     SELECT * FROM aeoi INTO TABLE gt_aeoi  WHERE usobj IN <selectoption_name>.

i have tried on different table this works absolutely correct............................

thanks & regards,

narayan

0 Kudos

Hi Mallesh,

I second Uppu's reply.

It should work if Select Options is declared with same type as table field.

SELECT-OPTIONS s_usobj FOR aeoi-usobj.

Regards,

Nisha Vengal.

Former Member
0 Kudos

Check this Now ..

TABLES : AEOI.

TYPES BEGIN OF TY_AEOI,

     AENNR LIKE AEOI-AENNR,

     AETYP LIKE AEOI-AETYP,

     USOBJ LIKE AEOI-USOBJ,

END OF   TY_AEOI .

DATA: ITAB TYPE STANDARD TABLE OF TY_AEOI INITIAL SIZE 0,

       WA TYPE TY_AEOI .

DATA : TEMP TYPE AEOI-USOBJ ,

        TEMP1 TYPE AEOI-USOBJ .

DATA: TEXT TYPE STRING,

       MOFF TYPE I,

       MLEN TYPE I,

       S1   TYPE STRING,

       S2   TYPE STRING.

SELECT-OPTIONS : SRCH_STR FOR AEOI-USOBJ.

*BREAK-POINT.

IF SRCH_STR-LOW IS NOT INITIAL .

   FIND REGEX `[A-Z]{1}`

       IN SRCH_STR-LOW

       IGNORING CASE

       MATCH OFFSET MOFF

       MATCH LENGTH MLEN

       SUBMATCHES S1 S2.

   IF SY-SUBRC EQ '0'.

     TEMP = SRCH_STR-LOW .

     CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'

       EXPORTING

         INPUT  = TEMP

       IMPORTING

         OUTPUT = TEMP.

   ELSE.

     TEMP = SRCH_STR-LOW .

   ENDIF.

   CONCATENATE '%' TEMP '%' INTO TEMP.

ELSE.

   TEMP = SPACE.

ENDIF.

IF SRCH_STR-HIGH IS NOT INITIAL .

   FIND REGEX `[A-Z]{1}`

       IN SRCH_STR-HIGH

       IGNORING CASE

       MATCH OFFSET MOFF

       MATCH LENGTH MLEN

       SUBMATCHES S1 S2.

   IF SY-SUBRC EQ '0'.

     TEMP1 = SRCH_STR-HIGH .

     CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'

       EXPORTING

         INPUT  = TEMP1

       IMPORTING

         OUTPUT = TEMP1.

   ELSE.

     TEMP1 = SRCH_STR-HIGH .

   ENDIF.

   CONCATENATE '%' TEMP1 '%' INTO  TEMP1.

ELSE.

   TEMP1 = SPACE.

ENDIF.

REFRESH SRCH_STR .

CLEAR   SRCH_STR .

SRCH_STR-SIGN = 'I'.

SRCH_STR-OPTION = 'BT' .

SRCH_STR-LOW = TEMP    .

SRCH_STR-HIGH = TEMP1  .

APPEND SRCH_STR.

IF SRCH_STR-LOW IS NOT INITIAL AND SRCH_STR-HIGH IS NOT INITIAL.

   IF SRCH_STR-LOW NE SRCH_STR-HIGH .

     SELECT AENNR AETYP USOBJ INTO CORRESPONDING FIELDS OF TABLE ITAB FROM AEOI

       WHERE USOBJ BETWEEN  SRCH_STR-LOW AND SRCH_STR-HIGH ." srch_str.

   ELSE.

      SELECT AENNR AETYP USOBJ INTO CORRESPONDING FIELDS OF TABLE ITAB FROM AEOI

         WHERE USOBJ LIKE SRCH_STR-LOW ." srch_str.

   ENDIF.

ELSEIF SRCH_STR-LOW IS INITIAL .

   SELECT AENNR AETYP USOBJ INTO CORRESPONDING FIELDS OF TABLE ITAB FROM AEOI

     WHERE USOBJ LIKE SRCH_STR-HIGH .

ELSEIF SRCH_STR-HIGH IS INITIAL .

   SELECT AENNR AETYP USOBJ INTO CORRESPONDING FIELDS OF TABLE ITAB FROM AEOI

   WHERE USOBJ LIKE SRCH_STR-LOW .

ENDIF.

LOOP AT ITAB INTO WA .

   WRITE 😕 WA-USOBJ  .

ENDLOOP .

Regard's

Smruti