08-23-2011 8:12 PM
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,
08-24-2011 2:46 AM
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
08-23-2011 9:21 PM
Give the details of the error that one PO or all PO's have come up with.
08-24-2011 2:46 AM
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
08-24-2011 6:00 PM
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