ErrorIfUnableToClearWIP(ProdOrder : Record "Production Order") ProdOrderLine.SETRANGE(Status,ProdOrder.Status); ProdOrderLine.SETRANGE("Prod. Order No.",ProdOrder."No."); IF ProdOrderLine.FIND('-') THEN REPEAT IF NOT OutputExists(ProdOrderLine) THEN IF MatrOrCapConsumpExists(ProdOrderLine) THEN BEGIN //ERROR(Text009,ProdOrderLine."Line No.",ToProdOrder.TABLECAPTION,ProdOrderLine."Prod. Order No."); // change above error(... , to message(... , as line below MESSAGE(Text009,ProdOrderLine."Line No.",ToProdOrder.TABLECAPTION,ProdOrderLine."Prod. Order No."); //jm.2010 0302 : . . . . . . . . . . s t a r t . . . . . . . . . . IF NOT DIALOG.CONFIRM('Create required output journal by system?', FALSE) THEN ERROR(Text009,ProdOrderLine."Line No.",ToProdOrder.TABLECAPTION,ProdOrderLine."Prod. Order No."); itemjnl.SETFILTER("Journal Template Name",'OUTPUT'); itemjnl.SETFILTER("Journal Batch Name",'DEFAULT'); IF itemjnl.FIND('+') THEN ln := itemjnl."Line No." ELSE ln := 0; itemjnl."Journal Template Name" := 'output'; itemjnl."Journal Batch Name" := 'default'; itemjnl."Line No." := ln + 10000; itemjnl."Posting Date" := TODAY; itemjnl.INSERT; itemjnl.MODIFY; itemjnl.VALIDATE("Posting Date"); itemjnl."Entry Type" := itemjnl."Entry Type"::Output; itemjnl.VALIDATE("Entry Type"); itemjnl.MODIFY; itemjnl."Prod. Order No." := ProdOrderLine."Prod. Order No."; itemjnl.VALIDATE("Prod. Order No."); itemjnl."Item No." := ProdOrderLine."Item No."; itemjnl.VALIDATE("Item No."); itemjnl.MODIFY; //get operation no. prodrtg.SETFILTER(Status,FORMAT(prodrtg.Status::Released)); prodrtg.SETFILTER("Prod. Order No.",ProdOrderLine."Prod. Order No."); prodrtg.SETFILTER("Routing Reference No.", FORMAT(ProdOrderLine."Line No.")); prodrtg.SETFILTER("Next Operation No.",''); prodrtg.FIND('+'); itemjnl."Operation No." := prodrtg."Operation No."; itemjnl.VALIDATE("Operation No."); itemjnl.MODIFY; //change location code in prod. order line to the defect location. ProdOrderLine.GET(ProdOrderLine.Status::Released, ProdOrderLine."Prod. Order No.",ProdOrderLine."Line No."); ProdOrderLine."Location Code" := '.DEFECT'; ProdOrderLine.MODIFY; itemjnl."Location Code" := '.DEFECT'; itemjnl.VALIDATE("Location Code"); itemjnl.MODIFY; itemjnl."Output Quantity" := 1; itemjnl.VALIDATE("Output Quantity"); itemjnl.MODIFY; COMMIT; itemjnl.RESET; itemjnl.SETFILTER("Journal Batch Name",'DEFAULT'); itemjnl.SETFILTER("Location Code",'.DEFECT'); poutf.SETRECORD(itemjnl); poutf.RUNMODAL; // ########## //how to make that form post himself, like pressing F11 key { // this can not work, but worth to try. i still don't know how to use sendkey command. IF DIALOG.CONFIRM('Post Output Journal rightaway?', FALSE) THEN BEGIN CREATE(wsh); wsh.SendKeys('{F11}'); CLEAR(wsh); END ELSE } // ########## ERROR(Text009,ProdOrderLine."Line No.",ToProdOrder.TABLECAPTION,ProdOrderLine."Prod. Order No."); //jm.2010 0302 : . . . . . . . . . . e n d . . . . . . . . . . END; UNTIL ProdOrderLine.NEXT = 0; Vars I added: all Local: poutf - Form - Output Journal itemjnl - Record - Item Journal Line prodrtg - Record - Prod. Order Routing Line ln - Integer wsh - Automation - 'Windows Script Host Object Model'.WshShell
Comments
System gives a warning message anyways. and if the user clicks OK then it is actually a user level error.
also if u want completely block it in case Finished qty is 0 then may be you could give an error message that Finished Qty cannot be 0, instead of auto populating the Output jnl. That may be easier and may work.
Regards,
Rajat.
Auto populating journal will make the work of user much easier, instead of just an error message.
we do MTO and proceed sales order as project order, creating production order with status released, right from the sales order. one prod order contains many items, and 1 production order for 1 sales order.
in the floor, the actual condition, it can be 1 prod. order line has excess output (more than expected output qty.), and we record this as is. there is also 1 prod. order line that consume few material, but considering process time, we decide to use excess products that we have to fulfill the line. as for the sales order, all items and qty's are fulfilled, but as for corresponding prod. order, there is one or more prod order line taking up some components but we cancel the production process, because we decide to use from excess product.
then when the SO is shipped, we change status of released prod order to finished. when executing this task, the prod order line which has consumption but no output, will give an error message. then NAV will stop, until user create required output for prod order line.
because we dont have actual output, but we must create one as required by NAV logic processing, so we will create output to virtual (defect) location, with qty. = 1 only, just to satisfy NAV's requirement. this is my purpose, instead of letting user create the output by his own, it can be inputting wrong item or wrong location or wrong date, etc.
so i plan to automate the output journal, as described in my post above. what do you think?