Loop At <itab> TO <wa> Where <cond> does not find lines

27,732

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.

Share:
27,732
kookies
Author by

kookies

Updated on July 15, 2022

Comments

  • kookies
    kookies almost 2 years

    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.

  • tomdemuyt
    tomdemuyt over 12 years
    Correct, at that point you have not yet filled in wa_sflight, but you do have the values of wa_spfli.
  • kookies
    kookies over 12 years
    thank you! stupid mistake :) I thought the "carrid" comes from spfli and thus i need it to compare with sflight.