Application Development and Automation 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: 
Read only

Select where clause char comparison

edgar_almonte
Participant
0 Likes
3,914

Hello

i have a doubt about a select statement , i have  a ZTABLE with a key field char length 11 and a record in the table with the key '00012345678'

i have a field in the selection screen of length 20 which i use for capture the value for find the data in the ZTABLE work fine so far but

if fill the field with the value '00012345678000' ( add 3 more zero at the end ) the record is still find in the DB and my question is this OK ? is this the normal behavior ? or is because is a CHAR type field ?


Thanks

1 ACCEPTED SOLUTION
Read only

edgar_almonte
Participant
2,844

thanks for the reply ,

i know how to solved the issue my question was more if this is the correct behavior of SQL or is just a abap case ?(that the where truncate the value in case of CHAR data type.(

Hello

i have a doubt about a select statement , i have  a ZTABLE with a key field char length 11 and a record in the table with the key '00012345678'

i have a field in the selection screen of length 20 which i use for capture the value for find the data in the ZTABLE work fine so far but

if fill the field with the value '00012345678000' ( add 3 more zero at the end ) the record is still find in the DB and my question is this OK ? is this the normal behavior ? or is because is a CHAR type field ?


Thanks

8 REPLIES 8
Read only

Former Member
0 Likes
2,844

Hi Edgar,

No. On screen you should define the same field lentgh which is defined in table.

Are you transferring screen data to local variable(type same as table data element) and further using it in Select query for comparision?

Regards,

Sudeesh Soni

Read only

Former Member
0 Likes
2,844

Hi Edgar,

            Kindly take the same type i.e your ZTABLE-field in your selection screen. Can i know of which type you have taken the field type for the screen field and in the program.

I think your issue will be solved.

Thanks & Regards,

S.Rajendranath Raparthi

Read only

former_member212705
Active Participant
0 Likes
2,844

Hi EA,

No, it should not find because the value differs. you are comapring 00012345678 with 00012345678000 and still you are getting result.. It should not return any value..

Read only

0 Likes
2,844

but i am getting value, is like the where is truncate the value of the field char 20 and only getting the first 11 position

Read only

edgar_almonte
Participant
2,845

thanks for the reply ,

i know how to solved the issue my question was more if this is the correct behavior of SQL or is just a abap case ?(that the where truncate the value in case of CHAR data type.(

Read only

0 Likes
2,844

Your question is very good Edgar. but i never faced such issue.  you are comparing 11 field length with 14 . i will have to check this. Will let you know.

Read only

0 Likes
2,844

thanks , let me know the result of your testing

Read only

0 Likes
2,844

Hi,

PARAMETER: aaa type c LENGTH 20.
data: bbb TYPE c LENGTH 11.

bbb = aaa.


Here bbb always contains First 11 characters of aaa. If it is an integer then it is the reverse case always contain last digits until it fit the field.


characters: assignment happens from left to right if the container is not enough size.

digits: assignment happens from right to left if the container is not enough size.


Regards,

Aswath.