Skip to Content
-1
Former Member
Mar 04, 2009 at 11:13 AM

BAPI to create wbs element not working

3055 Views

Hi all

I searched the forum, and found out that the BAPI BAPI_BUS2054_CREATE_MULTI can be used to create a wbs elements inside a project. (I need to create only 1 wbs element, though)

I have coded as per what I found in the forums, but still the code does not seem to work. (I need to create a wbs element xxxx.3 where xxxx is the project no.) Can anyone provide me with insights on what is wrong in this code? Or any other way to create wbs?

wa_i_project_definition-project_definition = wa_proj-pspid.

CONCATENATE wa_proj-pspid '.3' INTO l_wbs.

wa_it_wbs_element-wbs_element = l_wbs.

wa_it_wbs_element-wbs_up = wa_proj-pspid.

APPEND wa_it_wbs_element TO it_wbs_element.

CALL FUNCTION 'BAPI_PS_INITIALIZATION'

.

CALL FUNCTION 'BAPI_BUS2054_CREATE_MULTI'

EXPORTING

i_project_definition = wa_i_project_definition-project_definition

TABLES

it_wbs_element = it_wbs_element

et_return = it_et_return

  • EXTENSIONIN =

  • EXTENSIONOUT =

.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

LOOP AT it_et_return INTO wa_it_et_return.

WRITE /: wa_it_et_return-message.

ENDLOOP.

LOOP AT it_et_return INTO wa_it_et_return WHERE type CO 'EA'.

gv_error = 'X'.

ENDLOOP.

IF gv_error IS INITIAL.

CALL FUNCTION 'BAPI_PS_PRECOMMIT'

TABLES

et_return = gt_return_pre.

LOOP AT gt_return_pre INTO wa_return_pre WHERE type CO 'EA'.

gv_error = 'X'.

ENDLOOP.

ENDIF.

IF gv_error IS INITIAL.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = '1'

IMPORTING

return = gt_return_commit.

ENDIF.