11-18-2011 6:08 AM
Hi,
I have a program, where user enters a field. S_INGRP, from the Selection Screen.
Users may enter wild card characters in this field.
I have used the below code to handle this.
if s_ingrp-high eq space
Select <fields> into corresponding fields of itab
from table qmih where ingrp like s_matnr-low.
else
Select <fields> into corresponding fields of itab
from table qmih where ingrp in s_matnr.
endif.
This code helps me when
1.A single value with wild-card characters is provided. (eg E%)
2. The low value is with a wild-card character and high value is a exact value. (eg: E% to MM1)
But When I give both the low and the high value with wild- card characters ( eg: E% to M%) , it only returns the values for the low value (E%).
Please Help
11-18-2011 6:29 AM
hi !
Please check you logic/Coding.
check the low and figh values of selection and then write the coding.
if s_matnr-low is not initial.
select....
else if s_matnr-high is not initial.
elseif s_matnr-low is not initial and s_matnr-low is not initial.
endif
11-18-2011 6:44 AM
Hi Dharma raj,
My Query is : How should I frame my Select statement to handle wild characters in low as well as high values.
11-18-2011 8:59 AM
Hi backhac,
From what i know, if both low and high fields of the select options is filled then you cannot use wildcard options.
When you are filling the low and high option essentially you are making use of the 'BETWEEN' or "NOT BETWEEN' options.
And i doubt whether you can use wildcard characters when you are populating both the values. I am also watching this thread to see if there is a solution to your query !
Regards,
Arun
11-18-2011 11:59 AM
Hi Arun,
Even I was under the impression that both the Low and high values cannot be wild-card characters.
But I performed a test using the SE16 transaction on a table with both the Low and high values with wild-card characters....
So I believe there must be a way to do it.....
Waiting for a solution...
11-19-2011 5:29 AM
Hi Arun,
I have found a solution for this.
To be honest, I have not found it, but it was already there in ABAP.
To handle both the LOW and HIGH values with wild-card characters, the normal select query works:
SELECT * APPENDING TABLE ITAB FROM QMIH
WHERE INGRP IN S_INGRP.
But the catch here is that the range is exclusive of the high range. i.e. if the S_INGRP contains E* to M*, it returns records where INGRP starts with E, F,G,.......I,J,L. and not M.
and it works with '*' as well '%' for wild-characters.
Since I had test values beginning with only E and M, and I was providing the range as E* to M, it was returning only values with E, and I thought it was not working.
11-19-2011 6:36 AM
TABLES : qmih.
SELECT-OPTIONS : s_ingrp for qmih-INGRP.
data : itab TYPE TABLE OF qmih.
Select * into TABLE itab
from qmih where ingrp BETWEEN s_ingrp-low AND s_ingrp-high.
BR,
Vijay
11-19-2011 7:26 AM
Hi Krupaji and Vijay,
I have used both where ...in and where ..... between ...and.... variants, but I get the same result, the high value is excluded.
Am doing something wrong...
11-19-2011 7:30 AM
Am doing something wrong
No Bachack - You are correct high value is exclusive in ranges.
Go ahead.
BR,
Vijay
11-18-2011 6:58 AM
in IF condition you are checking with
if s_ingrp-high eq space
this condition.
so the code which you mentioned will not work for HIGH is not equals to space.
So chenge the code accordingly..
11-18-2011 12:43 PM
I see similar results....But when I do wildcard to value, I get what I expected... Experiment..you can find a solution...I would try this....
read table s_matnr into ls_matnr (described like line of s_matnr) or perhaps you'd need to loop and select appending.
if ls_matnr-low cs '' and ls_matnr-high cs ''.
replace '*' with '%' into ls_matnr-low.
replace '*' with '%' into ls_matnr-high.
select * ....
where matnr like ls_matnr-low or
matnr like ls_matnr-high.
else.
select * . . .
where matnr in s_matnr.
11-18-2011 2:50 PM
Hi BreakPoint,
This will return only values where matnr = matnr-low, but not the entire range between matnr-low and matnr-high
Edited by: bachack on Nov 18, 2011 4:01 PM
Edited by: bachack on Nov 19, 2011 4:47 AM
11-19-2011 6:06 AM
see the following example
TABLES : mdsb.
DATA : BEGIN OF t_mchb OCCURS 0,
matnr LIKE mchb-matnr,
lgort LIKE mchb-lgort,
charg LIKE mchb-charg,
clabs LIKE mchb-clabs,
cumlm LIKE mchb-cumlm,
flg(1) TYPE c,
END OF t_mchb.
SELECT-OPTIONS:matnr FOR mdsb-matnr. "here u can inptu e120% to f20%
SELECT * FROM mchb
INTO CORRESPONDING FIELDS OF TABLE t_mchb
WHERE matnr in matnr AND
charg = 'S'
'
.
i run this code and work fine.
Edited by: Krupaji on Nov 19, 2011 7:07 AM