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: 

Very Urgent Help , ABAP SQL Query

Former Member
0 Kudos

Guys,

Please suggest.I have a table(custom_table1) with a field say A which is of date type = c and length = 9. And i want to query this table.Following is the query.

Select substr(A,0,5) B C into itab From table custom_table1

where b = ( select b from cusstom_table2 )

and substr(A,0,5) = Input_A.

That is i want to equate an Input_A (which is of 5 character length) with field A (only first 5 character of the 9 length). But it seems the query is wrong. Kindly help ,very urgent

Thanks

5 REPLIES 5

Former Member
0 Kudos

Hi,

You can not query based on the first 5 characters only.

But you can use LIKE

Select A B C into itab From table custom_table1

where b = ( select b from cusstom_table2 )

and A LIKE <first 5 characters>

Regards,

Atish.

0 Kudos

Can i not even get the substr (A,0,5) from the column A ? I need to have only the first 5 character of field A into Internal Table Itab. And as per the where clause you suggested u said to use LIKE.

Is it where A LIKE '%Input_A%' or something else can you please give me the syntax for using with like operator ?

Thanks

0 Kudos

Hi,

Yes.You are correct. Use '%'

Regards,

Niyaz

0 Kudos

check below standard SAP help

PARAMETERS srch_str TYPE c LENGTH 20.

DATA text_tab TYPE TABLE OF doktl.

CONCATENATE '%' srch_str '%' INTO srch_str.

SELECT *

FROM doktl

INTO TABLE text_tab

WHERE doktext LIKE srch_str.

Regards,

Atish

0 Kudos

Thanks guys, U have helped me to fill up the where condition as

but what about the column A in the select query ?I need only 5 characters from the field populated into Itab.

CONCATENATE srch_str '%' INTO srch_str. -- bcos i want it to be 'InputA%'

Select Substr(A,0,5) , B C Into Itab From CustomTable 1 where B = (Select B from customtable2) and A Like SrchStr

Is there any means i can populate only the 5 characters from the select field A into Itab without using Substr (becos it doesnt work) ? Please help.