Modify problem

tobarichtobarich Member Posts: 33
Hi all, I have a report which updates a record from a setup table. This table has only one record and the mentioned report updates only one column of this record.
The problem is that i was doing some test and commented the line that makes table.GET but let the sentence table.MODIFY. After I ran the report the record of the table was blank.
Something like this:
// table.GET  -> line commented
...

table.column := newvalue;
table.MODIFY;

Has anyone suffered this problem before?
Thanks

Comments

  • matttraxmatttrax Member Posts: 2,309
    That is weird. I tried it myself and got the same result.

    Without a GET or FIND no record should have been retrieved and thus there should be no record to modify.

    I assume that MODIFY looks for a record with that primary key if one has not been retrieved. Since the key for most setup tables is a blank column I could potentially see that happening.

    This code blanks the record:
    Setup.MODIFY;
    MESSAGE('%1', Setup);
    

    This code produces an error because a record does not exist:
    Setup.Key := 'TEST';
    Setup.MODIFY;
    MESSAGE('%1', Setup);
    
  • krikikriki Member, Moderator Posts: 9,110
    Very weird indeed. I would have expected an error saying something like 'record has been changed by another user'.

    You should notify MS about it. Probably you hit a bug.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • jlandeenjlandeen Member Posts: 524
    My question to you is the table variable in your code example a variable or one of the data items on the report? If it's a variable then I would be surprised as I would expect it to fail - as there's no record retrieved yet to modify...however if it's a Data Item then I think it makes sense.

    A report is expected to retrieve and loop through all available records in a given data item. So if the code you refer to is in the OnAfterGetRecord of the Data Item then a record has been retrieved then regardless of whether you explicitly issued a get statment a record should have been retrieved.
    Jeff Landeen - Sr. Consultant
    Epimatic Corp.

    http://www.epimatic.com
  • krikikriki Member, Moderator Posts: 9,110
    I did the same thing with a form (without sourcetable!). I defined a global with the setup-record and in the OnOpenForm, I just put MODIFY and the record was changed!
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


Sign In or Register to comment.