
import AP.Common.GDT as apCommonGDT;
businessobject NumberRange {
// Used to distinguish between different number ranges.
[AlternativeKey] element Topic:ID;
// Constant prefix of the generated number.
element Prefix : LANGUAGEINDEPENDENT_EXTENDED_Text;
element PrefixSeparatedByBlank : Indicator;
// The (formatted) number itself.
element Number : LANGUAGEINDEPENDENT_EXTENDED_Text;
// If true, a blank will be placed between the formatted number and the suffix.
element SuffixSeparatedByBlank : Indicator;
element Suffix : LANGUAGEINDEPENDENT_EXTENDED_Text;
// Latest generated number (Prefix + Number + Suffix).
element PresentValue : LANGUAGEINDEPENDENT_EXTENDED_Text;
// Counter for the number generation itself.
element Counter : IntegerValue;
// Minimum and maximum values of the counter.
element MinValue : IntegerValue;
element MaxValue : IntegerValue;
// true as long as we haven't reached the maximum value of the counter.
element Ready : Indicator;
action GenerateNextNumber;
action InitializeInstance;
}
import ABSL;
if(!this.Topic.IsInitial()){
this.Prefix = this.Topic;
this.Suffix = "";
this.PrefixSeparatedByBlank = false;
this.SuffixSeparatedByBlank = false;
this.MaxValue = 999999999;
this.MinValue = 1;
this.Ready = true;
}
import ABSL;
var lv_sFormat = "";
var lv_sAux;
if (this.Ready) {
if(!this.MinValue.IsInitial()){
if(!this.MaxValue.IsInitial()){
if(this.MinValue < this.MaxValue){
// Initialize the counter in case the object is new.
if (this.Number.Length() == 0) {
this.Counter = this.MinValue - 1;
}
this.Counter = this.Counter + 1;
this.Number = this.Counter.ToString();
// Put the new value together.
if (this.Prefix.Length() > 0) {
if (this.PrefixSeparatedByBlank) {
lv_sAux = this.Prefix + " ";
}
else {
lv_sAux = this.Prefix;
}
}
else {
lv_sAux = "";
}
lv_sAux = lv_sAux + this.Number;
if (this.Suffix.Length() > 0)
{
if (this.SuffixSeparatedByBlank) {
lv_sAux = lv_sAux + " ";
}
this.PresentValue = lv_sAux + this.Suffix;
}
else {
this.PresentValue = lv_sAux;
}
if (this.Counter == this.MaxValue) {
this.Ready = false;
}
}
}
}
}
import ABSL;
var lv_my_topic: NumberRange.Topic;
var lo_number_range;
if (this.AgreementID.IsInitial()) {
lv_my_topic = "JerryBO";
lo_number_range = NumberRange.Retrieve(lv_my_topic);
if(!lo_number_range.IsSet()) {
lo_number_range = NumberRange.Create();
lo_number_range.Topic = lv_my_topic;
lo_number_range.InitializeInstance();
}
if(lo_number_range.Ready==true) {
lo_number_range.GenerateNextNumber();
this.AgreementID = lo_number_range.PresentValue;
return;
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
4 | |
3 | |
2 | |
2 | |
2 | |
2 | |
2 | |
1 | |
1 | |
1 |