2

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.

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
kookies
  • 61
  • 2
  • 3
  • 8

1 Answers1

7

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.

Tiago A.
  • 1,392
  • 1
  • 16
  • 26
  • 1
    Correct, at that point you have not yet filled in wa_sflight, but you do have the values of wa_spfli. – tomdemuyt Jan 05 '12 at 21:08
  • thank you! stupid mistake :) I thought the "carrid" comes from spfli and thus i need it to compare with sflight. – kookies Jan 06 '12 at 15:37