Actually the problem is in the standard program (SAPMWPUK) underlying WPUK. There is the following code:
call function 'IDOC_INBOUND_WRITE_TO_DB'
exporting
pi_do_handle_error = ' '
importing
pe_state_of_processing = l_state_of_processing
pe_inbound_process_data = l_inbound_process_data
tables
t_data_records = g_t_edidd
changing
pc_control_record = g_t_edidc
exceptions
idoc_not_saved = 1
others = 2.
if sy-subrc = 0 and sy-binpt <> 'X'.
commit work.
endif.
if l_state_of_processing = 0 and sy-subrc = 0.
append g_t_edidc to l_t_edidc.
call function 'IDOC_START_INBOUND'
exporting
pi_inbound_process_data = l_inbound_process_data
pi_called_online = 'X'
pi_do_commit = 'X'
tables
t_control_records = l_t_edidc
exceptions
others = 8.
The status variable sy-binpt is 'X' and thus there is no commit and then when IDOC_START_INBOUND FM is called it raises exception because although IDoc number is reserved it cannot be found in the database - due to no commit.
As an alternative, is there a BAPI or something else other than batch input to call WPUK??
Thanks in advance,
Konstantinos