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_PO_CHANGE message error

Former Member
0 Kudos

Hello Guys,

I have a problem when calling the BAPI_PO_CHANGE in loop to update the field EREKZ (Final Invoice) from ME22N.

Follows the logic...

Loop

CALL FUNCTION 'BAPI_PO_CHANGE'

EXPORTING

purchaseorder = vl_po_number

TABLES

Return = tl_return

poitem = tl_poitem

poitemx = tl_poitemx.

IF sy-subrc = 0 .

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = c_x

ENDIF.

refresh (all structures and table)...

endloop

Today the program works nice, blocking all PO correctly (field EREKZ)...

But, if one PO return some error for internal table, all PO subsequent too will have some error.

I need so much of help,

Please, somebody knows what's happening?

Thank you,

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Fabrica,

>> Be sure that you are CLEARing all work-areas&variables and REFRESHing all internal tables Properly in the loop.

>> Don't use +IF sy-subrc = 0 + after BAPI call, instead check tl_return table for any error.

Read table tl_return into wa_return with key type = 'E'.

if sy-subrc = 0.

Call 'BAPI_TRANSACTION_ROLLBACK'

else.

Call BAPI_TRANSACTION_COMMIT

endif.

IF you still get same problem, simple DEBUG and check that are all the variables, workares, int tables are cleared well.

BR,

Diwakar

3 REPLIES 3

Former Member
0 Kudos

Give the details of the error that one PO or all PO's have come up with.

Former Member
0 Kudos

Fabrica,

>> Be sure that you are CLEARing all work-areas&variables and REFRESHing all internal tables Properly in the loop.

>> Don't use +IF sy-subrc = 0 + after BAPI call, instead check tl_return table for any error.

Read table tl_return into wa_return with key type = 'E'.

if sy-subrc = 0.

Call 'BAPI_TRANSACTION_ROLLBACK'

else.

Call BAPI_TRANSACTION_COMMIT

endif.

IF you still get same problem, simple DEBUG and check that are all the variables, workares, int tables are cleared well.

BR,

Diwakar

0 Kudos

Diwakar, thank you so much,

I did what you said and it worked.

Follows what I did...

The data of PO are allocated in MEMORY ID..

Then I created a new report only with the BAPI_PO_CHANGE that import the data from MEMORY ID.

This happens for each loop from the main program that calls the program thought of SUBMIT.

The program now is working correctly.

I'm really thankful

vostan