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: 

Usage of 2 Ranges in select statement

Former Member
0 Kudos

Hi friends ...

iam encountering a problem like this ......

Iam selecting values from COSS table for a range of projects and a range of cost elements (KSTAR)

My statement is as follows :

*****************************

SELECT OBJNR KSTAR WOG001 WOG002 WOG003 WOG004 WOG005 WOG006

WOG007 WOG008 WOG009 WOG010 WOG011 WOG012

FROM COSS APPENDING TABLE T_COSS

WHERE LEDNR = X_LEDNR

AND OBJNR IN R_OROBJNR_IN_COUNT " -low

AND GJAHR = P_FYEAR

AND WRTTP = X_WRTTP

AND KSTAR IN R_SETLEAF.

******************************************

Here

1. R_OROBJNR_IN_COUNT => contains some 50 data ( all its option = 'EQ'

2. R_SETLEAF => contains cost elements ( one OPTION is 'BT' and all the others are 'EQ'

My Problem is :

This query is not returning the values from COSS for those cost elements which are in 'BT' values

Expecting ur answers;-)

Thanks in advance

Cheers,

R.Kripa.

9 REPLIES 9

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Show us how you are filling the ranges.

Regards,

Rich Heilman

former_member181962
Active Contributor
0 Kudos

I don't think there is any problem at all.

The records which have the cost elements (R_SETLEAF )between the range you have mentioned, does not have any one of those 50 single values you have given in R_OROBJNR_IN_COUNT.

<b>REmember the AND Condition wil only give the over lapped records.</b>

Anyways, check for your self in se11/se16.

Regards,

Ravi

Former Member
0 Kudos

have u filled the ranges like this

R_SETLEAF-sign = 'I'.

R_SETLEAF-option = 'BT'.

Former Member
0 Kudos

Hi kripa,

Fill range table R_OROBJNR_IN_COUNT

with only 1 or 2 entries for testing purpose

with record that matches your selection criteria

by looking into table COSS.

Also fill the range as

r_objnr-sign = 'I'.

r_objnr-option = 'BT'.

Regards,

Amole

Former Member
0 Kudos

Hey people....

This is my code .....

*********************************

LOOP AT R_OROBJNR_IN.

IF R_OROBJNR_IN-OPTION = 'EQ'.

R_OROBJNR_IN_TEMP-SIGN = R_OROBJNR_IN-SIGN.

R_OROBJNR_IN_TEMP-OPTION = R_OROBJNR_IN-OPTION.

R_OROBJNR_IN_TEMP-LOW = R_OROBJNR_IN-LOW.

APPEND R_OROBJNR_IN_TEMP.

CLEAR R_OROBJNR_IN_TEMP.

ELSEIF R_OROBJNR_IN-OPTION = 'BT'.

L_LOW_VALUE = R_OROBJNR_IN-LOW.

WHILE L_LOW_VALUE LE R_OROBJNR_IN-HIGH .

R_OROBJNR_IN_TEMP-SIGN = R_OROBJNR_IN-SIGN.

R_OROBJNR_IN_TEMP-OPTION = 'EQ'.

R_OROBJNR_IN_TEMP-LOW = L_LOW_VALUE.

APPEND R_OROBJNR_IN_TEMP.

CLEAR R_OROBJNR_IN_TEMP.

L_LOW_VALUE = L_LOW_VALUE + 1.

ENDWHILE.

ENDIF.

ENDLOOP.

REFRESH : R_OROBJNR_IN_COUNT.

CLEAR : R_OROBJNR_IN_COUNT.

LOOP AT R_OROBJNR_IN_TEMP.

R_OROBJNR_IN_COUNT = R_OROBJNR_IN_TEMP.

APPEND R_OROBJNR_IN_COUNT.

ADD 1 TO COUNTER.

IF COUNTER > MAX_COUNTER.

  • kripa

SELECT OBJNR KSTAR WOG001 WOG002 WOG003 WOG004 WOG005 WOG006

WOG007 WOG008 WOG009 WOG010 WOG011 WOG012

FROM COSS APPENDING TABLE T_COSS

WHERE LEDNR = X_LEDNR

AND OBJNR IN R_OROBJNR_IN_COUNT " -low

AND GJAHR = P_FYEAR

AND WRTTP = X_WRTTP

AND KSTAR IN R_SETLEAF.

  • kripa

MOVE 0 TO COUNTER.

REFRESH R_OROBJNR_IN_COUNT.

CLEAR R_OROBJNR_IN_COUNT.

ENDIF.

ENDLOOP.

*********************************

In R_SETLEAF .... i have values like this

************************

1 I EQ 950000 950000

2 I EQ 551046 551046

3 I EQ 551500 551500

4 I EQ 551400 551400

5 I EQ 551071 551071

6 I EQ 551040 551040

7 I EQ 551086 551086

8 I BT 551000 551030

9 I EQ 551045 551045

*************************

The costs of the 8th record is not picked up in the report .....

Am i clear ???

Cheers,

R.Kripa.

Clemenss
Active Contributor
0 Kudos

if you select distinct fields, don't forget the addition 'INTO CORRESPONDING FIELDS OF'... Your statement may result in garbage.

The way you select 'OBJNR IN R_OROBJNR' and 'KSTAR IN R_SETLEAF' will return only records fullfilling both conditions.

Either use SELECT FROM SELECT or ommit one of the ranges and after selection delete itab where not in <ommmitted range>.

Regards,

Clemens

Former Member
0 Kudos

Hi Amole renapurkar,

when there is only one data with the 9 cost elements ( even with 'BT') it is picking up values ......

but only when the query which i ve given above is not returning me any value ????

Cheers,

R.kripa

0 Kudos

Is it really necessary to break out the BT record into individual EQ records.

Regards,

Rich Heilman

0 Kudos

Hi Kripa,

Try keeping the high field empty when filling single values.(Specify only low).

Regards,

Ravi