Monthwise number sequence in SO and PO
Refreshing the number sequencing for sales order each month so that sales order creation month can be identified based on the number.
Initial setup:
/// This batch will update the numbersequence format ‘yr/Month/######’ for salesorder number.
///
class Monthwisenumberseq extends RunBaseBatch
{
}
// new method
protected boolean canGoBatchJournal()
{
return true;
}
// new method
public void run()
{
NumberSequenceReference numberseqref;
NumberSequenceTable numberSeqTable;
container segments;
str annotatedFormat, format, datestr;
;
ttsBegin;
datestr = date2str(systemDateGet(),
321,
DateDay::Digits2,
DateSeparator::Slash, // separator1
DateMonth::Short,
DateSeparator::Slash, // separator2
DateYear::Digits4,
DateFlags::None);
datestr = subStr(datestr, 1, strLen(datestr)- 2);
segments = [[-1,datestr]];
segments += [[-2,'######']];
annotatedFormat = NumberSeq::createAnnotatedFormatFromSegments(segments);
format = NumberSeq::createAnnotatedFormatFromSegments(segments, false);
numberseqref = NumberSeqReference::findReference(extendedTypeNum(SalesId));
select firstOnly forupdate numberSeqTable
where numberSeqTable.RecId == numberseqref.NumberSequenceId &&
numberSeqTable.NumberSequenceScope == numberseqref.NumberSequenceScope;
if (numberSeqTable)
{
numberSeqTable.AnnotatedFormat = annotatedFormat;
numberSeqTable.Format = format;
numberSeqTable.NextRec = 1;
numberSeqTable.doUpdate();
}
ttsCommit;
}
// new method
public static ClassDescription description()
{
return “Monthwise numbersequence”;
}
// new method
public server static void main(Args _args)
{
Monthwisenumberseq monthwisenumberseq = new Monthwisenumberseq();
if (monthwisenumberseq.prompt())
{
monthwisenumberseq.run();
}
}
Initial setup:
///
class Monthwisenumberseq extends RunBaseBatch
{
}
// new method
protected boolean canGoBatchJournal()
{
return true;
}
// new method
public void run()
{
NumberSequenceReference numberseqref;
NumberSequenceTable numberSeqTable;
container segments;
str annotatedFormat, format, datestr;
;
ttsBegin;
datestr = date2str(systemDateGet(),
321,
DateDay::Digits2,
DateSeparator::Slash, // separator1
DateMonth::Short,
DateSeparator::Slash, // separator2
DateYear::Digits4,
DateFlags::None);
datestr = subStr(datestr, 1, strLen(datestr)- 2);
segments = [[-1,datestr]];
segments += [[-2,'######']];
annotatedFormat = NumberSeq::createAnnotatedFormatFromSegments(segments);
format = NumberSeq::createAnnotatedFormatFromSegments(segments, false);
numberseqref = NumberSeqReference::findReference(extendedTypeNum(SalesId));
select firstOnly forupdate numberSeqTable
where numberSeqTable.RecId == numberseqref.NumberSequenceId &&
numberSeqTable.NumberSequenceScope == numberseqref.NumberSequenceScope;
if (numberSeqTable)
{
numberSeqTable.AnnotatedFormat = annotatedFormat;
numberSeqTable.Format = format;
numberSeqTable.NextRec = 1;
numberSeqTable.doUpdate();
}
ttsCommit;
}
// new method
public static ClassDescription description()
{
return “Monthwise numbersequence”;
}
// new method
public server static void main(Args _args)
{
Monthwisenumberseq monthwisenumberseq = new Monthwisenumberseq();
if (monthwisenumberseq.prompt())
{
monthwisenumberseq.run();
}
}
Very informative Blog! There is so much information here that can help thank you for sharing. custom erp development
ReplyDelete