learner
26th May 2003, 21:09
Hello,

I have generated a Maintain session using Generate Session & this is saving data in a customized table, now when i open up this session script, i found that no code was written to save the data, but data is getting properly saved.

Now my doubt starts from here , before Saving data i want to make sure that if tdpur045.spur field is having value as 7 then it should not allow to modify the record which is shown on my this customized session, so for this i added in user.choice.modify that go to tdpur045 and check the value, and give the message that the record cannot be saved if the value is 7 in tdpur045.spur field for the feceipt no. specified on the customized session input form...... but how do i stop it from modifying the record since i cannot find any code relating to Saving/ Modification in the program script ???


Does this means that i re-create the script and write my own code to save/ modify the data into this customized table ??

Waiting for your replies,Gurus !!

Ruskin
27th May 2003, 05:33
The standard script does not need code in it to write/read from the tables (the Baan tools handle this), but you are able to add your own code, to modify whether records get saved or not.

There are a couple of options, where you can prevent records from being saved, such as;

choice.update.db:
before.choice:
if tdpur045.spur = 7 then
choice.again()
endif


or you can use;

main.table.io:
before.write:
if tdpur045.spur = 7 then
skip.io("")
endif

before.rewrite:
if tdpur045.spur = 7 then
skip.io("")
endif

the before.write is for a new record being added, whereas the before.rewrite is for updating an existing record. In the skip.io, you can place a message code between the quotes, to have a message displayed to the user, why the record is not updated, if you leave the quotes empty, then it doesn't update the record, but no message is displayed. The choice.update.db is run, when you click on the save button (so is not always the best place to put checks on record updates in this section).

I have attached a text file, that is a copy of the sections that can be used in a 4GL script...

Ruskin
27th May 2003, 05:37
Meant to add; that since you have asked about preventing the record from being modified, if tdpur045.spur is not 7, then you may want to try something like;


choice.modify.set:
before.choice:
if tdpur045.spur = 7 then
message("NO MODIFYING!!!")
choice.again()
endif

choice.delete.set:
before.choice:
if tdpur045.spur = 7 then
message("NO DELETING!!!")
choice.again()
endif


You obviously want to refine this (as you should use message codes instead of hard coding the message plus you may have a multi occurrence form, in which case, you will get multiple messages if you select a range of records to delete, etc...).

learner
27th May 2003, 19:10
thanks as soon as i posted this message, i too did some R&D and was able to finanly figure out the same, anyway once again thanks all of u for helping me.:cool: