2008 Mar 31 2:27 PM
There is a field named bcode in data base that is of char length 3 , i want 1 to 10 insert in dat field, is it possible , i know yes , so tell me dat field is behaving like character when i m selecting values from selection screen , what i want when i m entering 1 to 7 it should show only then as a numeric field do , how we can do dat? tell me in details?
2008 Apr 01 10:11 AM
OK, I understand now.
>SO IT SHOULD ALSO SHOW 3 INSIDE THE VALUSE ,
No, it shouldn't. You're data types are wrong. The problem you've got is the sort order of your data - it is alpha sorting, not numeric. It's the same as if you'd put A, AB and C into the database. If you then select A to AB, you won't get C. ( 1 to 12, you won't get 3 ).
I imagine you have something like this for your selection screen.
DATA: num TYPE c LENGTH 3.
SELECT-OPTIONS s_num FOR num.
AT SELECTION-SCREEN ON s_num.
IF s_num CN ' 0123456789'.
MESSAGE e000(s1) WITH 'Numerics only'.
ENDIF.The best course of action is change your datatypes in the database, to match the data being held.
matt
2008 Mar 31 2:39 PM
what i want , for example ,
we ahve inserted 1 then 12 then 3
so value will be 1 , 12 , 3 , n when we are selecting by selection screen from 1 to 12 dat will show only 1 to 12 , 3 will not there i want 3 should also be there based on selection.
reply plz
2008 Mar 31 3:03 PM
2008 Mar 31 3:30 PM
I'd be delighted to help, but I do not understand what you are asking.
matt
2008 Mar 31 3:32 PM
2008 Mar 31 4:16 PM
2008 Mar 31 4:19 PM
HI I M REPEATING MY QUESTION , HERE DAT , I HAVE A FIELD OF CHAR LENGTH 3 ,
NOW I HAVE ADDED 3 VALUES 1 , 12, 3 TO DAT FIELD IN THE DATABASE,
NOW I M SELECTING VALUE THROUGH THE SELECTION SCREEN N
I M SELECTING ALL THE VALUES BETWEEN 1 TO 12 , SO
IT SHOULD ALSO SHOW 3 INSIDE THE VALUSE ,
BUT DAT IS NOT HAPPENING , BCOZ IT WAS A CHARACTER FIELD SO IT IS SHOWING 1 N 12 ,
SO I WANT TO KNOW HOW CAN WE SOLVE DAT PRB ,
?
2008 Apr 01 9:55 AM
2008 Apr 01 10:11 AM
Hi,
You have a data type Character in database.
data: t_test(12) type c,
n(10) type n.
n = t_test.
You can assign character to numerical value.
Create one internal table with a single field
n(10) type n.
Loop at the database table and insert all the values of the character field from the database table to the character field.
Then select based on the other internal table . Give condition like \
your database table field name = internal table field name.
Regards
Sandipan
2008 Apr 01 10:11 AM
OK, I understand now.
>SO IT SHOULD ALSO SHOW 3 INSIDE THE VALUSE ,
No, it shouldn't. You're data types are wrong. The problem you've got is the sort order of your data - it is alpha sorting, not numeric. It's the same as if you'd put A, AB and C into the database. If you then select A to AB, you won't get C. ( 1 to 12, you won't get 3 ).
I imagine you have something like this for your selection screen.
DATA: num TYPE c LENGTH 3.
SELECT-OPTIONS s_num FOR num.
AT SELECTION-SCREEN ON s_num.
IF s_num CN ' 0123456789'.
MESSAGE e000(s1) WITH 'Numerics only'.
ENDIF.The best course of action is change your datatypes in the database, to match the data being held.
matt
2008 Apr 01 10:21 AM
HI MAtt, thanks for ur suggestion , i got ur point but problem is not solved , the database we cant change that is the requirement , so we will have to take character s only , so tell me any other solution , u got right same is happening its taking alpha numeric sorting , so solve plz if possible.
2008 Apr 01 10:36 AM
Then follow Sandipan Ghosh's suggestion above. Read the database table into an internal table, convert the character numeric data to integer. Change your select option to be integer.
Or create a table, e.g. z_numtab, with two fields - CH3 type CHAR 3, and INT type INT1. Populate it with all the numbers 0-999. Then use it to convert the select option to a series of equalities.
DATA: num TYPE c LENGTH 3,
int TYPE i.
DATA: lt_numtab TYPE STANDARD TABLE OF z_numtab.
SELECT-OPTIONS: s_num FOR num.
RANGES: r_num FOR i.
FIELD-SYMBOLS: <ls_numtab> TYPE z_numtab.
AT SELECTION-SCREEN..
LOOP AT s_num.
IF s_num-low CN ' 0123456789' OR s_num-high CN ' 0123456789'.
MESSAGE e000(s1) WITH 'Numerics only'.
ENDIF.
ENDLOOP.
START-OF-SELECTION.
LOOP AT s_num.
r_num-option = s_num-option.
r_num-sign = s_num-sign.
r_num-low = s_num-low.
r_num-high = s_num-high.
APPEND r_num.
ENDLOOP.
SELECT * FROM z_numtab INTO TABLE lt_numtab WHERE int IN r_num.
REFRESH s_num.
s_num-sign = 'I'.
s_num-option = 'EQ'.
LOOP AT lt_numtab ASSIGNING <ls_numtab>.
s_num-low = <ls_numtab>-ch3.
ENDLOOP.
SELECT * FROM dbtab INTO TABLE lt_dbtab WHERE bcode IN s_num.matt
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |