importsap-commerce-cloudimpexhotfolder

How to roll back impex import in Hybris


When any impex line fails, is it possible to roll back all the previously imported lines from the same impex file, and stop further execution ?


Solution

  • You can use hybris Transaction if you import Impex using the ImpexService

    Transaction tx = Transaction.current();
    tx.begin(); 
    boolean success = false;
    try
    {
       // Import your impex here and catch exceptions that can occur
       doSomeBusinessLogic();
       success = true;
    }
    finally
    {
       if( success )
          tx.commit();
       else
          tx.rollback();
    }
    

    You can find the hybris documentation here : https://help.hybris.com/1808/hcd/8c7387f186691014922080f2e053216a.html