Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

BAPI's for creating of Project and WBS elements in SAP system.

Former Member
0 Kudos

Hi Guys,

I was able to use a Wrapper FM for creating the

We have a FM which combines 5 different BAPIs

FM/Wrapper: "Z_LEED_PROJ_WBSELEMT_CREATE"

1) BAPI_PS_INITIALIZATION

2) BAPI_BUS2001_CREATE

3) BAPI_BUS2054_CREATE_MULTI

4) BAPI_PS_PRECOMMIT

5) BAPI_TRANSACTION_COMMIT

Requirement: To automate the process of creation of Project and WBSE(Tasks) and create an entries in the PS tables based on the user inputs from the user interface in Visual Composer.

Basically user should be able to create the Projects and WBSE.

Issue: We were able to create the Project with the FM (BAPI_BUS2001_CREATE) but having the issue with the creation of WBSE(Tasks), the user will be entering the inputs for Project Definition, Project Profile and WBSE which are to be created in the UI.

The problem is we are not able to create the WBS elements using BAPI BAPI_BUS2054_CREATE_MULTI .i will send u the code below .Can anybody correct

CLEAR it_return.

CALL FUNCTION 'BAPI_BUS2054_CREATE_MULTI'

EXPORTING

I_PROJECT_DEFINITION = i_project_definition-project_definition

TABLES

IT_WBS_ELEMENT = it_wbs_element

ET_RETURN = it_return.

APPEND LINES OF it_return[] TO et_return[].

Thanks,

Gopi.

5 REPLIES 5

Former Member
0 Kudos

Hi guys,

Can anybody plz reply to this thread,atlest a suggestion?

Thanks,

Gopi.

0 Kudos

What is the return?

That code doesn't helps to see the problem

0 Kudos

Hi Ramiro,

This is the entire FM code which is below.

*"----


""Local Interface:

*" IMPORTING

*" VALUE(I_PROJECT_DEFINITION) LIKE BAPI_BUS2001_NEW STRUCTURE

*" BAPI_BUS2001_NEW

*" TABLES

*" IT_WBS_ELEMENT STRUCTURE BAPI_BUS2054_NEW

*" ET_RETURN STRUCTURE BAPIRET2 OPTIONAL

*" EXTENSIONIN STRUCTURE BAPIPAREX OPTIONAL

*" EXTENSIONOUT STRUCTURE BAPIPAREX OPTIONAL

*"----


DATA: it_return LIKE STANDARD TABLE OF BAPIRET2 WITH HEADER LINE,

v_error TYPE boolean VALUE IS INITIAL.

CLEAR: et_return, it_return.

CALL FUNCTION 'BAPI_PS_INITIALIZATION'.

  • Do checks for creating project definition

CALL FUNCTION 'BAPI_BUS2001_CREATE'

EXPORTING

I_PROJECT_DEFINITION = i_project_definition

TABLES

ET_RETURN = it_return.

APPEND LINES OF it_return[] TO et_return[].

LOOP AT it_return.

IF it_return-type CA 'EAX'.

CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.

v_error = 'X'.

EXIT.

ENDIF.

ENDLOOP.

IF v_error = 'X'.

EXIT.

ENDIF.

  • Do checks for creating WBS elements

CLEAR it_return.

CALL FUNCTION 'BAPI_BUS2054_CREATE_MULTI'

EXPORTING

I_PROJECT_DEFINITION = i_project_definition-project_definition

TABLES

IT_WBS_ELEMENT = it_wbs_element

ET_RETURN = it_return.

APPEND LINES OF it_return[] TO et_return[].

LOOP AT it_return.

IF it_return-type CA 'EAX'.

CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.

v_error = 'X'.

EXIT.

ENDIF.

ENDLOOP.

IF v_error = 'X'.

EXIT.

ENDIF.

CALL FUNCTION 'BAPI_PS_PRECOMMIT'

TABLES

ET_RETURN = it_return.

APPEND LINES OF it_return[] TO et_return[].

LOOP AT it_return.

IF it_return-type CA 'EAX'.

CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.

v_error = 'X'.

EXIT.

ENDIF.

ENDLOOP.

IF v_error = 'X'.

EXIT.

ENDIF.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

WAIT = 'X'.

ENDFUNCTION.

can u please look at the code and let me know the changes?

Thanks,

Gopi.

0 Kudos

Again, you don't say what is wrong with the code, it's just the calls of the bapis.

If there is an error, look for it in the return tables.

The only thing I can see that might be wrong with your code is that you most likely need a commit after the project definition creation to be able to use it in the wbs bapi

0 Kudos

Hi,

The individual WBS elements with all required values must be entered in table "IT_WBS_ELEMENT_TABLE". Please cross check your program with the bapi documentation, if any thing is missed.

Regards,

Keerthi