2023 Aug 24 11:39 AM
Hi guys,
I have recently developed a report, where I have been creating WBS for an existing Project.
The WBS are created using BAPI_BUS2054_CREATE_MULTI.
The issue that I've been facing is that the WBS after being created do not seem to be sorted ie they are not in the right order in CJ20n transaction, despite adding WBS_LEFT and WBS_UP fields.
for instance ;
project
project-wbs1
project-wbs2
project-wbs4
project-wbs3
The functional consultant needs to got to t-code CJ02 and manually enter the Project and click on Project-Derive structure-Execute-Save to get the WBS sorted for that particular project.
Is there any BAPI to attain this functionality through the program after creating the WBS and after commit
Thanks!
2023 Aug 24 2:27 PM
Did you call (in sequence)
or
to insure correct execution
2024 Jan 08 11:25 AM
You are using same Function Module two times?
2024 Jan 08 12:04 PM
Read KBA 1934899 - Error in BAPI_BUS2054_CREATE_MULTI execution which suggest to call BAPI for each level separately.
2023 Aug 24 3:04 PM
Yes the BAPI's are called in the below mentioned Sequence.
BAPI_PS_INITIALIZATION
BAPI_BUS2054_CREATE_MULTI
BAPI_PS_PRECOMMIT
BAPI_TRANSACTION_COMMIT
I can elaborate the issue to you in bit more detail if in case it helps.
Project - L1
wbs-1 -L2
wbs-1-1 - L3
wbs-1-2
wbs-2
wbs-2-1
wbs-2-3
wbs-2-2
wbs-2-5
wbs-3
wbs-4
lets consider all the above WBS' are already created except the highlighted ones.
Now lets lets take into consideration the level-3 WBS' here for instance which I just created newly - wbs-2-2
wbs-2-5
Please not rest all were already set up.
So ideally the above highlighted ones had to be attached below wbs-2-1 but instead it has been attached after wbs-2-3.
We can see the order has been screwed here 1-3-2-5, In case I add new wbs, wbs-2-4 in future it will go and attach after wbs-2-5.
P.S - There is a solution of using the BDC for CJ02 but that's the last resort, I'm looking for a BAPI which could handle this.
2023 Aug 25 8:52 AM
Hello
We do so by using BAPI BAPI_PROJECT_MAINTAIN.
WBS element is created by populating the below input parameters of the BAPI:
i_method_project = cs_project-method
i_wbs_element_table = cs_project-wbs_element
i_wbs_element_table_update = cs_project-wbs_element_update
* WBS element method
INSERT VALUE #(
refnumber = lv_refnumber
objecttype = co1_type-wbs_element
method = co1_meth-create
objectkey = ev_wbs_element ) INTO TABLE cs_project-method ##NO_TEXT.
* WBS element
INSERT CORRESPONDING #( is_wbs_element ) INTO TABLE cs_project-wbs_element REFERENCE INTO lr_wbs_element ##ENH_OK.
lr_wbs_element->wbs_element = ev_wbs_element.
lr_wbs_element->project_definition = is_project_wbs_element-project_definition.
But next to that it might be essential to also update the WBS element hierarchy by populating the below input parameters of the BAPI:
i_method_project = cs_project-method
i_wbs_hierarchie_table = cs_project-wbs_hierarchie
The logic for populating WBS hierarchy might be different for you. But could be something like below. The complete hierarchy is to be populated including existing hierarchy nodes and also newly added nodes. Existing hierarchy could be read by BAPI BAPI_PROJECT_GETINFO paramater e_wbs_hierarchie_table.
* WBS element hierarchy method
INSERT VALUE #(
objecttype = co1_type-wbs_hierarchy
method = co1_meth-create ) INTO TABLE cs_project-method ##NO_TEXT.
* New down node
INSERT VALUE #(
wbs_element = iv_wbs_element
project_definition = is_wbs_hierarchie-project_definition
up = is_wbs_hierarchie-wbs_element
right = is_wbs_hierarchie-down ) INTO TABLE cs_project-wbs_hierarchie.
2023 Sep 13 10:02 AM
Hello jack.graus2,
I tried your workaround, unfortunately this didn't work out.
The errors that I got was, that the WBS' already exists and these were for the new ones.
Thanks,
SA