Dear Sir,
I create multiple Item Journal Lines (For Re-class) from a Custom Document(QC) & want to Post them in a Single click. My Pseudo is given below for your review. Also I want that my QC Document will be Posted (transfer data from one(QC) to another (Posted QC)) after successfully Posting all the Lines from QC Document.
It's my experience that the Codeunit Item Jnl.-Post Batch (ID 23) is useful for bulk posting if I call INSERT Function during ItemJournalLine Creation. But the Standard Code of that Codeunit will show few message before & after the Posting Which I don't want, even I don't want to manipulate any code of that Codeunit (ID 23) as well as can't call INSERT function in my Custom Code.
CODEUNIT.RUN(CODEUNIT::"Item Jnl.-Post",ItemJournalLine); //ItemJournalLine - Table ID 83, Item Journal Line
I have also checked with the Codeunit Item Jnl.-Post Line (ID 22) to call repetitively in my custom code.
And I have few doubt about the rollback system in this way. Suppose I have to post three Line (Item Journal Line) & there is some problem in the last Item Journal Line for which the last line can not be posted. If this will happen then I just want to know the first two line will be rollbacked defiantly ?
HeaderTable.GET IF HeaderLine.FINDSET THEN BEGIN REPEAT IF HeaderLine.Field >0 THEN BEGIN CreateItemJournalLine(HeaderLine); ItemJnlPostLine.RunWithCheck(ItemJournalLine); //ItemJnlPostLine Codeunit Item Jnl.-Post Line (ID 22) END; IF HeaderLine.Field2 >0 THEN BEGIN CreateItemJournalLine2(HeaderLine); ItemJnlPostLine.RunWithCheck(ItemJournalLine); //ItemJnlPostLine Codeunit Item Jnl.-Post Line (ID 22) END; UNTIL HeaderLine.NEXT =0; //Create History BEGIN PostedHeaderTable PostedHeaderLine //Create History END //Delete BEGIN HeaderTable.DELETEALL; HeaderLine.DELETEALL; //Delete END Message('Posted Successfully'); END;
Kindly share your best suggestion.
Thanks,
Subrata
*This post is locked for comments