MODIFY problem

AlkroAlkro Member Posts: 115
I have a little problem with my C/AL Code. I don´t know what's happen.
rTransfer.RESET;
rTransfer.SETRANGE(rTransfer.Section,pTransfer.Section::S1);
rTransfer.SETRANGE(rTransfer.Transfer,FALSE);
rTransfer.SETRANGE(rTransfer.Marked,TRUE);
IF rTransfer.FIND('-') THEN BEGIN
  REPEAT
      //Here, code fill in Table 83 and Register "Item Reclass. Journal
   UNTIL rTransfer.NEXT = 0;
   //Here is the problem. *********
   IF rTransfer.FIND('-') THEN
      REPEAT
           rTransfer.Transfer := TRUE;
           rTransfer.Doc := DocNum;
           rTransfer.Date := WORKDATE;
           rTransfer.Time := TIME;
           rTransfer.MODIFY;
      UNTIL rTransfer.NEXT = 0;
     //***************
Why the last REPEAT only Modify first record??

First REPEAT, do transfer with many lines, but then only modify First...

I can't see the problem... 8)

HNY :)

Answers

  • kapamaroukapamarou Member Posts: 1,152
    Maybe it is this:

    In your loop you modify

    rTransfer.Transfer := TRUE;
    

    which is part of your filter as FALSE;

    This modification messes the sort order and as a result some records are skipped.

    If your version id >= 4.x where you have FINDSET available as a command then you should study the doc for this and use it specifying that you are about to modify key values.

    If your version does not supprt that then you could try the following:

       IF rTransfer.FIND('-') THEN
          REPEAT
               rTransfer.Transfer := TRUE;
               rTransfer.Doc := DocNum;
               rTransfer.Date := WORKDATE;
               rTransfer.Time := TIME;
               rTransfer.MODIFY;
               rTransfer.Transfer := FALSE; //<--- Add this.
          UNTIL rTransfer.NEXT = 0;
    

    I think that if you add the above line it changes the value temporarily to keep the correct sorting order but since it is AFTER the MODIFY the change is not applied.

    Have a go with this and let us know if it was helpful.

    Regards.
  • AlkroAlkro Member Posts: 115
    Working:
    IF rTransfer.FINDSET(TRUE,TRUE) THEN
          REPEAT
               rTransfer2 := rTransfer;
               rTransfer2.Transfer := TRUE;
               rTransfer2.Doc := DocNum;
               rTransfer2.Date := WORKDATE;
               rTransfer2.Time := TIME;
               rTransfer2.MODIFY;
          UNTIL rTransfer.NEXT = 0;
    

    Like example in Nav Help.

    Best Regards
  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    I have replaced the [SOLVED] in your topic title with the Topic Attribute (green checkmark).

    Please set it yourself, the next time one of your questions is solved:
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • AlkroAlkro Member Posts: 115
    ARggggg ](*,)

    Sorry Luc. Next time i will make it!

    BR
Sign In or Register to comment.