2009 Sep 16 1:23 PM
Hi All,
I am using following select statement to get the data from table BSIS.
Basically, i have to fetch the data abse don GL Account range.
I want to get the data for all GL ranges that i have mentioned in the below select statement.
select bukrs hkont gjahr belnr dmbtr shkzg projk kostl from BSIS
into corresponding fields of table it_othcost
for all entries in it_wbs
where bukrs = c_bukrs
and hkont between '0002102001' and '0002999999'
or hkont between '0002101001' and '0002101003'
or hkont between '0002101007' and '0002101009'
or hkont between '0002101013' and '0002101015'
or hkont between '0002101019' and '0002101024'
and gjahr eq v_year2
and monat between v_fmonth and v_tmonth
and kostl = it_wbs-kostl.
Please tell me how correctly and effieciently i can write the select statement for this requirement?
Basically the above select statement is giving incorrecct data from the database table BSIS.
Regards
Pavan
2009 Sep 16 1:31 PM
see, or is a very critical statement in select statements so it would be better if you use a range table.
for example
data : s_hkont type RANGE OF hkont,
sw_hkont LIKE LINE OF s_hkont .
sw_hkont-sign = 'I'.
sw_hkont-OPTION = 'BT'.
sw_hkont-low = '0002102001'.
sw_hkont-high = '0002999999'.
append sw_hkont to s_hkont.
clear : sw_hkont.
sw_hkont-sign = 'I'.
sw_hkont-OPTION = 'BT'.
sw_hkont-low = '0002101001'.
sw_hkont-high = '0002101003'.
append sw_hkont to s_hkont.
"similarly for other ones.
"now in you select statement use this range table
select bukrs hkont gjahr belnr dmbtr shkzg projk kostl from BSIS
into corresponding fields of table it_othco "try not to use into corresponding
for all entries in it_wbs
where bukrs = c_bukrs
and hkont in s_hkont. " and other options
see, or is a very critical statement in select statements so it would be better if you use a range table.
for example
data : s_hkont type RANGE OF hkont,
sw_hkont LIKE LINE OF s_hkont .
sw_hkont-sign = 'I'.
sw_hkont-OPTION = 'BT'.
sw_hkont-low = '0002102001'.
sw_hkont-high = '0002999999'.
append sw_hkont to s_hkont.
clear : sw_hkont.
sw_hkont-sign = 'I'.
sw_hkont-OPTION = 'BT'.
sw_hkont-low = '0002101001'.
sw_hkont-high = '0002101003'.
append sw_hkont to s_hkont.
"similarly for other ones.
"now in you select statement use this range table
select bukrs hkont gjahr belnr dmbtr shkzg projk kostl from BSIS
into corresponding fields of table it_othco "try not to use into corresponding
for all entries in it_wbs
where bukrs = c_bukrs
and hkont in s_hkont. " and other options
2009 Sep 16 1:31 PM
see, or is a very critical statement in select statements so it would be better if you use a range table.
for example
data : s_hkont type RANGE OF hkont,
sw_hkont LIKE LINE OF s_hkont .
sw_hkont-sign = 'I'.
sw_hkont-OPTION = 'BT'.
sw_hkont-low = '0002102001'.
sw_hkont-high = '0002999999'.
append sw_hkont to s_hkont.
clear : sw_hkont.
sw_hkont-sign = 'I'.
sw_hkont-OPTION = 'BT'.
sw_hkont-low = '0002101001'.
sw_hkont-high = '0002101003'.
append sw_hkont to s_hkont.
"similarly for other ones.
"now in you select statement use this range table
select bukrs hkont gjahr belnr dmbtr shkzg projk kostl from BSIS
into corresponding fields of table it_othco "try not to use into corresponding
for all entries in it_wbs
where bukrs = c_bukrs
and hkont in s_hkont. " and other options
2009 Sep 16 1:32 PM
Hi,
Create a ranges table for Hkont and use it in the where condition using IN operator.
Search forum for sample codes on ranges / see F1 help.
Regards
Karthik D
2009 Sep 16 1:34 PM
Populate a range for HKONT and pass all the below values .. and use it in where condition ...
select bukrs hkont gjahr belnr dmbtr shkzg projk kostl from BSIS
into corresponding fields of table it_othcost
for all entries in it_wbs
where bukrs = c_bukrs
and hkont in r_hkont
and gjahr eq v_year2
and monat between v_fmonth and v_tmonth
and kostl = it_wbs-kostl.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |