‎2007 Sep 04 4:06 PM
Hi
I would be greatful if someone could post a complete example of code that calls BAPI_PROJECT_MAINTAIN. I'm having a few probles specifically with assigning hierachy so if i could see an example of the bapi in use that would help
thanks in advance
‎2007 Sep 04 4:12 PM
HI,
Here is the example code
----
----
DATA: lv_seqno(6) TYPE n VALUE '000001',
lc_seqno(6) TYPE n VALUE '000000'.
Structures and Internal tables used in the BAPI
DATA : gs_project_definition LIKE bapi_project_definition,
gs_project_definition_upd LIKE bapi_project_definition_up.
DATA : gt_method_project LIKE bapi_method_project
OCCURS 0 WITH HEADER LINE,
gt_wbs_element_table_update LIKE bapi_wbs_element_update
OCCURS 0 WITH HEADER LINE,
gt_wbs_element_table LIKE bapi_wbs_element
OCCURS 0 WITH HEADER LINE,
gt_wbs_hierarchie_table LIKE bapi_wbs_hierarchie
OCCURS 0 WITH HEADER LINE,
gt_return LIKE bapireturn1
OCCURS 0 WITH HEADER LINE,
gt_return1 LIKE bapiret2
OCCURS 0 WITH HEADER LINE,
gt_message_table LIKE bapi_meth_message
OCCURS 0 WITH HEADER LINE.
Populate Project definition
gs_project_definition-project_definition = 'PD-TRAINING'.
gs_project_definition-description = 'Training project'.
gs_project_definition-project_profile = 'PPRO001'.
Populate Project dafinition update table
gs_project_definition_upd-project_definition = space.
Populate project method update
gt_method_project-refnumber = lv_seqno.
gt_method_project-objecttype = 'WBS-ELEMENT'.
gt_method_project-method = 'CREATE'.
gt_method_project-objectkey = 'TRAINING'.
APPEND gt_method_project.
lv_seqno = lv_seqno + 1.
gt_method_project-refnumber = lv_seqno.
gt_method_project-objecttype = 'WBS-ELEMENT'.
gt_method_project-method = 'CREATE'.
gt_method_project-objectkey = 'TRAINING.1'.
APPEND gt_method_project.
lv_seqno = lv_seqno + 1.
gt_method_project-refnumber = lv_seqno.
gt_method_project-objecttype = 'WBS-ELEMENT'.
gt_method_project-method = 'CREATE'.
gt_method_project-objectkey = 'TRAINING.2'.
APPEND gt_method_project.
gt_method_project-refnumber = lc_seqno.
gt_method_project-objecttype = space.
gt_method_project-method = 'SAVE'.
gt_method_project-objectkey = space.
Populate WBS element
gt_wbs_element_table-wbs_element = 'TRAINING'.
gt_wbs_element_table-project_definition = 'PD-TRAINING'.
gt_wbs_element_table-description = 'Whole Project'.
gt_wbs_element_table-wbs_element = 'TRAINING.1'.
gt_wbs_element_table-project_definition = 'PD-TRAINING'.
gt_wbs_element_table-description = 'Preparation'.
gt_wbs_element_table-wbs_element = 'TRAINING.2'.
gt_wbs_element_table-project_definition = 'PD-TRAINING'.
gt_wbs_element_table-description = 'Execution'.
Update the I_WBS_ELEMENT_TABLE_UPDATE table for the BAPI
This is done 3 times because there are 3 WBS elements
created for the Studio Project
DO 3 TIMES.
gt_wbs_element_table_update-wbs_element = 'I'.
APPEND gt_wbs_element_table_update.
ENDDO.
CALL FUNCTION 'BAPI_PROJECT_MAINTAIN'
EXPORTING
i_project_definition = gs_project_definition
i_project_definition_upd = gs_project_definition_upd
IMPORTING
return = gt_return
TABLES
i_method_project = gt_method_project
i_wbs_element_table_update = gt_wbs_element_table_update
i_wbs_element_table = gt_wbs_element_table
i_wbs_hierarchie_table = gt_wbs_hierarchie_table
e_message_table = gt_message_table.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'
IMPORTING
RETURN = gt_RETURN1.
----
----
Regards
Sudheer