Auto increment of sequence number
Sometime in grid or scroll, we need to write peoplecode on a field which stores unique number every time when we click on add new row button. Below code can be used to achieve this functionality:
Local Rowset &rowset;
&rowset = GetLevel0()(1).GetRowset(Scroll.TEST);
&count = 0;
For &i = 1 To &rowset.ActiveRowCount
If &count < &rowset(&i).TEST.SEQNBR.Value Then
&count = &rowset(&i).TEST.SEQNBR.Value;
End-If;
End-For;
&rowset(CurrentRowNumber()).TEST.SEQNBR.Value = &count + 1;
TEST is name of grid or scroll. Auto increment number will start from 0 if you want that it will start from 1 or any other number, assigned that value &count variable after declaring rowset.
No comments:
Post a Comment