4 Replies Latest reply: Sep 5, 2016 5:49 AM by Friedrich Hofmann RSS

    Problem in a LOOP

    Friedrich Hofmann

      Hi,

       

      in the script I'm currently working on, there is a FOR_NEXT loop. In this instance, there are 43 records in the table I'm reading for the counter - so there are 43 items (>>Tracks<<), all of which share one common number (>>Serial_Lot_Number<<);

      => For each Track, I want to have a variable that I can consequently use to filter a table, and I want to incorporate the counter in the table_name, so I would end up with 43 tables.

      The issue is, currently, the loop in itself works fine (I can step through it from 1 to 44), now I have just moved the closing >>NEXT i<< to after that LOAD I want to filter on the variable.

      Something is wrong, however: Now, the first iteration runs fine, the table is called [tablename]_1 - on the second iteration, however, the variables are both set to NULL - and the LOAD is repeated again and again, always with the same filters and the same tablename ...

       

      The relevant part of my script is this:

       

      // Die Hilfstabelle mit den Tracks gehen wir jetzt durch und machen bei jedem Datensatz
      // zuerst mal eine Variable aus dem Track, die wir später verwenden können.

      FOR i = 1 TO $(v_Tracks_from_del)
      LET v_current_Track = PEEK('Track', ($(i)-1), Aux_Tracks);
      LET v_Serial_Lot = PEEK('Serial_Lot', ($(i)-1), Aux_Tracks);
      // Die Schleife können wir natürlich erst dann wieder zumachen, wenn
      // die gesamte Bearbeitung abgeschlossen ist.


      // Jetzt laden wir die Transaktionstabelle einfach noch mal, um alle Buchungen rauszukriegen,
      // die an dieser Ware vorgenommen wurden;
      // Dabei filtern wir auf die Sachnr. und auf den aktuellen Track.

      Transaktionen_Archiv_
      $(i):
      LOAD
      ITEM_NUMBER,
      %ITEM_NUMBER,
      TRAN_DATE_TD,
      TRAN_DATE_Time,
      TRAN_CODE,
      QUANTITY,
      BIN,
      TRACKING_NUMBER,
      CONTROL_NUMBER,
      SERIAL_LOT_NUMBER,
      shift
      FROM
      \\rgb1app202\production\01_QVD\QVD\TransDtl_A163_Archiv.qvd
      (
      qvd)
      WHERE SERIAL_LOT_NUMBER = '$(v_Serial_Lot)'
      AND   TRACKING_NUMBER = '$(v_current_Track)'
      ;

      NEXT i


      EXIT Script;

       

      Can anyone help me there? Sorry I cannot post a sample of this main table that I want to filter, only of the small auxiliary_table which I use for the LOOP.

      Thanks a lot!

      Best regards,

       

      DataNibbler