‎2018 Jan 30 10:25 AM
Hello guys,
at the moment I'm trying to create a custom report which can create wbs elements from an excel file. Therefor I want to add some basic data of wbs element, set user status and set longtext for wbs element. My problem now is that I want to the whole thing in one commit. Unfortunately the status and the longtext have to created in separated tasks. At the moment it looks like:
(1) BAPI_PS_INITIALIZATION for WBS element initialization
(2) BAPI_BUS2054_CREATE_MULTI for WBS element creation
(3) BAPI_BUS2054_SET_STATUS for setting status of WBS
(4) BAPI_PS_PRECOMMIT do the precommit
(5) BAPI_TRANSACTION_COMMIT do the commit
(6) SAVE_TEXT and COMMIT_TEXT to add the long text
My problem is now the steps 5 and 6. I only want to create the wbs element, when both work, wbs creation and long text creation. So normally I have to do the comit (5) in step 6 instead. But when switching that, I cannot create the text because the OBJNR for longtext is not created yet. In the way it is now, it works, but I have no chance to undo the creation when the longtext creation fails.
Any solutions for that?
Regards
Michael
‎2018 Feb 10 1:00 PM
Hi,
Have you tried this in the case of a failure of step 6?
How about various rollback techniques?
Another option is to have a ghost WBS that you will delete at the end (or have it so it is used for those purposes only) that you can test the SAVE_TEXT on it, as a kind of a simulation, and if it fails not to go through steps 5 and 6. There are problems with this way that you need to manage - not sure how your system is customized and what constraints you put on WBS in your organization, consult the authority at your workplace.
‎2018 Feb 10 1:13 PM
Why does the long text have to be in the same commit? Many SAP documents save texts in the V2 (secondary) update, so unless you have a very specific reason, I don't see an issue with your sequence. Perhaps it would be easier to adjust any follow dependencies.
‎2018 Feb 12 8:01 AM