This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

SUPPORT Q&A - Transaction handling and rollback controls in Aras

Bali - Tuesday, October 2, 2012 2:30 AM:

I have an external system from which I want to create an assembly structure in Aras. For example: I would like to create an assembly and 10 parts and connect them together.
My sequence would be:
Create Assembly Item.
Create Part1 and connect to Assembly
Create Part 2 and connect to Assembly…. and so on.
Now I want this to happen completely or not happen at all. So if I am creating part 3 and face an error condition, I want the complete operation to rollback. This means Assembly and part 1, 2 and their connections should be automatically deleted.
On a traditional database this would be done by transaction handling and rollback mechanism. Does Aras provide such facilities for transaction handling?

Will the isTemp and isNew attribute help in anyway? I could not figure out, any help would be deeply appreciated.

Regards,

Bali



RobMcAveney - Tuesday, October 2, 2012 10:11 AM:

See the Programmer's Guide, section 7.9.  You can either create one Item/Relationship/Item structure that adds the Assembly and Parts together, like this:

<Item type="Part" action="add">
  <item_number>Assembly</item_number>
  <Relationships>
    <Item type="Part BOM" action="add">
      <related_id>
        <Item type="Part" action="add">
          <item_number>Part 1</item_number>
        </Item>
      </related_id>
     </Item>
    ...
  </Relationships>
</Item>

or you can use ApplyAML instead of ApplyItem.  Everything inside an <AML> tag is treated as a single transaction.  For example:

<AML>
  <Item type="Part" action="add">
    <item_number>Assembly</item_number>
  </Item>
  <Item type="Part" action="add">
    <item_number>Part 1</item_number>
  </Item>
  <Item type="Part BOM" action="add">
    <source_id>
      <Item type="Part" action="get">
        <item_number>Assembly</item_number>
      </Item>
    </source_id>
    <related_id>
      <Item type="Part" action="get">
        <item_number>Part 1</item_number>
      </Item>
    </related_id>
  </Item>
  ...
</AML>



Bali - Tuesday, October 2, 2012 11:21 AM:

Thanks Rob. There may be scenarios where we cannot build an AML with all 10 parts because of certain validations and run time variable inputs.
Is it possible to have something like this
Try
{
Start Transaction();
{
   //My entire set of logic (validating and forming runtime AML) goes here. Parts will be created individually and connected separately.

}
Commit transaction();
}
Catch
{
                Abort Transaction();
}