Posting Routine

yekedeyekede Member Posts: 96
Hi all,
I have a question:
I created a new codeunit to do a posting routine. My codeunit creates Gen. Journal Lines through genjnlline.init
I need to post this lines into the G/L ledger table. To achieve this i have called the genjnlLine.runwithcheck function.
The problem is this function takes two parameters: a gen. jnl. Line record and a Temp. jnl Line Dim. record.
But i have not included dimensions in my customizations. Do anyone have an idea how i can post this lines without dimensions?
Thanks for any contributions.

Answers

  • matttraxmatttrax Member Posts: 2,309
    Have you tried just passing an empty record?
  • yekedeyekede Member Posts: 96
    Thanks Mattrax,
    I have tried. it worked fine for a while but after a while it gives an error: 'this Ledger entry dimensions exists already' and it shows some values. I tried to find the bug. and i discovered that when table "Journal Line Dimension" is empty all works fine. but if it contains records i have my error
  • David_SingletonDavid_Singleton Member Posts: 5,479
    I think you need to init or clear the temp dim record and then maybe you need to set the primary key to match the journal. Try both ways. but for sure clear the rec before each line.
    David Singleton
  • yekedeyekede Member Posts: 96
    Hi David,
    I have done this:
    CLEAR(TempjnlLineDim1);
    TempjnlLineDim1.INIT ;
    TempjnlLineDim1."Table ID" := 81;
    TempjnlLineDim1."Journal Template Name" := GnlJnlLine."Journal Template Name";
    TempjnlLineDim1."Journal Batch Name" := GnlJnlLine."Journal Batch Name";
    TempjnlLineDim1."Journal Line No." := GnlJnlLine."Line No.";
    TempjnlLineDim1."Allocation Line No." := 0;
    TempjnlLineDim1."Dimension Code" := ' ';
    genjnlpostline.RunWithCheck(GnlJnlLine,TempjnlLineDim1);
    but i still have my error:
    "The Ledger Entry Dimension already exists.
    Identification fields and values Table ID='17' ,Entry No.='3118', Dimension Code= 'ACHETEUR'"
  • BeliasBelias Member Posts: 2,998
    Is entry no. 3118 one of the entries you're posting?If not, maybe the problem is this:

    INIT instruction does not clear the Primary Key fiels, maybe there are some dirty variables somewhere;
    try to do a
    clear(tempvariable);
    genjnlpostline.RunWithCheck(GnlJnlLine,Tempvaribale);
    
    if this does not work either, try to insert a jnl line w/o dimension, enable debug and post it: you should be able to see how the tempjnl is (not) evaluated in the runwithcheck function :wink:

    P.S.: you should test if you have to clear the variable, if, for example, for some lines you have to insert dimensions, and for some others not.
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • yekedeyekede Member Posts: 96
    Belias wrote:
    Is entry no. 3118 one of the entries you're posting?
    Entry no. 3117 is the last entry in the General Ledger Entries Table
    Belias wrote:
    INIT instruction does not clear the Primary Key fiels, maybe there are some dirty variables somewhere;
    try to do a
    clear(tempvariable);
    genjnlpostline.RunWithCheck(GnlJnlLine,Tempvaribale);
    
    I have tried that too:same error
    Belias wrote:
    try to insert a jnl line w/o dimension,
    Please i don't quite understand what you mean by that
  • BeliasBelias Member Posts: 2,998
    i mean that you should try to insert a gen. jnl line manually w/o (means without) dimension, and then post it with debugger enabled. you should be able to see how the dimension table is (or is not) created
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • yekedeyekede Member Posts: 96
    Belias wrote:
    i mean that you should try to insert a gen. jnl line manually w/o (means without) dimension, and then post it with debugger enabled. you should be able to see how the dimension table is (or is not) created
    Hi Belias it works fine when i post manually :roll: so i don't get the source of my error
  • David_SingletonDavid_Singleton Member Posts: 5,479
    OK I think the issue may be that you still have records left over. Are you cetain that the TempjnlLineDim1 is temporary. If so try adding

    TempjnlLineDim1.deleteall;
    David Singleton
  • BeliasBelias Member Posts: 2,998
    instead of running the runwithcheck function directly, run the codeunit 12 (as the standard posting routine does).
    moreover, to the onrun, you have only to pass the journal line, and not the dimension table!

    EDIT: david is somewhat faster: because in the onrun you'll find:
    GLSetup.GET;
    TempJnlLineDim2.RESET;
    TempJnlLineDim2.DELETEALL;
    IF "Shortcut Dimension 1 Code" <> '' THEN BEGIN
      TempJnlLineDim2."Table ID" := DATABASE::"Gen. Journal Line";
    ..................
    
    RunWithCheck(Rec,TempJnlLineDim2);
    
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • yekedeyekede Member Posts: 96
    OK I think the issue may be that you still have records left over. Are you cetain that the TempjnlLineDim1 is temporary. If so try adding

    TempjnlLineDim1.deleteall;
    :thumbsup: You're right David. It works fine now :D Thanks David, Belias for your help.
  • David_SingletonDavid_Singleton Member Posts: 5,479
    yekede wrote:
    OK I think the issue may be that you still have records left over. Are you cetain that the TempjnlLineDim1 is temporary. If so try adding

    TempjnlLineDim1.deleteall;
    :thumbsup: You're right David. It works fine now :D Thanks David, Belias for your help.

    You are welcome. Its great to see someone posting vaild information and asking the question correctly. Makes it soooooo much easier for us to answer that way. \:D/
    David Singleton
Sign In or Register to comment.