Via the function dal_wdh_wri_lis you can write records which were newly created (insert operation) or edited (update operation) in DataView into the data base. DataView realizes for each records with the help of the content of the internal record ident number, which kind of operation you execute for the data base table:
If you executed an update operation, the record ident number remains unchanged. If you executed an insert operation, DataView will assign a new record ident number. It will be automatically entered into the internal ident number field of the mask.
To improve speed when writing changed mask data into the data base, DataView features so-called dirty-flags. There are field dirty flags and record dirty flags. DataView automatically sets both flags at any interactive editing as soon as a record has been changed by the user. For in case of the program-controlled editing of records and fields no interaction of user occurs, you will have to manually set the dirty flags. If you finished the edit operation and DataView returns into the standard event loop, all dirty flags set will be reset to zero by the system.
For each field in a mask there is a field-dirty-flag. It marks the state of the field regarding its field contents. A field can be »clean« (drt = 0) or »modified« (drt = m).
When storing changed records (update operation) DataView only writes those field contents back into the data base, whose field-dirty-flags are set to »modified«. This means that after modifying a field content via a userexit the corresponding field-dirty-flag must always be set to drt = m if the changes are to be saved to the data base. The field-dirty-flag always refers to all field contents of a field. So if you alter field contents in the column record buffer of a field for several records, you only have to set the corresponding field-dirty-flag once. To do so, use the function dal_mas_set_drt_fld.
If - because of wrong entries or transaction problems - it is not possible to write a field contents into the data base, the field-dirty-flag remains set after returning from the function dal_wdh_wri_lis (drt = m). In case of success the field-dirty-flag will be automatically reset by DataView (drt = 0). Using the function dal_mas_ret_drt_fld you can enquire the record-dirty-flag for each record.
When creating new records in the mask (insert operation) DataView does not evaluate the field-dirty-flags and always writes all field contents of the newly created records into the data base.
For each record in a mask there is a record-dirty-flag. It marks the state of the record as »clean« (drt = 0), »selected« (drt = +), or »modified« (drt = m).
Record-dirty-flags only exist in lists. In forms the field-dirty-flags are sufficient to uniquely mark changed field contents of the visible records.
When storing changed records and when creating new records DataView only writes those row entries back into the data base whose record-dirty-flags are set to »modified«. This means that after modifying the field contents of a record via a userexit, or after creating a new record via userexit - in addition to the corresponding field-dirty-flag - the corresponding record-dirty-flag must always be set to drt = m if the changes are to be saved to the data base. To do so use the function dal_mas_set_drt_rec.
If - because of wrong entries or transaction problems - it is not possible to write a field contents into the data base, the record-dirty-flag remains set after returning from the function dal_wdh_wri_lis (drt = m). In case of success the record-dirty-flag will be automatically reset by DataView (drt = 0). Using the function dal_mas_ret_drt_rec you can enquire the record-dirty-flag for each record.
The state »selected« (drt = +) can only be applied to mark a record as selected analogous to the interactive procedure. This is necessary whenever you want to execute functions expecting selected records in the widget (as for instance delete records with dal_wdh_del_lis).
Example: The figure shows an example for the application of the dirty flags for update and insert operations.
In the upper mask the user has selected two records and set them into mask edit state, but he only edited field contents biopsy forceps of the description field of record 002. Prior to the data base transaction DataView sets only the record-dirty-flag of the record 002 to m, while the record-dirty-flag of the record 004 remains unchanged as + = »selected«. For the field description has been modified, DataView also sets the corresponding field-dirty-flag to m = »modified«. If the user stores his changes, evaluating both dirty flags DataView realizes that only the changed field contents biopsy forceps must be written back into the data base.
In the lower mask the user has inserted a new record in the mask. It is automatically shifted into mask edit state for entering new field contents. Prior to the data base transaction DataView sets the record-dirty-flag of the new record 005 to m. If the user enters new field contents after inserting, DataView will set the corresponding field-dirty-flags, but only evaluates the record-dirty-flag for storing and writes all field contents of the newly created record into the data base.