Auto Journal Posting Issue
write2sourav
Posts: 113
Hi,
I am automatically creating a multiline journal through Gen Jnl Line. I am populating shortcut dimensions through code using the ValidateShortcutDimCode() function. When i am trying to post the journal programattically, system is asking for dimension on a particular line. I have already provided the same dimension at the time of creating journal...
I am using the following line for posting
CUGenJnlPostLine.RUN(Rec81);
Where Rec81 is a var of table 81.
If i post the journal manually, by blocking the above code (only inserting in table 81 through program), the same is posted without any error. What could be the reason..
Plz help......
I am automatically creating a multiline journal through Gen Jnl Line. I am populating shortcut dimensions through code using the ValidateShortcutDimCode() function. When i am trying to post the journal programattically, system is asking for dimension on a particular line. I have already provided the same dimension at the time of creating journal...
I am using the following line for posting
CUGenJnlPostLine.RUN(Rec81);
Where Rec81 is a var of table 81.
If i post the journal manually, by blocking the above code (only inserting in table 81 through program), the same is posted without any error. What could be the reason..
Plz help......
0
Comments
-
If you are not inserting the Jnl line but just filling the values, the dimension entries will not be filled in (the line no. is 0). You need to use RunWithCheck function of the codeunit to pass JnlLine and temp table with dimensions.0
-
Or just VALIDATE the fields on the General Journal Line. That will take the appropriate actions for the dimensions and insert the records in to the Journal Line Dimension table.0
-
But only if you are really inserting the record by Insert(True)... :-)matttrax wrote:Or just VALIDATE the fields on the General Journal Line. That will take the appropriate actions for the dimensions and insert the records in to the Journal Line Dimension table.0 -
Hi,
I am unable to post the journal automatically. The same error is coming. The code is as follows:
IF CONFIRM('Do you want to create the journal lines',TRUE) THEN BEGIN
TESTFIELD("RTGS Date");
TESTFIELD("Amount to be Remitted");
TESTFIELD(Type);
TESTFIELD("Beneficiary Code");
TESTFIELD("Applicant A/C No.");
TESTFIELD("Voucher Posting Date");
IF ("Beneficiary Type"="Beneficiary Type"::Customer) OR ("Beneficiary Type"="Beneficiary Type"::Vendor) THEN BEGIN
RecGenJnlLine.RESET;
RecGenJnlLine.SETRANGE("Journal Template Name",RecGLSetup."RTGS Template Name");
RecGenJnlLine.SETRANGE("Journal Batch Name",RecGLSetup."RTGS Batch Name");
IF RecGenJnlLine.FIND('+') THEN
LineNo:=RecGenJnlLine."Line No."+10000
ELSE
LineNo:=10000;
END;
IF ("Beneficiary Type"="Beneficiary Type"::Bank) THEN BEGIN
RecGenJnlLine.RESET;
RecGenJnlLine.SETRANGE("Journal Template Name",RecGLSetup."RTGS Template Name CV");
RecGenJnlLine.SETRANGE("Journal Batch Name",RecGLSetup."RTGS Template Batch CV");
IF RecGenJnlLine.FIND('+') THEN
LineNo:=RecGenJnlLine."Line No."+10000
ELSE
LineNo:=10000;
END;
DivCode:='DIV BLK'; //Hard Coded
CLEAR(RecGenJnlLine);
RecGenJnlLine.RESET;
RecGenJnlLine.INIT;
IF ("Beneficiary Type"="Beneficiary Type"::Customer) OR ("Beneficiary Type"="Beneficiary Type"::Vendor) THEN
RecGenJnlLine.VALIDATE("Journal Template Name",RecGLSetup."RTGS Template Name")
ELSE
RecGenJnlLine.VALIDATE("Journal Template Name",RecGLSetup."RTGS Template Name CV");
IF ("Beneficiary Type"="Beneficiary Type"::Customer) OR ("Beneficiary Type"="Beneficiary Type"::Vendor) THEN
RecGenJnlLine.VALIDATE("Journal Batch Name",RecGLSetup."RTGS Batch Name")
ELSE
RecGenJnlLine.VALIDATE("Journal Batch Name",RecGLSetup."RTGS Template Batch CV");
RecGenJnlLine."Line No.":=LineNo;
RecGenJnlLine.VALIDATE("Posting Date","Voucher Posting Date");
IF ("Beneficiary Type"="Beneficiary Type"::Vendor) THEN
RecGenJnlLine.VALIDATE("Document Type",RecGenJnlLine."Document Type"::Payment)
ELSE
RecGenJnlLine.VALIDATE("Document Type",RecGenJnlLine."Document Type"::" ");
IF "Beneficiary Type"="Beneficiary Type"::Bank THEN
BEGIN
IF RecGenJnlBatch.GET(RecGLSetup."RTGS Template Name CV",RecGLSetup."RTGS Template Batch CV") THEN
RecGenJnlLine.VALIDATE("Document No.",NoSeriesMgt.GetNextNo(RecGenJnlBatch."No. Series",WORKDATE,FALSE));
END
ELSE
BEGIN
IF RecGenJnlBatch.GET(RecGLSetup."RTGS Template Name",RecGLSetup."RTGS Batch Name") THEN
RecGenJnlLine.VALIDATE("Document No.",NoSeriesMgt.GetNextNo(RecGenJnlBatch."No. Series",WORKDATE,FALSE));
END;
IF ("Beneficiary Type"="Beneficiary Type"::Customer) THEN
RecGenJnlLine.VALIDATE("Account Type",RecGenJnlLine."Account Type"::Customer);
IF ("Beneficiary Type"="Beneficiary Type"::Vendor) THEN
RecGenJnlLine.VALIDATE("Account Type",RecGenJnlLine."Account Type"::Vendor);
IF ("Beneficiary Type"="Beneficiary Type"::Bank) THEN
RecGenJnlLine.VALIDATE("Account Type",RecGenJnlLine."Account Type"::"Bank Account");
RecGenJnlLine.VALIDATE("Account No.","Beneficiary Code");
RecGenJnlLine.VALIDATE("External Document No.","RTGS No.");
RecGenJnlLine.VALIDATE("Gen. Posting Type",RecGenJnlLine."Gen. Posting Type"::" ");
RecGenJnlLine.VALIDATE(Amount,"Amount to be Remitted");
RecGenJnlLine.VALIDATE("Shortcut Dimension 1 Code",'HO');
IF ("Beneficiary Type"="Beneficiary Type"::Bank) THEN
RecGenJnlLine.ValidateShortcutDimCode(3,DivCode);
IF RecDefDim.GET(270,"Beneficiary Code",'BANK') THEN
RecGenJnlLine.ValidateShortcutDimCode(7,RecDefDim."Dimension Value Code");
IF RecGenJnlLine.INSERT(TRUE) THEN;
NewDocNo:=RecGenJnlLine."Document No.";
//Balancing Line
IF ("Beneficiary Type"="Beneficiary Type"::Customer) OR ("Beneficiary Type"="Beneficiary Type"::Vendor) THEN
RecGenJnlLine.VALIDATE("Journal Template Name",RecGLSetup."RTGS Template Name")
ELSE
RecGenJnlLine.VALIDATE("Journal Template Name",RecGLSetup."RTGS Template Name CV");
IF ("Beneficiary Type"="Beneficiary Type"::Customer) OR ("Beneficiary Type"="Beneficiary Type"::Vendor) THEN
RecGenJnlLine.VALIDATE("Journal Batch Name",RecGLSetup."RTGS Batch Name")
ELSE
RecGenJnlLine.VALIDATE("Journal Batch Name",RecGLSetup."RTGS Template Batch CV");
RecGenJnlLine."Line No.":=LineNo+10000;
RecGenJnlLine.VALIDATE("Posting Date","Voucher Posting Date");
IF ("Beneficiary Type"="Beneficiary Type"::Customer) OR ("Beneficiary Type"="Beneficiary Type"::Bank) THEN
RecGenJnlLine.VALIDATE("Document Type",RecGenJnlLine."Document Type"::" ")
ELSE
RecGenJnlLine.VALIDATE("Document Type",RecGenJnlLine."Document Type"::Payment);
RecGenJnlLine.VALIDATE("Document No.",NewDocNo);
RecGenJnlLine.VALIDATE("Account Type",RecGenJnlLine."Account Type"::"Bank Account");
RecGenJnlLine.VALIDATE("Account No.","Applicant A/C No.");
RecGenJnlLine.VALIDATE("External Document No.","RTGS No.");
RecGenJnlLine.VALIDATE("Gen. Posting Type",RecGenJnlLine."Gen. Posting Type"::" ");
RecGenJnlLine.VALIDATE(Amount,-("Amount to be Remitted"));
RecGenJnlLine.VALIDATE("Shortcut Dimension 1 Code",'HO');
RecGenJnlLine.ValidateShortcutDimCode(3,DivCode);
IF RecGenJnlLine.INSERT(TRUE) THEN;
CUGenJnlPostLine.RUN(RecGenJnlLine); //"Gen. Jnl.-Post Line"
The shortcut dimension for Bank is populated when the "Applicant A/C No." field is filled.
But again it is asking for the same when i post the journal automatically using
CUGenJnlPostLine.RUN(RecGenJnlLine);.
Plz advice0 -
As each time, I recommend to use this pattern to insert the record:
MyRec.INIT; //Assigning/Validating primary key fields MyRec.INSERT(True); //Assigning/Validating other fields MyRec.MODIFY(True);
This pattern is closest to the manual entry of data and will lead to correctly created record.0 -
- You shouldn't be hiding any errors from the INSERT(TRUE) statements because if you get one there's a problem.
- Calling the RUN trigger of the G/L posting codeunit only allows you to set GD1 and GD2
- If creating any record in NAV that it's often best to follow the route that the Forms do when creating the record, especially if you don't understand all the code on the table. ie:
- Clear the record
- Populate the primary key
- Insert the record
- Populate other fields
- modify the record.
- You probably want to call the batch post routine CU13 to do your posting.
- Please wrap your code in code tags on mibuso
Robert de Bath
TVision Technology Ltd0 -
Hi,
Thanks to all. I have finally solved the issue with ur suggestions....0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 611 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 253 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions

