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 Single statement not working

Former Member
0 Likes
7,312

Hi,

I have a problem with my select single statement:

SELECT single * FROM setleaf
WHERE setclass = var
AND setname = var1
AND valfrom = vbrk-regio.

SELECT SINGLE * FROM setlinet
WHERE setclass = var
AND setname = var1
AND lineid = setleaf-lineid
AND langu LIKE sy-langu.

Both the select statements are not working. I have more queries that work well. but these last ones do not work.
Please help me. I am a newbie in abap.

The first image is from debugger and after the select, it has not providing result.

The second image is from the table SETLEAF(First select) and you can see with the help of the transaction that you have data.



The third image is from table SETLINET (Second Select) and you can also see the data.

Then I can not find where I'm wrong or what I'm missing

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
4,513

Hello everyone, I found a solution for my problem.

Thank you very much for your comments and help.

The solution was very simple:
In my select statement I just needed to uppercase the value in my where clause for example:

SELECT single * FROM setleaf
WHERE setclass = '0000'
AND setname = 'tax_st'. change to this => 'TAX_ST'
AND valfrom = vbrk-regio.

SELECT SINGLE * FROM setlinet
WHERE setclass = '0000'
AND setname = 'tax_st' change to this => 'TAX_ST'
AND lineid = setleaf-lineid
AND langu LIKE sy-langu.

And problem solved.

Regards.

13 REPLIES 13
Read only

Former Member
0 Likes
4,513

I am not sure about your target structure as you have not mentioned in your query.

But select single * will always return the first records with all the fields of the table matching your where criteria.

If you can write your exact select query then I can let you know the problem.

Currently what is vbrk-region(as you cannot pass the full table) or may be you are trying to just explain.

Not working means -> Not providing result or giving dump?

Read only

0 Likes
4,513

HI,

Thanks for your time.

The select statement It does not return data.
I did tests on transaction se16 and there is data then I do not know what is my error.

Read only

0 Likes
4,513

Pl. do a sy-subrc check against your first SELECT, before proceeding to the next SELECT statement. This is very dangerous statement, in case you plan to do a update on the table based on that, in real time scenario.

Hard code a break-point against your useID, activate and check how the execution goes, and how the tables gets filled.

Could be a change in your logical conditions

Read only

retired_member
Product and Topic Expert
Product and Topic Expert
4,513

What do you want to achieve with

AND langu LIKE sy-langu.

Where are your INTO clauses

???

SELECT is thoroughly documented.

https://help.sap.com/http.svc/rc/abapdocu_752_index_htm/7.52/en-US/index.htm?file=abapselect.htm

Read only

JL23
Active Contributor
0 Likes
4,513

I think he wont get any result either if he copies and pastes your example

Read only

Ankit_Maskara
Product and Topic Expert
Product and Topic Expert
4,513

As suggested by others you have not done your homework of checking already available resources. Please search thoroughly.

You can even look at t-code ABAPDOCU which has various sample program available which you can analyse and debug to creat an understanding of open SQL.

Read only

0 Likes
4,513

believe me I've seen documentation and tried many things, this is why I need help, since I've seen querys similar to mine

Read only

Ankit_Maskara
Product and Topic Expert
Product and Topic Expert
0 Likes
4,513

Open SE16N and enter the values for which you are getting data from SETLEAF table. Then click on display selection criteria which will show the select statement which the standard SAP code generates to fetch the data. Now compare your understanding with same and validate.

Read only

NTeunckens
Active Contributor
4,513

See the Code-Sample by rob.burbank in this old Questions : link

That should work ...

Read only

JL23
Active Contributor
4,513

Assume the box with the holes is your table and the bricks are your variables.

You showed us just the box, but not your variables.

How could anyone know what value you have there and if that matches with the value in the table.

Read only

Former Member
0 Likes
4,513

Hi Andres Gomez,

Go through below syntax. You have written select statement but you doesn't mention workarea or internal table to hold the data records.

* wa_setleaf should be setleaf table structure.

SELECT single * FROM setleaf into wa_setleaf
WHERE setclass = var
AND setname = var1
AND valfrom = vbrk-regio.

* wa_setlinet should be setlinet table structure.
SELECT SINGLE * FROM setlinet into wa_setlinet
WHERE setclass = var
AND setname = var1
AND lineid = setleaf-lineid
AND langu = sy-langu.

Thanks.

Read only

Former Member
0 Likes
4,514

Hello everyone, I found a solution for my problem.

Thank you very much for your comments and help.

The solution was very simple:
In my select statement I just needed to uppercase the value in my where clause for example:

SELECT single * FROM setleaf
WHERE setclass = '0000'
AND setname = 'tax_st'. change to this => 'TAX_ST'
AND valfrom = vbrk-regio.

SELECT SINGLE * FROM setlinet
WHERE setclass = '0000'
AND setname = 'tax_st' change to this => 'TAX_ST'
AND lineid = setleaf-lineid
AND langu LIKE sy-langu.

And problem solved.

Regards.

Read only

Former Member
0 Likes
4,513

I found a solution.