Hi,
Just want to share how did I achieved this , since I am creating WDA application for creating WBS, I convinced the client to make those fields non-mandatory in cj02 and
Made those investment management fields mandatory WDA screen, I explained them since BDC is not good practice and not easy to maintain if some change happens in future.
- 1. Created WBS using BAPI_BUS2054_CREATE_MULTI after that
- 2. Updated IM fields using FM - AIPP_ALLOCATE_POSITION_DARK
Below is the sample code :
*project creation
CALL FUNCTION 'BAPI_PROJECTDEF_CREATE'
EXPORTING
project_definition_stru = ls_project_definition
IMPORTING
return = ls_bapireturn1_pro_defi
TABLES
e_message_table = lt_message_table.
*WBS creation
CALL FUNCTION 'BAPI_PS_INITIALIZATION'.
CALL FUNCTION 'BAPI_BUS2054_CREATE_MULTI'
EXPORTING
i_project_definition = lv_proj_no
TABLES
it_wbs_element = lt_wbs_element
et_return = lt_wbs_msg.
CALL FUNCTION 'BAPI_PS_PRECOMMIT'
TABLES
et_return = lt_pre_commit.
COMMIT WORK AND WAIT .
*Invesmnet management field update
DATA :lt_dyn_tab TYPE im_alloc_dyn_tab_type,
ls_dyn_tab TYPE im_alloc_dyn_type.
ls_dyn_tab-prnam = 'Z1'.
ls_dyn_tab-posid = 'Z1.1.1.1.1.1'.
ls_dyn_tab-gjahr = '2007'.
APPEND ls_dyn_tab TO lt_dyn_tab.
CALL FUNCTION 'AIPP_ALLOCATE_POSITION_DARK'
EXPORTING
i_aktyp = 'V' V= create
i_obart = 'PR' " WBS = PR
i_kokrs = 'ABC' " company
i_objnr = lv_objnr
* I_AUART =
i_posid = lv_wbs2
* I_PRART_IQ =
i_dyntab_dark = lt_dyn_tab[]
* I_FLG_BUDG_CTG_DIALOG = ' '
* I_FLG_REASSIGN_MR = ' '
* I_FLG_YRCHG_IGNORE =
i_flg_upd_on_commit = 'X'
* I_FLG_TEST_RUN = ' '
IMPORTING
e_update = lv_flag
EXCEPTIONS
alloc_already_exists = 1
alloc_no_proposal_made = 2
error_occured = 3
OTHERS = 4.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.