Options

Post multiple Line in One shot

navuser1navuser1 Member Posts: 1,329
Dear Sir,

I have created multiple Lines thru code & now I want to Post the same in a Single Shot thru code itself.
How to Do it ?

Code given below for your review.
IF RecordAVR.FINDSET THEN
  REPEAT
    GenJnlLine2.INIT
    ....
    ....
    ....
  UNTIL RecordVAR.NEXT =0;

CODEUNIT.RUN(CODEUNIT::"Gen. Jnl.-Post Line", GenJnlLine2);  //GenJnlLine2 has multiple Lines

The above code posts only the First Line. What is the issue in the above code.
Kindly reply.

Regards,
navuser1
Now or Never

Answers

  • Options
    Slawek_GuzekSlawek_Guzek Member Posts: 1,690
    edited 2017-12-16
    C12 Gen. Jnl.-Post Line posts only one line. You need to call it inside the loop, or you need to call C13 Gen. Jnl.-Post Batch
    Slawek Guzek
    Dynamics NAV, MS SQL Server, Wherescape RED;
    PRINCE2 Practitioner - License GR657010572SG
    GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
  • Options
    JohnHunterJohnHunter Member Posts: 45
    Take a look how C90 uses GenJnlPostLine.
  • Options
    lubostlubost Member Posts: 615
    If your loop consist GenJnlLine2.INSERT; you have to use Gen. Jnl.-Post Batch and all lines will be posted as one transaction.
    You can use loop without GenJnlLine2.INSERT; (and without Template, Batch and Line No.) and post line by line. This approach can be used only if each line has Account and Balance Account part.
  • Options
    navuser1navuser1 Member Posts: 1,329
    C12 Gen. Jnl.-Post Line posts only one line. You need to call it inside the loop, or you need to call C13 Gen. Jnl.-Post Batch

    Thanks for your reply.

    If I call Gen. Jnl.-Post Line Codeunit within the loop, then it generates different "Transaction No." in the G/L Entry for the same Document No.

    My goal is to achieve the single "Transaction No." for the multiple Gen. Journal Lines where all have the same "Document No."
    Now or Never
  • Options
    navuser1navuser1 Member Posts: 1,329
    lubost wrote: »
    If your loop consist GenJnlLine2.INSERT; you have to use Gen. Jnl.-Post Batch and all lines will be posted as one transaction.

    Thanks for your reply. I will follow this one first then back to you.

    lubost wrote: »
    You can use loop without GenJnlLine2.INSERT; (and without Template, Batch and Line No.) and post line by line. This approach can be used only if each line has Account and Balance Account part.

    Every Line is balanced ( Balancing Account is given in every Line)
    Now or Never
  • Options
    navuser1navuser1 Member Posts: 1,329
    The Lines which going to be posted are given below (as a Scenario)...
    mx1nidnryba0.png
    Now or Never
Sign In or Register to comment.