Options

posting "prediction", trying to make smal

PhennoPhenno Member Posts: 630
Hi there.

I'm trying to make a small feature so want to talk with you guys...
In very beginning of every implementation of MBS Navision we got complains about how users cannot see what is going to be posted to gl on order/cr. memos, document postings.

So, idea is to make test posting but with full information on what account will be used with what amounts, just like real posting.

Few ideas are on the way:

1) to copy navision posting logic and make classical report (sounds complicated, isn't it?). benefits are that we will, in meantime, learn fully posting logic of nav.

2) to redirect, somehow, postings to gl to some temporary or new table. this sounds dangerous and hard to control, specially cause you have to know ALL tables that will be used in posting (all ledgers must be redirected too).

3) to control a transaction, actually to break posting transaction on very end. in that case nothing will be posted/changed and everything I have to do is to break transaction and write new data in g/l before break. Problems are number of transactions, what is end point, etc....

Any thoughts/ideas?

Answers

  • Options
    Miklos_HollenderMiklos_Hollender Member Posts: 1,598
    Copying the posting functions would be quite hard - there is a lot of them.

    You can search for GenJnlLine in CU 80,90 and modify it to have a preview mode, where the journal lines are inserted in a temporary table, then you could run a report on that (the temp table can be given to the report by a function call of the report object that gets it as a parameter, the report can run on then Integer table filtered to temptable.COUNT). I did that for Post Inventory Costs to G/L and wasn't very hard.

    Another option might be to look at the General and Inventory and other posting setup and "guess" what will be posted but I don't think that would be trustable.

    Would not automating creating and posting a Credit Memo to the Invoice do instead? I mean these all are ugly hacks...
  • Options
    PhennoPhenno Member Posts: 630
    Ok, that covers first two aproches to problem. Now, it seems that first aprouch (by BlackTiger) make sense.


    What about third solution?
  • Options
    Miklos_HollenderMiklos_Hollender Member Posts: 1,598
    Well, if you truly want to reinvent every core functionality from VAT looping, Dimension looping, Dimension priority, checking for consistency, VAT rounding, VAT triangulation when you join the EU, currency exchange, currency rounding, and half dozen other I forgot then just go with the first solution... =D>

    As for the third... I don't really understand. You can't suspend a transaction and run a form before commiting, becase Navi will complain in a huge error message, if that's what you ask.
  • Options
    PhennoPhenno Member Posts: 630
    Well, if you truly want to reinvent every core functionality from VAT looping, Dimension looping, Dimension priority, checking for consistency, VAT rounding, VAT triangulation when you join the EU, currency exchange, currency rounding, and half dozen other I forgot then just go with the first solution... =D>

    As for the third... I don't really understand. You can't suspend a transaction and run a form before commiting, becase Navi will complain in a huge error message, if that's what you ask.


    I thought just to break transaction at the end of posting and with some flags and changes in cu80/90 or lower, to write to a file accounts and values. I think that would be enough for "first solution". In that error (or breaking transaction point) I will inform, where he can see pre-posting report. Something like a simple two-step procedure.

    Ofcourse, this is only idea and don't know even if it's doable.
  • Options
    PhennoPhenno Member Posts: 630
    with second idea I have a problem that I MUST find all tables that receive records in posting transaction (all ledgers, VATs, Documents...) and all of them change/duplicate to temporary tables...
  • Options
    Miklos_HollenderMiklos_Hollender Member Posts: 1,598
    I thought users are only interested in G/L.
  • Options
    PhennoPhenno Member Posts: 630
    They Are interested only in GL, but if I use regular posting procedure and then change/duplicate only GL entries (or jnl entries) table to temporary GL entries table the rest of ledger tables and documents will be affected with posting.
  • Options
    Miklos_HollenderMiklos_Hollender Member Posts: 1,598
    Oh, I did not mean that. I would create a boolean field called Simulation on the Invoice. When CU80 creates the journal lines, if it's Simulation, it could insert the journal in a temptable, run a report and abort the whole transaction with an ERROR('') . You don't need G/L Entries to preview posting, Gen. Journal Lines also show G/L Acc. No. and Amount and that's the interesting data.
  • Options
    dmitripdmitrip Member Posts: 44
    Copy the routing "Post and Print" and in the code insert a rollback statement. in this case you'll get a report as it's posted by Navision but w/o actual posting.
  • Options
    ara3nara3n Member Posts: 9,255
    Hello You can use single innsance codeunit.
    This might help you.

    http://www.mibuso.com/forum/viewtopic.php?t=11142&highlight=commit+single+instnace
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Options
    krikikriki Member, Moderator Posts: 9,096
    dmitrip wrote:
    Copy the routing "Post and Print" and in the code insert a rollback statement. in this case you'll get a report as it's posted by Navision but w/o actual posting.
    Be carefull with this, because in C80, there are some COMMIT's.
    Ex. when posting an invoice, Navision gets the next invoice No. from the no. series, puts it in record of T36, saves it and then does a COMMIT. So if you later generate an ERROR, this value remains in the record in T36.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • Options
    PhennoPhenno Member Posts: 630
    ara3n wrote:
    Hello You can use single innsance codeunit.
    This might help you.

    http://www.mibuso.com/forum/viewtopic.php?t=11142&highlight=commit+single+instnace


    Hehhehhh ;)
  • Options
    PhennoPhenno Member Posts: 630
    Ok, now we are talking about same solution (including ara3n single instance, cause with temp tables I'll have a problem with temp table deleting too).


    Now, on kriki's part. Hidden COMMITS could make me lot of trouble and that's why I'm asking for advice here at first place. What could be problems of transaction break (although, it is a quite normal procedure to break posting transactions. It happens all the time for numerous of reasons like, wrong posting setup,dimension requiremets on gls, etc etc).

    I do now that it puts a value of next no. into T36 (Posting No., like Reservation of no. of posting cause it gets it before posting procedure).

    Is that the only possible problem?
  • Options
    ara3nara3n Member Posts: 9,255
    Performance and locking issues. With this feature, people will want to do it everytime, and this will double the number transaction to your server.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Options
    ara3nara3n Member Posts: 9,255
    Phenno wrote:
    Ok, now we are talking about same solution (including ara3n single instance, cause with temp tables I'll have a problem with temp table deleting too).


    You can delete the temp gl entry after the form is closed. Or modify the insert statement so that if it exists delete all records first.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Options
    PhennoPhenno Member Posts: 630
    ara3n wrote:
    Phenno wrote:
    Ok, now we are talking about same solution (including ara3n single instance, cause with temp tables I'll have a problem with temp table deleting too).


    You can delete the temp gl entry after the form is closed. Or modify the insert statement so that if it exists delete all records first.

    I thought that temporary tables are included in transaction (and, records are deleted too upon rollback) but now I see that I was wrong.

    So I did modifications and now I do have posting prediction except few commits that will happens anyway on errorenous postings of orders...

    Now, I have more logicaly problem than it's Navision.

    I made a small variable in SingleInstance that says "I'm doing a test posting so, break a transaction at the end".

    Just before that error, I clear/reset that boolean flag. And, that works ok. But, if I run a test posting on a order that has setup errors, my posting procedure will be broken up before I clear the flag and that is the problem that causes breaking the next first regular posting transaction too.

    I need an idea how to reset this var on posting errors?
  • Options
    ara3nara3n Member Posts: 9,255
    Create a function in the single instance codeunit and call it. In the function you can set the variable to false.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Options
    PhennoPhenno Member Posts: 630
    ara3n wrote:
    Create a function in the single instance codeunit and call it. In the function you can set the variable to false.

    I do set and reset that var in that function, that's not the problem.


    - I set that var before i start salesPost codeunit
    - I reset that var right before breaking transaction and showing form with results.

    problem is that my transaction can be breaked before that and than my var stays setted so I must say to customer "manually reset var" but I want to avoid that cause they'll be confused or will forgot to do that.
  • Options
    PhennoPhenno Member Posts: 630
    Ok, I found a solution with another flag that keeps mi informed is test past ok or not.

    Actualy, what was important that I can catch Error code from codeunit (it gives back status) and that add additional piece of code where I can reset vars.
  • Options
    ara3nara3n Member Posts: 9,255
    I'm assuming, you've found the solution to your question. I guess you can edit the thread as solved.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Options
    PhennoPhenno Member Posts: 630
    ara3n wrote:
    I'm assuming, you've found the solution to your question. I guess you can edit the thread as solved.


    Not fully but enough for me at this moment.

    Btw, I aksed somewhere here about that [solved] thing. How can I edit thread name?
  • Options
    Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    Phenno wrote:
    Btw, I aksed somewhere here about that [solved] thing. How can I edit thread name?

    Just go to your first message in this thread and click the "Edit" button on the right.
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • Options
    PhennoPhenno Member Posts: 630
    Thanx a lot guys!
Sign In or Register to comment.