HI Wei,
Appreciate your investigation.
I was facing the same issue while creating delivery from STO. It was observed BAPI "BAPI_DELIVERYPROCESSING_EXEC" was successfully creating delivery upto 2 STOs, but at the time of 3rd delivery process by 3rd STO , BAPI failed to create delivery.
It was due to 3rd STO failed to fetch EKPV table data for that 3rd STO done in "ME_EKPV_ARRAY_READ" FM exist in above delivery BAPI.
under this FM , there is counter me->mv_iter which limits iteration max to 2 counts.
use "ME_EKPV_ARRAY_READ" function module with PI_REFRESH_BUFFER = 'X' before calling BAPI "BAPI_DELIVERYPROCESSING_EXEC".
-------------------------Code--------------------------------
CALL FUNCTION 'ME_EKPV_ARRAY_READ'
EXPORTING
pi_refresh_buffer = c_x
TABLES
pti_ekpv_key = lt_pti_ekpv_key.
CLEAR lt_pti_ekpv_key[].
CALL FUNCTION 'BAPI_DELIVERYPROCESSING_EXEC'
TABLES
request = lt_request[]
createditems = lt_createditems[]
return = lt_return[].
-----------------------------------------------------------------------
By using above logic, an issue has been solved.
Thanks,
Vikas