Hi Leandro,
I would move the document creation to the After form data add/Update event.
I would make sure my form data is created in the database, and after that, I will try to create the documents, commit and rollback as necessary.
This way :
1, If data created + Document created -> no issue.
2. If data not created -> Document will not be created.
3. If data created + Document not created -> user can rectify the problem (ie. Opening the closed period) and re-do the document creation by updating the form.
Of course there is a draw back also, On point 3, SAP will always shows up a message operation completed + another message of your addon.
The safest way to handle this,
I would set my form to not auto managed. (This mean you will loose automatic DB update/add for your form)
On the before item pressed event, I would :
1. Start Transaction.
2. Create/Update my form data to DB.
3. Create documents.
4. If 2 & 3 success, commit, else roll back. BubbleEvent = true or false depending on the result.
Regards
Edy