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 error

Former Member
0 Kudos
265

Hello all,

How can a simple statement like this one:

SELECT SINGLE * FROM tbl_smt INTO ls_smt

WHERE field = p_field.

<b>always</b> return sy-subrc = 4 ?

p_field is declared <i>like tbl_smt-field</i>

and is in fact a CHAR of length 30.

tbl_smt contains a few lines with data.

p_field is not a key field.

1 ACCEPTED SOLUTION

Vinod_Chandran
Active Contributor
0 Kudos
160

Also check whether the field's tbl_smt-field domain has a conversion routine. Goto the domain and copy the routine name for example ALPHA.

Now go to SE37 and check for ALPHA. You will get two function modules like CONVERSION_EXIT_ALPHA_INPUT and

CONVERSION_EXIT_ALPHA_OUTPUT. The first one is used to convert to internal and other one to external. You have to use the INPUT function module.

Thanks

Vinod

19 REPLIES 19

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos
160

How is the value of field stored in the database?

Is it stored with leading zeros and you are hitting it with a value like 1234? For example in the material master table MARA. The matnr field is 18 characters, if the material number is a numeric value then in the DB it looks like this '000000000000001234'. In you select statement, you must make sure that you are hitting it with the same format.

Regards,

Rich Heilman

0 Kudos
160

No, the field is a char field, storing simple city names.

Regards,

Bogdan

0 Kudos
160

Is the field case-sensitive?

Regards,

Rich Heilman

0 Kudos
160

Is that possible?

Regards,

Bogdan

0 Kudos
160

Sure.....

Regards,

Rich Heilman

0 Kudos
160

Yes. It is possible.

Check the Domain and you can find a checkbox.

0 Kudos
160

Look at the domain TEXT40. Under the output characteristics, you see a checkbox, that says lowercase. This means that the system will not translate it to uppercase when saved to the database.

Regards,

Rich Heilman

0 Kudos
160

If your field has a domain like this, then you must hit the db with exactly the case used in the database.

Regards,

Rich Heilman

0 Kudos
160

The "lowercase" checkbox is not checked.

Vinod_Chandran
Active Contributor
0 Kudos
161

Also check whether the field's tbl_smt-field domain has a conversion routine. Goto the domain and copy the routine name for example ALPHA.

Now go to SE37 and check for ALPHA. You will get two function modules like CONVERSION_EXIT_ALPHA_INPUT and

CONVERSION_EXIT_ALPHA_OUTPUT. The first one is used to convert to internal and other one to external. You have to use the INPUT function module.

Thanks

Vinod

0 Kudos
160

No, the domain does not have a conversion routine.

0 Kudos
160

The "Lowercase" checkbox isn't checked, eather.

Former Member
0 Kudos
160

Could it be an issue of encoding?

0 Kudos
160

Please post the values of the field as they are exactly from the database. Also post your select statement as well as the parameter statement.

Regards,

Rich Heilman

Former Member
0 Kudos
160

SE16 doesn't return any values eather, when entering in the select-option corresponding to <i>field</i> a value that exists in the table.

Regards,

Bogdan

Former Member
0 Kudos
160

Well, I guess I'm too tired now.

The problem is solved.

The values in the database are indeed case sensitive.

I needed to TRANSLATE a bit the <i>field</i> before hitting the database with it, ofcourse.

Thank you, guys.

Bogdan

0 Kudos
160

Please award points accordingly and mark this post as solved. Thanks.

Regards,

Rich Heilman

Former Member
0 Kudos
160

As you say, it is possible that this is an encoding problem.

Write a simple program to select some records from the table. Now put the your search value (p_field) similar to one of the value in the table.

Say the table contains following entries:

City

WALTHAM

BOSTON

CAMBRIDGE

WORCESTOR

QUINCY

  • You can set this as screen parameter

p_field = 'WALTHAM'.

SELECT * FROM table INTO it_data.

BREAK-POINT.

When this takes you to debugging mode, examine contents of it_data.

Enter it_data[1] & p_field in the fields to examine.

Click on the magnifying glass on the right hand side to see the Hexadecimal values.

This will allow you to compare what you are entering and what is there in the table, and tell you what you are doing wrong. You can examine other entries one by one if you don't get hit on first one.

~Sivaraj.

0 Kudos
160

;-). Ignore my reply.