Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Create wbs element with long text

Missschaaa
Participant
0 Likes
1,080

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

3 REPLIES 3
Read only

iftah_peretz
Active Contributor
0 Likes
888

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.

Read only

pokrakam
Active Contributor
0 Likes
888

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.

Read only

RaymondGiuseppi
Active Contributor
0 Likes
888

You could wrap the SAVE /COMMIT_TEXT in a RFC FM (or use RFC_SAVE_TEXT) and call this FM in BACKGROUND TASK/UNIT before the commit, so it will be executed after the update and only if successful?