cancel
Showing results for 
Search instead for 
Did you mean: 

WBS Hierarchy Inconsistency Error in "BAPI_PROJECT_MAINTAIN.

0 Kudos

HI Friends,

I am facing the Error "The Transferred Hierarchy is inconsistent" while using BAPI_PROJECT_MAINTAIN.

Please help me finding out where is the issue and rectify it . Thanks in advance.

Here is the sample code below :

lv_refno = 1.
wa_projmethod-objecttype = 'WBS-Element'.
wa_projmethod-method = 'Create'.
wa_projmethod-objectkey = lv_topwbs.
wa_projmethod-refnumber = lv_refno.
APPEND wa_projmethod TO it_projmethod.
CLEAR wa_projmethod.

lv_refno = lv_refno + 1.
wa_projmethod-objecttype = 'WBS-Element'.
wa_projmethod-method = 'Create'.
wa_projmethod-objectkey = lv_wbs.
wa_projmethod-refnumber = lv_refno.
APPEND wa_projmethod TO it_projmethod.
CLEAR wa_projmethod.

** Set BAPI Trigger to create WBS-Milestones based on Milestone table passed
lv_refno = 1.
wa_projmethod-objecttype = 'WBS-Milestone'.
wa_projmethod-method = 'CREATE'.
wa_projmethod-objectkey = '2022001'.
wa_projmethod-refnumber = lv_refno.
APPEND wa_projmethod TO it_projmethod.
CLEAR wa_projmethod.
**Set correct WBS Hierarchy
lv_refno = 1.
wa_projmethod-objecttype = 'WBS-Hierarchy'.
wa_projmethod-method = 'Create'.
wa_projmethod-objectkey = space.
wa_projmethod-refnumber = space.
APPEND wa_projmethod TO it_projmethod.
CLEAR: wa_projmethod.

** Set BAPI Trigger to save and wait

wa_projmethod-objecttype = space.
wa_projmethod-method = 'Save'.
wa_projmethod-refnumber = space.
APPEND wa_projmethod TO it_projmethod.
CLEAR wa_projmethod.

* Append WBS
**Ensure all mandatory fields are populated
wa_UWBS_ELEMENT-description = 'Top WBS Element1'.
wa_UWBS_ELEMENT-wbs_element = lv_topwbs.
wa_UWBS_ELEMENT-project_definition = lv_pspid.
wa_UWBS_ELEMENT-wbs_billing_element = 'X'.
wa_UWBS_ELEMENT-comp_code = 'SE10'.
wa_UWBS_ELEMENT-co_area = 'ATEA'.
wa_UWBS_ELEMENT-proj_type = '01'.
APPEND wa_UWBS_ELEMENT TO it_UWBS_ELEMENT.

wa_UWBS_ELEMENT-description = 'Initiate_new'."is_attributes_new-name'.
wa_UWBS_ELEMENT-wbs_element = lv_wbs.
wa_UWBS_ELEMENT-project_definition = lv_pspid.
wa_UWBS_ELEMENT-wbs_billing_element = 'X'.
wa_UWBS_ELEMENT-comp_code = 'SE10'.
wa_UWBS_ELEMENT-co_area = 'ATEA'.
wa_UWBS_ELEMENT-proj_type = '01'.
APPEND wa_UWBS_ELEMENT TO it_UWBS_ELEMENT.

*Create Milestone
wa_EWBS_MILESTONE-milestone_number = '2022001'.
wa_EWBS_MILESTONE-milestone_usage = 'Z0001'.
"if creating, followign wbs can't already exist on the project definition
wa_EWBS_MILESTONE-wbs_element = lv_wbs.
wa_EWBS_MILESTONE-description = 'Advance payment'.
APPEND wa_ewbs_milestone TO it_ewbs_milestone .
*Create Hierarchy
wa_wbs_hierarchie-wbs_element = lv_topwbs.
wa_wbs_hierarchie-project_definition = lv_pspid.
wa_wbs_hierarchie-up = lv_pspid.
wa_wbs_hierarchie-down = lv_wbs.
wa_wbs_hierarchie-left = space.
wa_wbs_hierarchie-right = space.
APPEND wa_wbs_hierarchie TO it_wbs_hierarchie.
CLEAR wa_wbs_hierarchie.

wa_wbs_hierarchie-wbs_element = lv_wbs.
wa_wbs_hierarchie-project_definition = lv_pspid.
wa_wbs_hierarchie-up = lv_topwbs.
wa_wbs_hierarchie-down = space.
wa_wbs_hierarchie-left = space.
wa_wbs_hierarchie-right = space.
APPEND wa_wbs_hierarchie TO it_wbs_hierarchie.
CLEAR wa_wbs_hierarchie.
*Call BAPI to update Project Definition
CALL FUNCTION 'BAPI_PROJECT_MAINTAIN'
EXPORTING
i_project_definition = wa_PROJDEF_EDT
i_project_definition_upd = wa_PROJDEF_UPD
IMPORTING
return = ls_RETURN
TABLES
i_method_project = it_projmethod
* I_WBS_ELEMENT_TABLE_UPDATE = IT_UWBS_ELEMENT_upd
i_wbs_element_table = it_uwbs_element
i_wbs_milestone_table = it_ewbs_milestone
* I_WBS_MILESTONE_TABLE_UPDATE = IT_EWBS_MILESTONE_upd
i_wbs_hierarchie_table = it_wbs_hierarchie
e_message_table = it_message. .

raymond_giuseppi
Active Contributor
0 Kudos

Are you just adding WBS to a project, in this case consider using BAPI_BUS2054_CREATE_MULTI.

Accepted Solutions (0)

Answers (1)

Answers (1)

Ken_Melching
Product and Topic Expert
Product and Topic Expert
0 Kudos

I added the ABAP tag. What error have you found during debugging?

0 Kudos

"The Transferred Hierarchy is inconsistent" in Messages Table.

Ken_Melching
Product and Topic Expert
Product and Topic Expert
0 Kudos

I think you will have to debug it line by line to see where creating the hierarchy is failing .