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......
0
Comments
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
My Blog - nav.education
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
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 advice
This pattern is closest to the manual entry of data and will lead to correctly created record.
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
- Clear the record
- Populate the primary key
- Insert the record
- Populate other fields
- modify the record.
and call all the triggers.TVision Technology Ltd
Thanks to all. I have finally solved the issue with ur suggestions....