cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

SELECT CASE | Nested query

miske
Participant
0 Likes
2,340

Hello everyone,
I need some help with syntax in ABAP

1111111111111333333333333.png

Is there a way to write another select statement here?


To put more context to it, I have multiple rows in a table for the same document (4 rows for example). For 2 of them AUFNR is INITIAL, for other 2 is the same number '0001' (but for other docs its diff number). I need to set so all 4 rows have the same value for AUFNR ('0001').

Accepted Solutions (0)

Answers (1)

Answers (1)

retired_member
Product and Topic Expert
Product and Topic Expert
0 Likes

Subqueries cannot be used in the SELECT list.

https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abensubquery_glosry.h...

For combining SELECT lists from different sources, Joins can be used.Maybe you can do something with UNION?

miske
Participant
0 Likes

Dear Horst,
thank you so much for answering. I did try using UNION but I had no luck getting the needed result. Like I said I need to change the value of one record from the select list. If this was a SAP HANA sql I would try something like this

SELECT acdoca~RLDNR,

acdoca~RBUKRS,
acdoca~GJAHR,

acdoca~BELNR,

(SELECT top 1 aufnr FROM acdoca WHERE aufnr is not initial ) as aufnr,

acdoca~REBZG,

acdoca~AWREF

FROM acdoca

INTO TABLE @it_acdoca.

This also might not work bcuz I need to specify for witch document number is he getting AUFNR.
Since this can't be used in ABAP, can you, please write me a code sample of what I could do to solve this without losing any records (I need to get those sets where the AUFNR is initial but to change that so it has value) ? 🙂
Best regards.