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: 

finding the range for 2 different fields

vijy_mukunthan
Active Contributor
0 Kudos

Hi friends

In table HRV1218 the fields EXPR_LOW and EXPR_HIGH stores the range value when configrued responsibility. I want to get the range from these 2 fields. How to write the select query. I tried with between statement since its are 2 different field. Here is my code.

DATA : OBJID TYPE OBJID.

DATA : ORGID TYPE ORGID.

DATA : PA LIKE PA0001-WERKS.

DATA : LT_ITAB TYPE HRV1218 OCCURS 0 WITH HEADER LINE.

PA = '1027'.

SELECT OBJID FROM HRP1240 INTO OBJID WHERE EXT_OBJID = '01000014'.

ENDSELECT.

SELECT ALL FROM HRV1218 INTO LT_ITAB WHERE EXPR_LOW IN ('00000000') AND

EXPR_HIGH IN ('99999999') AND OBJID = OBJID.

LOOP AT LT_ITAB.

WRITE LT_ITAB.

ENDLOOP.

Am not getting any thing in my LT_ITAB. I want the range between the fields.

In table EXPR_LOW = '00000000' and EXPR_HIGH = '99999999' suppose the when the value is 60000709 i should get the other fields in the table. How to get this.

Regards

vijay

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Do like this:

DATA:
   r_expr   TYPE RANGE            
                  OF HRV1218-EXPR_LOW.   
    ....................................................
    .....................................................
     wa_expr-sign = 'I'.
    wa_expr-option = 'BT'.
    wa_expr-low = '00000000'.
    wa_expr-high = '99999999'.
    APPEND wa_expr TO r_expr.
    ...................................................
    ...................................................
    SELECT * FROM HRV1218 
      INTO LT_ITAB
      WHERE (EXPR_LOW IN r_expr
      OR EXPR_HIGH IN r_expr)
      AND OBJID = OBJID.

Regards,

Neha

Edited by: Neha Shukla on Dec 22, 2008 2:35 PM

8 REPLIES 8

Former Member
0 Kudos

Hi

IN is not the correct way

SELECT ALL FROM HRV1218 INTO LT_ITAB

WHERE ( EXPR_LOW >= '00000000' and

EXPR_LOW <= '99999999') and

(EXPR_HIGH >= '00000000' and EXPR_HIGH <= ('99999999')) AND OBJID = OBJID.

Regards

Aditya

Former Member
0 Kudos

Hi,

As far as I get ur problem try this out

SELECT ALL FROM HRV1218 INTO LT_ITAB WHERE EXPR_LOW GE '00000000' AND

EXPR_HIGH LE '99999999' AND OBJID = OBJID.

Thanks

Sahil

Former Member
0 Kudos

Hi,

Do like this:

DATA:
   r_expr   TYPE RANGE            
                  OF HRV1218-EXPR_LOW.   
    ....................................................
    .....................................................
     wa_expr-sign = 'I'.
    wa_expr-option = 'BT'.
    wa_expr-low = '00000000'.
    wa_expr-high = '99999999'.
    APPEND wa_expr TO r_expr.
    ...................................................
    ...................................................
    SELECT * FROM HRV1218 
      INTO LT_ITAB
      WHERE (EXPR_LOW IN r_expr
      OR EXPR_HIGH IN r_expr)
      AND OBJID = OBJID.

Regards,

Neha

Edited by: Neha Shukla on Dec 22, 2008 2:35 PM

0 Kudos

Hi neha

What is the type of wa_expr? when i try to declare the type as r_expr its showing error as

I declared as wa_expr like r_expr OCCURS 0 .

"WA_EXPR" is a table without a header line and therefore has no component called "SIGN".

When i declared like this

wa_expr like r_expr OCCURS 0 WITH HEADER LINE .

Its showing this error.

When using "WITH HEADER LINE", the line type cannot be a table type. .

Former Member
0 Kudos

You could try few things:

1. Try to directly select data based on the values you are putting in the query directly from se16. Just to cross verify, since you are using IN or =

2. Use relational operators LE or GE so that even if there is some other value data will get selected.

3. Check the value in your variable OBJID.

Former Member
0 Kudos

hi create range for it

ranges :r_range for HRV1218-EXPR_LOW

then populate the range with values high and low

SELECT field1 field2 FROM HRV1218

INTO ITAB

WHERE EXPR_LOW IN r_expr OR

EXPR_HIGH IN r_expr

AND OBJID = OBJID.

thanks

Former Member
0 Kudos

hi, declare it as

ranges,

press f1 on ranges

thanks

Former Member
0 Kudos

Hi vijay,

try this out

1) declare an internal table

begin of so_hrv218 occurs 0,

SIGN(1) type c,

OPTION(2) type c,

LOW like bukrs,

HIGH like bukrs,

end of so_hrv218.

2) declare a work area

3) pass the following values into the work area and then to the table so_hrv218

wa_so_hrv218-sign = 'I'.

wa_so_hrv218-option = 'BT'.

wa_so_hrv218-low = '00000000'.

wa_so_hrv218-high = '99999999'.

APPEND wa_expr TO r_expr.

4) Declare ranges

5) then go on with the simple SQL select query

hope this works

thanks

srikanth