11-21-2007 3:16 AM
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
11-21-2007 3:28 AM
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.
11-21-2007 3:37 AM
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
11-21-2007 3:42 AM
11-21-2007 3:48 AM
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
11-21-2007 5:05 AM
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.