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: 

How to compare the range of values with an internal table values

Former Member
0 Kudos

Hi,

I have 10 select-options in my selection-screen.

and I am using only 2 select-options in my select statment.

But while displaying my output I need to compare the data for the remaining fields with my obtained data which is in an internal table.

Thanks,

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

My requirement has not been solved yet -

it is something like - as I said I need to compare an internal table values with other 8 selection screen values, I cant use

loop at <itab> in s_range

endloop.

as this idea will suffice when I have to compare with only one range of values, how abt others??

My code looks like -

LOOP AT ITAB1 .

IF NOT P_CUSTID IS INITIAL.

READ TABLE ITAB3 WITH KEY KUNNR = P_CUSTID-LOW.

IF SY-SUBRC EQ 0.

check ITAB1-KUNNR = P_CUSTID-low.

IF P_ACYEAR EQ SPACE.

F_ITAB1-GJAHR = ITAB1-GJAHR.

ELSE .

F_ITAB1-GJAHR = P_ACYEAR-low.

ENDIF.

IF p_Dunblk EQ SPACE.

F_ITAB1-MANSP = ITAB1-MANSP.

ELSE.

F_ITAB1-MANSP = p_Dunblk-low.

ENDLOOP.

Here- I have been using 'p_custid-low' / 'p_acyear-low' / 'p_dunblk-low'...

Here i need to check with all the values entered in the selection screen , how to do this??

4 REPLIES 4

Former Member
0 Kudos

just try with this EX:

RANGES : s_matnr FOR mara-matnr.

RANGES: s_VBELN FOR VBAK-VBELN.

INITIALIZATION.

s_matnr-LOW = 10.

s_matnr-HIGH = 20.

s_matnr-OPTION = 'BT'.

s_matnr-SIGN = 'I'.

APPEND s_matnr.

s_matnr-LOW = 145.

s_matnr-HIGH = 2023.

s_matnr-OPTION = 'BT'.

s_matnr-SIGN = 'I'.

APPEND s_matnr.

s_matnr-LOW = 87.

s_matnr-HIGH = 207.

s_matnr-OPTION = 'BT'.

s_matnr-SIGN = 'I'.

APPEND s_matnr.

s_matnr-LOW = 19.

s_matnr-HIGH = 204576.

s_matnr-OPTION = 'BT'.

s_matnr-SIGN = 'I'.

APPEND s_matnr.

|

|

|

so on.

s_vbeln-LOW = 10000.

s_vbeln-HIGH = 20000.

s_vbeln-OPTION = 'BT'.

s_vbeln-SIGN = 'I'.

APPEND s_vbeln.

s_vbeln-LOW = 50000.

s_vbeln-HIGH =60000.

s_vbeln-OPTION = 'BT'.

s_vbeln-SIGN = 'I'.

APPEND s_vbeln.

s_vbeln-LOW = 80000.

s_vbeln-HIGH = 90000.

s_vbeln-OPTION = 'BT'.

s_vbeln-SIGN = 'I'.

APPEND s_vbeln.

s_vbeln-LOW = 12000.

s_vbeln-HIGH = 23000.

s_vbeln-OPTION = 'BT'.

s_vbeln-SIGN = 'I'.

APPEND s_vbeln.

|

|

|

|

so on

in select query declare these two parameters in where condition.

david_carballido
Active Participant
0 Kudos

you can compare values on a internal table this:

IF itab[] IN s_range.

logic ...

ENDIF.

Regards.

David Carballido

Former Member
0 Kudos

Hi,

My requirement has not been solved yet -

it is something like - as I said I need to compare an internal table values with other 8 selection screen values, I cant use

loop at <itab> in s_range

endloop.

as this idea will suffice when I have to compare with only one range of values, how abt others??

My code looks like -

LOOP AT ITAB1 .

IF NOT P_CUSTID IS INITIAL.

READ TABLE ITAB3 WITH KEY KUNNR = P_CUSTID-LOW.

IF SY-SUBRC EQ 0.

check ITAB1-KUNNR = P_CUSTID-low.

IF P_ACYEAR EQ SPACE.

F_ITAB1-GJAHR = ITAB1-GJAHR.

ELSE .

F_ITAB1-GJAHR = P_ACYEAR-low.

ENDIF.

IF p_Dunblk EQ SPACE.

F_ITAB1-MANSP = ITAB1-MANSP.

ELSE.

F_ITAB1-MANSP = p_Dunblk-low.

ENDLOOP.

Here- I have been using 'p_custid-low' / 'p_acyear-low' / 'p_dunblk-low'...

Here i need to check with all the values entered in the selection screen , how to do this??

0 Kudos

You can use WHERE clause in your LOOP statement to filter out your previously selected records based on your other selection parameters. Your code should look somewhat like this.

LOOP AT ITAB1 WHERE KUNNR IN P_CUSTID

AND GJHAR IN P_ACYEAR

AND MANSP IN P_DUNBLK.

ENDLOOP.

You can use multiple select options in LOOP statement.