Skip to Content
avatar image
-6
Former Member

Select Single statement not working

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

6 Answers

  • Best Answer
    Nov 16, 2017 at 09:18 PM

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

    That should work ...

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 16, 2017 at 09:57 PM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 16, 2017 at 06:03 PM

    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.

    Add comment
    10|10000 characters needed characters exceeded

    • 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.

  • 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?

    Add comment
    10|10000 characters needed characters exceeded

    • 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

  • 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.

    Add comment
    10|10000 characters needed 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.

    Add comment
    10|10000 characters needed characters exceeded