2008 Jul 30 10:43 PM
i'm calling the bapi_po_create1 from an rfc, it contains some errors, that i can see it in the return table, but i've tried to catch wether is an error ocurred or not, but the sy-subrc it's always 0, why??
here's my code:
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
poheader = v_header
poheaderx = v_headerx
IMPORTING
exppurchaseorder = v_purch
TABLES
poitem = v_item
poitemx = v_itemx
return = v_return.
IF sy-subrc = 0. "always = 0
PERFORM pr_commit TABLES v_return
USING 'X'.
WRITE: / v_purch.
ELSE.
LOOP AT v_return.
WRITE: / v_return-type,
v_return-message.
ENDLOOP.
ENDIF.
2008 Jul 30 10:56 PM
hi,
the call of 'BAPI_PO_CREATE1' will never set the sy-subrc, because there's no exception for it. The only chance you have is to check the return table for error messages, like
loop at v_return where msgty = 'E'.
WRITE: / v_return-type,
v_return-message.
endloop.
if sy-subrc <> 0.
* everyting seems ok
PERFORM pr_commit TABLES v_return
USING 'X'.
WRITE: / v_purch.
endif.
hope it helps.
Hi,
Define an internal table or type BAPIRET2 for holding the error messages and pass it to function module as RETURN table for catching errors.
loop at it_return.
commit if there are no errors.
endloop.
Regards,
Srilatha.
2008 Jul 30 10:53 PM
Hi,
Define an internal table or type BAPIRET2 for holding the error messages and pass it to function module as RETURN table for catching errors.
loop at it_return.
commit if there are no errors.
endloop.
Regards,
Srilatha.
2008 Jul 30 10:56 PM
hi,
the call of 'BAPI_PO_CREATE1' will never set the sy-subrc, because there's no exception for it. The only chance you have is to check the return table for error messages, like
loop at v_return where msgty = 'E'.
WRITE: / v_return-type,
v_return-message.
endloop.
if sy-subrc <> 0.
* everyting seems ok
PERFORM pr_commit TABLES v_return
USING 'X'.
WRITE: / v_purch.
endif.
hope it helps.
2008 Jul 30 10:57 PM
Instead of using sy-subrc use:
IF v_return[] IS INITIAL.
then check for message type E
ENDIF.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |