Using strPoke and strRFix function Generating serial number
Wrote by Jimmy on Jan.26th 2011
static void Jimmy_JournalSerialNumber(Args _args) { name maxNum,NumStr,strDate,name01,name02; int i = 1; String30 MaxRelationId(Str 10 _YearMonthDay) { QVS_BatchManageReportHeader BatchManageReportHeader ; ; select maxof(RelationId) from BatchManageReportHeader where BatchManageReportHeader.RelationId like 'BAT'+ _YearMonthDay+ '*'; return BatchManageReportHeader.RelationId; } ; StrDate = date2str(systemDateget(),321,2,0,2,0,4);//20110126 //BAT20101219001 //strDate = "20101219"; print strDate; maxNum = MaxRelationId(strDate);//QVS_BatchManageReportHeader::MaxRelationId(strDate); print maxNum; if(maxNum) NumStr = substr(maxNum,strlen(maxNum),-3);//截取字符串最后3个字符 NumStr = int2str(str2int(NumStr) + 1); print NumStr; print strlen(NumStr); name01 = strfmt("%1%2%3",'BAT',strDate,strPoke('000',NumStr,4 - strLen(NumStr))); name02 = strfmt("%1%2%3",'BAT',strDate,strRFix(NumStr, 3, "0")); print name01; print name02; print strlen(name02); //BAT + 年 + 月 + 日 + 三位数的序列号 // 3 + 4 + 2 + 2 + 3 = 14 pause; }