Incrementing Batch Name in Journal Batch Name

When using Journal, if the Journal Batch Name contains any number, then if all the lines are posted, and none lines remaining, then NAV will automatically delete the Batch Name, and create a new Batch Name by incrementing the Batch Name, ie. BATCH-01A will be BATCH-02A.

Although this feature is not used publicly by the customers, this feature is existing and no setup to manage that.

However, the code responsible for that job lies in:

Codeunit 13 Gen. Jnl.-Post Batch

UpdateAndDeleteLines

END ELSE BEGIN
// Not a recurring journal
GenJnlLine2.COPY(GenJnlLine);
GenJnlLine2.SETFILTER(“Account No.”,’%1′,”);
IF GenJnlLine2.FINDLAST THEN; // Remember the last line
GenJnlLine3.COPY(GenJnlLine);
GenJnlLine3.SETCURRENTKEY(“Journal Template Name”,”Journal Batch Name”,”Line No.”);
GenJnlLine3.DELETEALL;
GenJnlLine3.RESET;
GenJnlLine3.SETRANGE(“Journal Template Name”,GenJnlLine.”Journal Template Name”);
GenJnlLine3.SETRANGE(“Journal Batch Name”,GenJnlLine.”Journal Batch Name”);
IF NOT GenJnlLine3.FINDLAST THEN
IF INCSTR(GenJnlLine.”Journal Batch Name”) ” THEN BEGIN
GenJnlBatch.DELETE;
IF GenJnlTemplate.Type = GenJnlTemplate.Type::Assets THEN
FAJnlSetup.IncGenJnlBatchName(GenJnlBatch);
GenJnlBatch.Name := INCSTR(GenJnlLine.”Journal Batch Name”); //AW: This is the responsible line
IF GenJnlBatch.INSERT THEN;
GenJnlLine.”Journal Batch Name” := GenJnlBatch.Name;
END;

Hence, I you want to remove this ‘annoying’ feature, you know what to do 🙂

Reference:
https://msdn.microsoft.com/en-us/dynamics-nav/incstr-function–code–text-

Have a good day!

Advertisements

2 thoughts on “Incrementing Batch Name in Journal Batch Name

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s