Skip to Content
-6

Select Single statement not working

Nov 16, 2017 at 03:59 PM

229

avatar image
Former Member

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

10 |10000 characters needed characters left characters exceeded

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

2
Former Member

I found a solution.

0
* Please Login or Register to Answer, Follow or Comment.

6 Answers

Best Answer
Nic Teunckens Nov 16, 2017 at 09:18 PM
1

See the Code-Sample by Former Member in this old Questions : link

That should work ...

Share
10 |10000 characters needed characters left characters exceeded
Jürgen L
Nov 16, 2017 at 09:57 PM
4

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.

Share
10 |10000 characters needed characters left characters exceeded
Ankit Maskara
Nov 16, 2017 at 06:03 PM
0

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.

Show 2 Share
10 |10000 characters needed characters left characters exceeded
Former Member

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

0

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.

0
avatar image
Former Member Nov 16, 2017 at 04:15 PM
-1

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?

Show 2 Share
10 |10000 characters needed characters left characters exceeded
Former Member

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.

0

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

0
avatar image
Former Member Nov 18, 2017 at 10:28 PM
-1

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.

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Nov 17, 2017 at 03:21 PM
-2

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.

Share
10 |10000 characters needed characters left characters exceeded