Code แบบ Check เอา
- loopBatch = dlfBatchId.value();
- countBatch = strlen(loopBatch);
- if(countBatch == 10){
- //Split String
- findStrBatch = StrFind(loopBatch, "-", 1 , 10);
- subStrFirstBatch = SubStr(loopBatch, findStrBatch - 1, -6);
- subStrLastBatch = SubStr(loopBatch, findStrBatch + 1, 3);
- for(loop = 0; loop < dlfRun.value(); loop++){
- //insert into InventBatch table.
- SELECT * FROM inventBatch;
- inventBatch.inventBatchId = strfmt("%1-%2", subStrFirstBatch, subStrLastBatch);
- inventBatch.itemId = dlfItemNo.value();
- inventBatch.insert();
- //Conver Format Number.
- loopBatchConvert = Str2Num(subStrLastBatch);
- if(loopBatchConvert < 10){
- subStrLastBatch = strfmt("00%1",Int2Str(Str2Num(subStrLastBatch) + 1));
- } else {
- if(loopBatchConvert > 10 && loopBatchConvert < 100){
- subStrLastBatch = strfmt("0%1",Int2Str(Str2Num(subStrLastBatch) + 1));
- } else {
- subStrLastBatch = Int2Str(Str2Num(subStrLastBatch) + 1);
- }
- }
- }
- }
แบบที่ 2 ใช้ Function StrRfix
- str strRfix(str _str, int _length [, char _char])
- for(loop = 0; loop < dlfRun.value(); loop++){
- //insert into InventBatch table.
- SELECT * FROM inventBatch;
- inventBatch.inventBatchId = strfmt("%1-%2", subStrFirstBatch, subStrLastBatch);
- inventBatch.itemId = dlfItemNo.value();
- inventBatch.insert();
- //Conver Format Number.
- subStrLastBatch = StrRfix(Int2Str(Str2Num(subStrLastBatch)+ 1), 3, "0");
- }
http://www.axaptapedia.com/StrRfix
ไม่มีความคิดเห็น:
แสดงความคิดเห็น