‎2006 Sep 15 12:11 PM
Hi frnds i m unable to know the answer for the q?
How do u handle errors in BAPI.
i.e i m using standard BAPI po creation if some errors occurs then how to handle those errors
how can we know the errors.
plz reply me back frnds...
thnks...
‎2006 Sep 15 12:13 PM
BAPI_PO_CREATE REturns back a table "RETURN STRUCTURE" which will contain any errors occurred during execution.You can assign any table to this parameter and it should get filled in case of errors.
‎2006 Sep 15 12:33 PM
‎2006 Sep 15 12:41 PM
Hi Sanjay,
Call BAPI like this :
data: it_retrun typa table of bapireturn.
CALL FUNCTION 'BAPI_PO_CREATE'
EXPORTING
po_header =
PO_HEADER_ADD_DATA =
HEADER_ADD_DATA_RELEVANT =
PO_ADDRESS =
SKIP_ITEMS_WITH_ERROR = 'X'
ITEM_ADD_DATA_RELEVANT =
HEADER_TECH_FIELDS =
IMPORTING
PURCHASEORDER =
tables
po_items =
PO_ITEM_ADD_DATA =
po_item_schedules =
PO_ITEM_ACCOUNT_ASSIGNMENT =
PO_ITEM_TEXT =
RETURN = it_return
PO_LIMITS =
PO_CONTRACT_LIMITS =
PO_SERVICES =
PO_SRV_ACCASS_VALUES =
PO_SERVICES_TEXT =
PO_BUSINESS_PARTNER =
EXTENSIONIN =
POADDRDELIVERY =
IT_RETURN will contains all message returned from BAPI. For error message you can read IT_RETURN table where type = 'E'.
Thanks
Swagatika
.
‎2006 Sep 15 12:42 PM
Hi,
please have a look at code.
data po_head type BAPIEKKOC,
it_poitem type table of BAPIEKPOC ,
it_return type table of BAPIRETURN.
CALL FUNCTION 'BAPI_PO_CREATE'
EXPORTING
PO_HEADER = po_head
PO_HEADER_ADD_DATA =
HEADER_ADD_DATA_RELEVANT =
PO_ADDRESS =
SKIP_ITEMS_WITH_ERROR = 'X'
ITEM_ADD_DATA_RELEVANT =
IMPORTING
PURCHASEORDER =
TABLES
PO_ITEMS = it_poitem
PO_ITEM_ADD_DATA =
PO_ITEM_SCHEDULES =
PO_ITEM_ACCOUNT_ASSIGNMENT =
PO_ITEM_TEXT =
RETURN = it_return
PO_LIMITS =
PO_CONTRACT_LIMITS =
PO_SERVICES =
PO_SRV_ACCASS_VALUES =
PO_SERVICES_TEXT =
PO_BUSINESS_PARTNER =
EXTENSIONIN =
POADDRDELIVERY =
.
IT_RETURN will have all the messages after executing the bapi.
Regards,
Rahul
‎2006 Sep 15 12:47 PM
Hi,
BAPIs have standardized interface. Every BAPI will have a RETURN table parameter which contains all the messages that the BAPI gets while during execution.
The messages returned by each BAPI is documented very well. You can check for the RETURN parameter to find out the status of the call.
Regards,
Mustajab
‎2006 Sep 15 12:49 PM
Hi Sanjay
While we are using the BAPIs,its not like the CALL TRANSACTION where we have to handle all the errors.
Seee i am clearing ur doubts.
BAPIs are function RFC modules where we will passing some values in the import parameters and also in table parameters.If we are passing the wrong values then it will not execute and through the errors which we can view in return parameters by seeing the error descriptions.
This is the main disadvantage of BAPI that we will not be knowing the perticular line where error occured.
Try to pass the correct values in correct format for BAPI_PO_CREATE .U can refer FM documentation for this.
Its better to pass the valus and Debugg the FM and watch where error is occuring.
Regards
Manas Ranjan Panda.
‎2006 Sep 15 1:36 PM
Hi Sanjay,
you r using BAPI_po_create.
once look at tables interface in BAPI_po_create.
there u find RETURN like BAPIRETURN.
after calling bapi u loop at tha err_tab that of structue BAPIRETURN.
there u search for errors.
loop at itab.
at new xxx.
endat.
....
....
at end of xxx.
call functin 'bapi_po_create'.
clear flag.
loop at err_tab.
if (err_tab-type = 'E') or err_tab-type = 'W'.
flag = 'X'.
endif.
if flag is initial.
call fuction 'BAPI_TRANSACTION_COMMIT'
wait = 'X'.
else.
call fuction 'BAPI_TRANSACTION_ROLLBACK'.
endif.
endat.
‎2006 Sep 15 1:43 PM
Hi Sanjay,
you r using BAPI_po_create.
once look at tables interface in BAPI_po_create.
there u find RETURN like BAPIRETURN.
after calling bapi u loop at tha err_tab that of structue BAPIRETURN.
there u search for errors.
loop at itab.
at new xxx.
endat.
....
....
at end of xxx.
call functin 'bapi_po_create'.
clear flag.
loop at err_tab.
if (err_tab-type = 'E') or err_tab-type = 'W'.
flag = 'X'.
endif.
endloop.
if flag is initial.
call fuction 'BAPI_TRANSACTION_COMMIT'
wait = 'X'.
else.
call fuction 'BAPI_TRANSACTION_ROLLBACK'.
endif.
endat.
endloop.
‎2006 Sep 15 9:03 PM
Hello Sanjay
As several other SDN users already have said BAPIs have standardized error handling. They neve throw or raise any exception but return the corresponding messages.
If you simply want to check for success or failure you could use the following coding:
" BAPI returns single message
IF ( return-type CA 'AEX' ).
"... failure -> rollback and exit
ELSE.
"... success -> commit work
ENDIF.
"BAPI returns itab with messages
LOOP AT return TRANSPORTING NO FIELDS
WHERE ( type CA 'AEX' ).
EXIT.
ENDLOOP.
IF ( syst-subrc = '0' ).
"... failure -> rollback and exit
ELSE.
"... success -> commit work
ENDIF.Please note that the names of the return parameters may vary between BAPIs.
Regards
Uwe