Skip to Content

finding the range for 2 different fields

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

7 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Dec 22, 2008 at 09:05 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

    • 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. .

  • author's profile photo Former Member
    Former Member
    Posted on Dec 22, 2008 at 09:04 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 22, 2008 at 09:05 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 22, 2008 at 09:18 AM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 22, 2008 at 09:25 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 22, 2008 at 09:55 AM

    hi, declare it as

    ranges,

    press f1 on ranges

    thanks

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 22, 2008 at 10:57 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.