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: 

Fetching records from PA0001 table using field SNAME

Former Member
0 Kudos

Dear Gurus,

I suppose to make a web service using FM which take input of name and in return, deliver all information about that name from PA0001 and PA0002. How can i do this?

For example: There are 2 record of names "ABC XYZ" and "ABC EFG" in PA0001. Field is SNAME in PA0001. But it can only bring record if we give full name to field SNAME like "ABC XYZ". But i want that if user enter just "ABC" it bring all records that have name "ABC". I mean if i pass just "ABC" to field SANAME, it should bring  "ABC XYZ" and "ABC EFG".

how can i write a select query for this purpose. I tried using this but it does not work.

select * from PA0001 into CORRESPONDING FIELDS OF TABLE itab

   where SNAME = ' *ABC* ' .

How can i do this? Kindly help.

Regards

1 ACCEPTED SOLUTION

former_member183607
Contributor
0 Kudos

Hi,

     You May Use like operator to achieve pattern

select * from PA0001 into CORRESPONDING FIELDS OF TABLE itab

   where SNAME like ' ABC% ' .

8 REPLIES 8

former_member183607
Contributor
0 Kudos

Hi,

     You May Use like operator to achieve pattern

select * from PA0001 into CORRESPONDING FIELDS OF TABLE itab

   where SNAME like ' ABC% ' .

0 Kudos

Dear Somendra,

hanks for your reply

Does it work like *ABC*?

I checked the way you said with one name. It brought 21 records from PA0001 , however, there are 89 records of that name in PA0001. I think your suggested way work like ABC* but i want something that work like *ABC*.

Regards

0 Kudos

Hi ,

     Put % inplace of *.

     Like '%ABC%'

0 Kudos

Dear Somendra,

Thanks fro your reply. I want to ask one thing. The web service that i am making , suppose to return employee details on input parameters of Employee number, employee name, email, designation and department. So what you think. Using Select * from like %" is best for this purpose?? will select queries work fine? any other idea you have or shall i proceed with this?

Regards

0 Kudos

Hi Imran,

Yes. You can use LIKE % for all the fields mentioned above in the post in WHERE condition of SELECT QUERY.

Thanks.

0 Kudos

Dear Naveen,

I want to ask one more thing. If there is sentence like *abc efg xyz*, and if i want to convert it like this,  %abc%efg%xyz.    HOW CAN I DO THAT?

LET ME KNOW PLEASE.

Regards

0 Kudos

Hi Imran,

If the space between abc efg xyz should be the preserved then it is better to use %abc efg xyz% for the search. This is because if you use %abc%efg%xyz% then other words like abcdefghxyz will also be considered. Let me know for more information.

thanks

0 Kudos

In the sql condition, "%" represents any character string, even an empty one, and "_" represents any character. So you can play with CONCATENATE or REPLACE statement to adapt your code.

Regards,

Raymond