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: 

how to use BAPI in series?

Former Member
0 Kudos

Dear experts:

when i use ['BAPI_BUS2054_CREATE_MULTI'] to create the WBS, the message type occurs s, means the wbs has been created sucessfully. but when i use [BAPI_BUS2054_SET_STATUS] to get the status, it tell me that wbs is not exist, anyone can tell me why.thanks.

CALL FUNCTION 'BAPI_PS_INITIALIZATION'.

CALL FUNCTION 'BAPI_BUS2054_CREATE_MULTI'

EXPORTING

i_project_definition = l_project

TABLES

it_wbs_element = lt_wbs_table

et_return = lt_message

extensionin = lt_extensionin

extensionout = lt_extensionout.

  • ENDTRY.

LOOP AT lt_message WHERE type = 'E'

OR type = 'I'.

gt_log-messagetype = 'E'.

gt_log-zmenum = c_create_menum_error.

gt_log-zdate = sy-datum.

gt_log-ztime = sy-uzeit.

gt_log-zmessage = lt_message-message.

APPEND gt_log.

ENDLOOP.

IF sy-subrc = 0.

CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.

ELSE.

gt_log-messagetype = 'S'.

gt_log-zmenum = c_create_menum_ok.

gt_log-zdate = sy-datum.

gt_log-ztime = sy-uzeit.

gt_log-zmessage = 'WBS created'.

APPEND gt_log.

CALL FUNCTION 'BAPI_PS_PRECOMMIT'.

CALL FUNCTION 'BAPI_PS_INITIALIZATION'.

CALL FUNCTION 'BAPI_BUS2054_SET_STATUS'

  • IMPORTING

  • RETURN =

TABLES

i_wbs_system_status = lt_system_satus

  • i_wbs_user_status = lt_user_satus

e_result = lt_message_status.

LOOP AT lt_message_status WHERE message_type = 'E'

OR message_type = 'I'.

gt_log-messagetype = 'E'.

gt_log-zmenum = c_create_menum_error.

gt_log-zdate = sy-datum.

gt_log-ztime = sy-uzeit.

gt_log-zmessage = lt_message_status-message_text.

APPEND gt_log.

ENDLOOP.

IF sy-subrc = 0.

CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.

ELSE.

gt_log-messagetype = 'S'.

gt_log-zmenum = c_create_menum_ok.

gt_log-zdate = sy-datum.

gt_log-ztime = sy-uzeit.

gt_log-zmessage = 'WBS updated status'

APPEND gt_log.

CALL FUNCTION 'BAPI_PS_PRECOMMIT'.

  • CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

ENDIF.

ENDIF.

Monson

8 REPLIES 8

valter_oliveira
Active Contributor
0 Kudos

Hello.

Are you using BAPI_TRANSACTION_COMMIT after each BAPI you use? i.e, instead of after first BAPI verify if an error occured, and if yes, use BAPI_TRANSACTION_ROLLBACK, use if an error didn't occur, use BAPI_TRANSACTION_COMMIT.

If an error occurs, and you don't make commit, you don't need to use roolback.

Best regards.

Valter Oliveira.

0 Kudos

pls see clearly about this question, thanks for your answer..

0 Kudos

Hi again.

I was sugesting you not to use BAPI_transction_rollback and use BAPI_transaction_commit instead.

You use 1st BAPI and it returns ok. However, you must use BAPI_transaction_commit instead (with parameter wait = 'X'), before using the second one. If not, the first document is not "really" in the system, only in the buffer.

Just try:

BAPI 1 - (if success commit bapi)

then

BAPI 2 - (if success commit bapi)

Hope this helps.

Best regards.

Valter Oliveira.

0 Kudos

hi

thanks for your reply.

but if bapi call failed, i use rollback work

if bapi call sucess, i use commit work.

can you help me to work out my question ?

0 Kudos

Hi,

Please take a look at your code carefully, insert 'BAPI_TRANSACTION_COMMIT' before 'BAPI_PS_INITIALIZATION' as they recomended.

Hope it helps,

Chang

Former Member
0 Kudos

use [ 'BAPI_BUS2054_CREATE_MULTI' ] can see wbs has been created, but use [ BAPI_BUS2054_SET_STATUS ] the system tell me [wbs is not exitst]..

anyone can tell me why?

Former Member
0 Kudos

Hi,

I hope the below link will help you.

Thanks,

Khushboo.

Former Member
0 Kudos

Hi experts,

I want to create a WBS element using the BAPI's BAPI_BUS2054_CREATE_MULTI .

I did this sequence of test :

BAPI_PS_INITIALIZATION

BAPI_BUS2054_CREATE_MULTI

And I have this return

S CNIF_PI 004 Individual check for creating the object WBS Element U008-F033-001 required

CAn anyone tell me what to do in order to resolve this problem ( calling a commit after this sequence leads to 'DUMP' bacause no precommit is called before )

Thanks in advance