Loop At <itab> TO <wa> Where <cond> does not find lines
-
14-04-2021 - |
Question
I have a problem with Loop through a using the condition that an attribute from one table is the same with the other. For better explaining i'll past the code. Is not something difficult but i don't understand where i make the mistake.
LOOP AT gt_spfli INTO wa_spfli.
AT NEW carrid.
WRITE:/ wa_spfli-carrid.
ENDAT.
LOOP AT gt_sflight INTO wa_sflight WHERE carrid EQ wa_sflight-carrid.
WRITE:/ wa_sflight-carrid,
wa_sflight-connid,
wa_sflight-price.
ENDLOOP.
ULINE.
ENDLOOP.
For every carrid in spfli i want to show what sflight contains for that carrid. But it only writes the wa_spfli-carrid. It never gets to second write. When i do debugging i get that wa_sflight is always empty. ( or never gets to it ) gt_sflight and gt_spfli is populated so where does the problem comes from? If i remove the "where carrid EQ wa_sflight-carrid" works... but is not what i want to be shown on screen.
Additional info ( don't know if it's useful ): the gt_spfli and gt_sflight is populated through a function module i made myself.
Solution
On the inner loop, you want to compare carrid with wa_spfli-carrid (which comes from the outer loop) and not with wa_sflight-carrid.