Codeunit with three XMLports - Rollback?

pn7pn7 Member Posts: 17
edited 2016-03-16 in NAV Three Tier
Hello

This is my first post to mibuso so bear with me.

So I have a Codeunit which launches three XMLports. The problem shows up when the codeunit reaches the last XMLport and if the run time error occurs with some validation -> There are no Rollbacks. How one must build this that it rolls back each used XMLport?

To give you context: I'm importing sales headers and sales lines from different files.

Navision version: 2015

Has any one have solution for that kind of problem?


Yours truly,

pn7

Comments

  • postsauravpostsaurav Member Posts: 708
    I am not sure but this seems to be the appropriate solution as per my understanding -
    Assuming you xmlport are XMLA, XMLB and XMLC

    1. Create Temp (staging Table) for all these three tables where actually want to import record.
    2. insted of XMLA.Import(parameters) Use
      TransferRecord  := FALSE;
    
      IF(XMLA.Import(parameters)) THEN 
       XMLA.Close;
      ELSE
        TransferRecord := FALSE;
    
      IF XMLB.Import(parameters)) THEN
        XMLB.Close;
      ELSE
        TransferRecord := FALSE;
    
      IF XMLC.Import(parameters)) THEN BEGIN 
        XMLC.Close;
        TransferRecord := TRUE;
      END;
    
    IF TransferRecord THEN 
      // Code to Transfer Record to Actual Tables and Delete Record from Staging Tables.
    ELSE
      // Code to Delete records from Staging tables.
    
    Where TransferRecord Is a Boolean.

    Thanks & Regards,
    Saurav Dhyani

    Do you Know this About NAV?


    Connect - Twitter | Facebook | Google + | YouTube

    Follow - Blog | Facebook Page | Google + Page
  • krikikriki Member, Moderator Posts: 9,112
    [Topic moved from 'NAV Tips & Tricks' forum to 'NAV Three Tier' forum]
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


Sign In or Register to comment.