Are there any ‘roll back’ mechanism in C/SIDE?

joycopl_mejoycopl_me Member Posts: 52
Hi All,

Can you help answering this question bellowing?

Are there any ‘roll back’ mechanism in C/SIDE?
For Example: one transaction insert into G/L Entry table but in the inserting process, some entry line already, some entry line not yet and the power, network,… turn-off suddenly. How is about this transaction? Are they roll back or missing some entry line?

Thanks,
Thang

Comments

  • krikikriki Member, Moderator Posts: 9,110
    As long as you don't put a COMMIT that is executed, Navision takes care of the rollback.
    So if in the middle of a posting, your client-computer crashes, the DB rolls back the transaction automatically.
    If your are writing to the DB, and at a certain moment, you notice (with C/AL code) that there is something wrong, just give an ERROR or FIELDERROR and Navision rolls back the transaction.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • sidhartasidharta Member Posts: 1
    Hi,
    i have a problem with the 'Roll back' when i m using 3 'CodeUnit'. For example, i m using the "Item Jnl.-Post Batch" CodeUnit to post some item entries, but before, i'm calling a second CodeUnit to post some resource entries using the "Res. Jnl.-Post Batch". :whistle:
    So my problem is: when there is an error in posting the item entries, then the system must cancel the posting of the resource entries Already validated ; This is not the case !!! ](*,)

    Thankssss :)
    Mohamed CHELLY
    NAVISION CONSULTANT
    TUNISIA
  • krikikriki Member, Moderator Posts: 9,110
    In both codeunits, there is a COMMIT. So it is logical that before launching the second codeunit, the first has been commited.

    You can add a function in the codeunit that receives a boolean : IblnSkipCOMMIT. This is then saved in a global.
    Then the codeunit.RUN must be called to post the batch.
    In the codeunit, everywhere you find a COMMIT, you must change it to
    IF NOT blnSkipCOMMIT THEN
      COMMIT;
    
    The negative of this is that the transaction becomes longer. So if it is possible to divide the transactions and create something to recover from an ERROR in the second part, this would be even better.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • MbadMbad Member Posts: 344
    There is a commit in the end of the Res batch post. You should call Res. Jnl.-Post Line directly either runwithcheck or direcly onrun depending if the journal lines are inserted or not.
  • krikikriki Member, Moderator Posts: 9,110
    Mbad wrote:
    There is a commit in the end of the Res batch post. You should call Res. Jnl.-Post Line directly either runwithcheck or direcly onrun depending if the journal lines are inserted or not.
    This way you can also avoid using a batch, but you need to handle all lines+dimensions manually.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • joycopl_mejoycopl_me Member Posts: 52
    Hi kriki,

    Thank you very much! :D

    Thang
    Thang
Sign In or Register to comment.