05-03-2006 10:29 AM
hi
i need to get a record from EQUi table . i have a serial number(sernr) '000a123456'
iam getting the record if i give like this
select single * from equi
where sernr = '000a123456'.
but not if i give sernr = 'a123456'.
how to write the select statement.
thanks in advance
05-03-2006 10:48 AM
Hi sai,
1. Yes u are right.
2. If u are hardcoding the value
in sql statement itself,
then we need to give the FULL VALUE
(including the left zeroes)
regards,
amit m.
05-03-2006 10:48 AM
Hi sai,
1. Yes u are right.
2. If u are hardcoding the value
in sql statement itself,
then we need to give the FULL VALUE
(including the left zeroes)
regards,
amit m.
05-03-2006 10:53 AM
Hi Sai,
Take a constant of type 'sernr' and pass your value into it and use the same in the select statement. Try to avoid hard coding in your program. Always declare a corresponding type constant and pass the constant value into this constant and use it.
Thanks and Regards,
Bharat Kumar Reddy.V
05-03-2006 10:55 AM
Hi,
Where is the value coming from?
If you are hard coding the way you have shown.
select single * from equi
where sernr = '000a123456'.
If the user is selecting it from a F4 on the selection screen then
select single * from equi
where sernr = 'p_sernr.
Regards,
Ravi
note : Please mark the helpful answers
05-03-2006 10:56 AM
try this...
data : v_sernr(18).
v_sernr = 'a123456'.
select single * from equi
where sernr = '000a123456'.
but not if i give sernr = v_sernr.
05-03-2006 11:05 AM
hi
good
as per your requirement you must give the full name of the serial number how it is store in the database table.
in the select statement it must be 000a123456 not a123456 because the select statement wont found any record under that name.
thanks
mrutyun
05-03-2006 11:13 AM
Hai Sai ram
sernr is not a key field in 'equi' table
so you must give leading zero's also for that condition
if it is a key field then you exclude the leading zero's
check it
tables : equi.
data : it_equi like equi occurs 0 with header line.
**in this case you should give the full value with leading zero's because sernr is not a key field
select * from equi into table it_equi
where sernr = '000a123456'.
if sy-subrc = 0.
sort it_equi by sernr.
endif.
**in this case you give the value without leading zero's because eqrnr is a key field
select * from equi into table it_equi
where EQUNR = 'a123456'.
if sy-subrc = 0.
sort it_equi by equnr.
endif.
Thanks & regards
Sreenivasulu P
05-03-2006 11:17 AM
Use can use ALPHA convertion exit before select statement
Convertion exit FMs:
CONVERSION_EXIT_ALPHA_INPUT
CONVERSION_EXIT_ALPHA_OUTPUT
05-03-2006 11:27 AM
hi sai
use this FM
CONVERSION_EXIT_ALPHA_INPUT
and pass the field u want
regards venkat
05-03-2006 12:09 PM
Hi again,
1. instead of hardcoding in the select statement,
or using a variable,
2. if we use PARAMETERS,
then we don't face such problem
bcos
automatic conversion (left padding with zeroes and vice-versa)
happens.
3. just copy paste this in new program, to get a taste of it.
4.
report abc.
*----
tables : equi.
parameters : equnr like equi-equnr default 'a123456'.
*----
This will not work
*data : equnr like equi-equnr value 'a123456'.
select single * from equi
into equi
where equnr = equnr.
write 😕 equi-equnr.
regards,
amit m.
05-07-2006 8:38 AM
check out this sample code
data: w_sernr like equi-sernr .
tables: equi .
w_sernr = 'a123456' .
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = w_sernr
IMPORTING
OUTPUT = w_sernr .
select single * from equi where sernr = w_sernr .
Regards
Raja