Options

Blank Temp Record after insert

BeliasBelias Member Posts: 2,998
this is the code: why the first message returns the "Lot no." and the second returns blank? the variable TBEntrySummTemp is declared ONLY as global
nav version: 2009 sp1 build 30212.
the code is not the cleanest one, but i plan to clean it up after i solve the problem...i'm probably missing something stupid, but tomorrow i'll start my holiday and i've been "half-ill" the whole week...my brain is a bit tired :(
//variables: VAR vTBEntrySummTemp - not temporary here, but temporary in the calling function
CLEAR(TBEntrySummTemp);
vTBEntrySummTemp.COPY(TBEntrySummTemp,TRUE);

//check if the table is temporary before deleting all the records
RRCheckEmpty.GETTABLE(TBEntrySummTemp);
IF NOT RRCheckEmpty.ISTEMPORARY THEN
  ERROR('Warning!TBEntrySummTemp variable must be Temporary!!!');

TBEntrySummTemp.RESET;
TBEntrySummTemp.DELETEALL;

IF TBItem.GET("Item No.") THEN BEGIN
  TBItemLedgEntry.SETCURRENTKEY("Item No.","Serial No.","Lot No.",Open,"Variant Code",
                                Positive,"Location Code","Posting Date","Expiration Date");
  TBItemLedgEntry.SETRANGE("Item No.","Item No.");
  TBItemLedgEntry.SETFILTER("Lot No.",'<>%1','');
  TBItemLedgEntry.SETRANGE("Serial No.",'');
  TBItemLedgEntry.SETFILTER("Location Code",
                            TBRentContrLines.FNTCreateLocationFilter(UserSetupMgt.GetSalesFilter,TBItem."Item Category Code"));
  TBItemLedgEntry.FINDSET;
  REPEAT
    TBItemLedgEntry.SETRANGE("Lot No.",TBItemLedgEntry."Lot No.");
    TBItemLedgEntry.CALCSUMS("Remaining Quantity");
    IF TBItemLedgEntry."Remaining Quantity" > 0 THEN BEGIN
      TBEntrySummTemp."Entry No." += 1;
      TBEntrySummTemp."Lot No." := TBItemLedgEntry."Lot No.";
      MESSAGE(TBEntrySummTemp."Lot No.");
      RESET;
      SETRANGE("Lot No.",TBEntrySummTemp."Lot No.");
      IF FINDFIRST THEN
        TBEntrySummTemp."Selected Quantity" := Quantity;
      TBEntrySummTemp."Total Available Quantity" := TBItemLedgEntry."Remaining Quantity";
      TBEntrySummTemp.INSERT;
      MESSAGE(TBEntrySummTemp."Lot No.");
    END;
    TBItemLedgEntry.FINDLAST;
    TBItemLedgEntry.SETFILTER("Lot No.",'<>%1','');
  UNTIL TBItemLedgEntry.NEXT = 0;
END;
thanks in advance
-Mirko-
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog

Comments

  • Options
    vijay_gvijay_g Member Posts: 884
    RESET; //which recvar it has reset.
  • Options
    BeliasBelias Member Posts: 2,998
    rec variable, there are no "WITH" instruction.
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • Options
    krikikriki Member, Moderator Posts: 9,098
    First : copy the first message over the second one so they are completely the same.
    Second: I think that the FINDFIRST cleans the global variables. So better use another variable instead of rec.FINDFIRST. Or make your all your global variables local.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • Options
    BeliasBelias Member Posts: 2,998
    First: messages are the same... :thumbsup:
    Second: i was going down this line of development, but only because of a "sixth sense"
    anyway, can you explain me why does it happen? (i remember a post of mattrax -maybe- who said that the modify of the record clears the variables within it, but i don't know if it's related...)
    thanks!
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • Options
    krikikriki Member, Moderator Posts: 9,098
    I don't think the modify does that but getting a new record does clear the global variables (NOT the local variables in the function where you are doing a GET or FIND* or NEXT ) in it. Getting a new record seems to do a CLEAR.
    Remember that CLEAR (and I think also GET or FIND* or NEXT) does NOT clear the records in a global temptable in your record.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • Options
    BeliasBelias Member Posts: 2,998
    kriki wrote:
    I don't think the modify does that but getting a new record does clear the global variables (NOT the local variables in the function where you are doing a GET or FIND* or NEXT ) in it. Getting a new record seems to do a CLEAR.
    Remember that CLEAR (and I think also GET or FIND* or NEXT) does NOT clear the records in a global temptable in your record.
    i finally found the topic i couldn't find in the post before...where you (not mattrax) told that "The globals are cleared between the OnValidate and the OnModify (just tried it out)."
    that said, it was not the MODIFY instruction, as i remembered, but between the 2 triggers...just to make it clear, and to link that topic, that can be more helpful if linked to this one :thumbsup:
    http://www.mibuso.com/forum/viewtopic.php?f=23&t=41868
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
Sign In or Register to comment.