Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

select statement

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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.

10 REPLIES 10

Former Member
0 Kudos

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.

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos
try this...

data : v_sernr(18).

v_sernr = 'a123456'.

select single * from equi 
where sernr = '000a123456'.
but not if i give sernr = v_sernr.

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

Use can use ALPHA convertion exit before select statement

Convertion exit FMs:

CONVERSION_EXIT_ALPHA_INPUT

CONVERSION_EXIT_ALPHA_OUTPUT

Former Member
0 Kudos

hi sai

use this FM

CONVERSION_EXIT_ALPHA_INPUT

and pass the field u want

regards venkat

Former Member
0 Kudos

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.

0 Kudos

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