2009 Apr 15 4:59 AM
hi experts,
i am facing problem in looping using range table in where condition part.
LOOP AT gt_wv_trans INTO gwa_wv_trans WHERE hkont = r_scelem-low AND
kostl = r_skostl-low.
:
:
ENDLOOP.
Here the range table is taking the last value only and not from the first.
ie., gt_wv_trans has values ->
hkont kostl sgtxt
701000 9999 panasonic ltd.
702000 101 xxxxx
803000 9999 yyyyy
r_scelem value->
hkont
701000
702000
803000
r_skostl value ->
kostl-low kostl-high
9999
101 305
9999
now the looping is done only for the last value ie., 803000 and 9999
1). how to make the looping to do from the first value (ie., 701000 and 9999)
2). how to loop and check the conditions for the range table low and high value ?
plz help me.
thanks.
2009 Apr 15 5:17 AM
Hi Sakthi,
Check the below sample code to understand the logic,
DATA:BEGIN OF it_tab OCCURS 0,
f1 TYPE i,
f2 TYPE i,
END OF it_tab.
RANGES: r_f1 FOR it_tab-f1.
"Jus data filling
it_tab-f1 = 1000.
it_tab-f2 = 2000.
APPEND it_tab.
it_tab-f1 = 1001.
it_tab-f2 = 2001.
APPEND it_tab.
it_tab-f1 = 1002.
it_tab-f2 = 2002.
APPEND it_tab.
r_f1-sign = 'I'.
r_f1-option = 'EQ'.
r_f1-low = 1000.
APPEND r_f1.
r_f1-sign = 'I'.
r_f1-option = 'EQ'.
r_f1-low = 1001.
APPEND r_f1.
"Here is the logic
LOOP AT it_tab WHERE f1 IN r_f1.
WRITE:/ it_tab-f1, it_tab-f2.
ENDLOOP.Hope this helps you!
Regards,
Manoj Kumar P
Edited by: Manoj Kumar on Apr 15, 2009 6:17 AM
hi experts,
i am facing problem in looping using range table in where condition part.
LOOP AT gt_wv_trans INTO gwa_wv_trans WHERE hkont = r_scelem-low AND
kostl = r_skostl-low.
:
:
ENDLOOP.
Here the range table is taking the last value only and not from the first.
ie., gt_wv_trans has values ->
hkont kostl sgtxt
701000 9999 panasonic ltd.
702000 101 xxxxx
803000 9999 yyyyy
r_scelem value->
hkont
701000
702000
803000
r_skostl value ->
kostl-low kostl-high
9999
101 305
9999
now the looping is done only for the last value ie., 803000 and 9999
1). how to make the looping to do from the first value (ie., 701000 and 9999)
2). how to loop and check the conditions for the range table low and high value ?
plz help me.
thanks.
2009 Apr 15 5:06 AM
Hi:
if u hv two options like
1. LOOP AT gt_wv_trans INTO gwa_wv_trans WHERE hkont GE r_scelem-low AND
kostl LE r_skostl-low.
:
:
ENDLOOP
2. select * from <table> into table gt_wv_trans where WHERE hkont GE r_scelem-low AND
kostl LE r_skostl-low.
- sort the internal table
- start the looping as per your requirement.
Regards
Shashi
2009 Apr 15 5:17 AM
Hi Sakthi,
Check the below sample code to understand the logic,
DATA:BEGIN OF it_tab OCCURS 0,
f1 TYPE i,
f2 TYPE i,
END OF it_tab.
RANGES: r_f1 FOR it_tab-f1.
"Jus data filling
it_tab-f1 = 1000.
it_tab-f2 = 2000.
APPEND it_tab.
it_tab-f1 = 1001.
it_tab-f2 = 2001.
APPEND it_tab.
it_tab-f1 = 1002.
it_tab-f2 = 2002.
APPEND it_tab.
r_f1-sign = 'I'.
r_f1-option = 'EQ'.
r_f1-low = 1000.
APPEND r_f1.
r_f1-sign = 'I'.
r_f1-option = 'EQ'.
r_f1-low = 1001.
APPEND r_f1.
"Here is the logic
LOOP AT it_tab WHERE f1 IN r_f1.
WRITE:/ it_tab-f1, it_tab-f2.
ENDLOOP.Hope this helps you!
Regards,
Manoj Kumar P
Edited by: Manoj Kumar on Apr 15, 2009 6:17 AM
2009 Apr 15 5:21 AM
Dear ,
See the range is also same as internal table .
First apply the loop on the selection option parameter then u apply the condition on the internal table for which you want to check the condition .
This will surely do debug and check .
for example :
Loop at s_option .
"loop at the internal table where you want to check condition using where clause .
endloop .rgds ankit
2009 Apr 15 5:57 AM
r_scelem and r_skostl. are internal table with header line so when you specify only r_scelem-low AND
kostl = r_skostl-low value it will take the value in the header.
Just try these codes this will solve the issue.
LOOP AT gt_wv_trans INTO gwa_wv_trans.
IFgwa_wv_trans-hkont IN r_scelem AND
gwa_wv_trans-kostl IN r_skostl.
:
:
ENDLOOP.Regards,
Gurpreet
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |