Application Development 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 first row of internal table directly with matching conditions

rajeev_anandan
Explorer
0 Kudos

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

1 ACCEPTED SOLUTION

Juwin
Active Contributor
0 Kudos

This?

LOOP AT <lt_xvbap> INTO ls_vbapvb WHERE ( abgru <> '' AND pstyv IN lr_pstyv ).
  EXIT.
ENDLOOP.
3 REPLIES 3

Juwin
Active Contributor
0 Kudos

This?

LOOP AT <lt_xvbap> INTO ls_vbapvb WHERE ( abgru <> '' AND pstyv IN lr_pstyv ).
  EXIT.
ENDLOOP.

0 Kudos

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.

zeshanshafqat79
Active Participant
0 Kudos

use a (select distinct ) then you see only one row and skip other

Deputy Manager (SAP BI/BW and SAP Analytics Cloud)