Many times we face the challenge to develop a logic for auto incremental of a field and achieve it by doing many permutations and combinations.
Here is my attempt to build a common logic.
Before going to the logic we should have the knowledge of following variables:-
1) filled.occ (It is number of filled occurrences or the count of records displayed on a form at a time.)
2) actual.occ (It is the occurrence number currently selected on form.)
The Code.
extern domain tcsrnb temp.seqn, new.seqn1, new.seqn2
choice.add.set:
before.choice:
temp.seqn = 0
new.seqn1 = get.next.seqn() - 1
new.seqn2 = filled.occ
field.<FieldName>:
before.input:
if filled.occ = 1 then
temp.seqn = 0
new.seqn1 = get.next.seqn() - 1
new.seqn2 = filled.occ - 1
endif
<FieldName> = new.seqn1 + actual.occ - new.seqn2
function domain tcsrnb get.next.seqn()
{
if temp.seqn = 0 then
select max sequence of field
from table
where Condition
selectdo
temp.seqn = (max sequence of field) + 1
return(temp.seqn)
endselect
temp.seqn = 1
return(1)
else
if <FieldValue> <> 0 then
return(<FieldValue>)
else
temp.seqn = temp.seqn + 1
return(temp.seqn)
endif
endif
}
:) Just do these and enjoy!!!!!!!
Here is my attempt to build a common logic.
Before going to the logic we should have the knowledge of following variables:-
1) filled.occ (It is number of filled occurrences or the count of records displayed on a form at a time.)
2) actual.occ (It is the occurrence number currently selected on form.)
The Code.
extern domain tcsrnb temp.seqn, new.seqn1, new.seqn2
choice.add.set:
before.choice:
temp.seqn = 0
new.seqn1 = get.next.seqn() - 1
new.seqn2 = filled.occ
field.<FieldName>:
before.input:
if filled.occ = 1 then
temp.seqn = 0
new.seqn1 = get.next.seqn() - 1
new.seqn2 = filled.occ - 1
endif
<FieldName> = new.seqn1 + actual.occ - new.seqn2
function domain tcsrnb get.next.seqn()
{
if temp.seqn = 0 then
select max sequence of field
from table
where Condition
selectdo
temp.seqn = (max sequence of field) + 1
return(temp.seqn)
endselect
temp.seqn = 1
return(1)
else
if <FieldValue> <> 0 then
return(<FieldValue>)
else
temp.seqn = temp.seqn + 1
return(temp.seqn)
endif
endif
}
:) Just do these and enjoy!!!!!!!
No comments:
Post a Comment