09-20-2022 10:32 AM
Hi experts,
I'm having a requirement to read the first row of an internal table with some matching conditions. Please find the code snippet which I had written below.
DATA(lt_vbapvb) = VALUE va_vbapvb_t( FOR ls_vbapvb IN <lt_xvbap>
WHERE ( abgru <> '' AND pstyv IN lr_pstyv )
( ls_vbapvb ) ).
DATA(ls_vbapvbb) = VALUE #( lt_vbapvb[ 1 ] OPTIONAL ).
Here I am reading all the matching rows from <lt_xvbap> into a temporary internal table lt_vbapvb first. After that I am reading the first row from this internal table.
I would like to know if the same functionality can be achieved in a single statement by using ABAP 7.4 syntax rather than splitting into two different statements.
Thanks in advance,
Rajeev
09-21-2022 12:58 AM
This?
LOOP AT <lt_xvbap> INTO ls_vbapvb WHERE ( abgru <> '' AND pstyv IN lr_pstyv ).
EXIT.
ENDLOOP.
09-21-2022 12:58 AM
This?
LOOP AT <lt_xvbap> INTO ls_vbapvb WHERE ( abgru <> '' AND pstyv IN lr_pstyv ).
EXIT.
ENDLOOP.
09-21-2022 7:10 AM
Thanks a lot juwin.thomas2 . Appreciate your help.
It is working fine. Just wanted to know if the same functionality can be achieved by ABAP 7.4 syntax via FOR loop instead of Loop..Endloop.
09-21-2022 5:44 AM
use a (select distinct ) then you see only one row and skip other