Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

Create multiple Item Journal Lines & POST them in a Single Click

Posted on by 1,112

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

  • subrata.bauri Profile Picture
    subrata.bauri 1,112 on at
    RE: Create multiple Item Journal Lines & POST them in a Single Click

    Thanks for you reply.  

    Exactly.

  • Verified answer
    I Gusti Made Ari Profile Picture
    I Gusti Made Ari 3,594 on at
    RE: Create multiple Item Journal Lines & POST them in a Single Click

    Looking at your code  , it will be rolled back if any error during posting the line.

    After all process completed and before the Message prompt  , i suggest to put commit command

    //Delete BEGIN

       HeaderTable.DELETEALL;

       HeaderLine.DELETEALL;

     //Delete END

      COMMIT; //add commit

      Message('Posted Successfully');

    this to avoid locking if user didn't close the message prompt.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans