11-18-2007 7:31 AM
11-18-2007 7:51 AM
Hi Sudhakar,
You have to create a parameter named Return for every BAPI. This parameter returns exception messages or success messages to the calling program.
BAPIs themselves must not trigger any messages (such as MESSAGE xnnn) in the coding. In particular they must not generate terminations or display dialog boxes. Instead, all messages must be intercepted internally and reported back to the calling program in the Return parameter. Otherwise the BAPI will not be processed correctly and control may not be given back to the calling program.
All error messages or indeed any message that may be returned by the BAPI, must be defined in message table (Tools -> ABAP Workbench -> Development -> Programming environment -> Messages) and described in the documentation for the return parameter. This also applies to the most important or most likely error messages generated by other programs that can be indirectly passed via the BAPI to the application program.
ans in BAPI'S u can handle the errors with the help of BAPI RETURN parameter.
U have to declare an internal table like BAPIRET2. u need to pass this internal table to the RETURN structure .Now this internal table will capture the error messages once u run the BAPI.
Have a look at below link.
http://help.sap.com/saphelp_nw04/helpdata/en/a5/3ec9f74ac011d1894e0000e829fbbd/content.htm
Hope it will solve ur problem
<b>Reward points if useful..</b>
Thanks & Regards
ilesh 24x7
11-18-2007 7:57 AM
Hi
In Every Bapi there will be a RETURN parameter of type BAPIRET2.
WE PASS IT AS TABLES PARAMETERS
AND ALL THE ERRORS ARE COLLECTED INTO IT
see the sample code
REPORT z34332_bdc_create_material .
data: la_headdata type BAPIMATHEAD,
la_clientdata type BAPI_MARA,
la_CLIENTDATAX type BAPI_MARAX,
<b>la_return type BAPIRET2.</b>
data: i_materialdescription type table of BAPI_MAKT,
wa_materialdescription like line of i_materialdescription.
la_headdata-MATERIAL = '000000000000000004'.
la_headdata-IND_SECTOR = 'M'.
la_headdata-MATL_TYPE = 'FERT'.
la_clientdata-BASE_UOM = 'FT3'.
la_CLIENTDATAX-BASE_UOM = 'X'.
la_clientdata-MATL_GROUP = '01'.
la_CLIENTDATAX-MATL_GROUP = 'X'.
wa_materialdescription = 'TEST'.
append wa_materialdescription to i_materialdescription.
clear: wa_materialdescription.
CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
EXPORTING
headdata = la_headdata
CLIENTDATA = la_clientdata
CLIENTDATAX = la_CLIENTDATAX
PLANTDATA =
PLANTDATAX =
FORECASTPARAMETERS =
FORECASTPARAMETERSX =
PLANNINGDATA =
PLANNINGDATAX =
STORAGELOCATIONDATA =
STORAGELOCATIONDATAX =
VALUATIONDATA =
VALUATIONDATAX =
WAREHOUSENUMBERDATA =
WAREHOUSENUMBERDATAX =
SALESDATA =
SALESDATAX =
STORAGETYPEDATA =
STORAGETYPEDATAX =
FLAG_ONLINE = ' '
FLAG_CAD_CALL = ' '
IMPORTING
<b>RETURN = la_return</b>
TABLES
MATERIALDESCRIPTION = i_materialdescription
UNITSOFMEASURE =
UNITSOFMEASUREX =
INTERNATIONALARTNOS =
MATERIALLONGTEXT =
TAXCLASSIFICATIONS =
RETURNMESSAGES =
PRTDATA =
PRTDATAX =
EXTENSIONIN =
EXTENSIONINX =
.
<b>write: la_return-TYPE, ',', la_return-MESSAGE.</b>
clear: la_headdata, la_return, la_clientdata, la_clientdatax.
Regards
Anji
11-30-2007 3:54 AM
Hi
You could try to use application logs.
Check out sample program: SBAL_DEMO_04
Hope this helps.
Regards,
Joanne
DATA:
gs_log_handle TYPE balloghndl,
gs_control_handle TYPE balcnthndl,
gs_container TYPE REF TO cl_gui_dialogbox_container,
gs_s_log TYPE bal_s_log,
gs_t_log_handle TYPE bal_t_logh,
gs_s_msg TYPE bal_s_msg,
gs_s_display_profile TYPE bal_s_prof,
gs_msgno TYPE bal_s_msg-msgno.
gs_s_log-extnumber = 'APPLICATION LOG CONTROL FOR OPERATION'.
CALL FUNCTION 'BAL_LOG_CREATE'
EXPORTING
i_s_log = gs_s_log
IMPORTING
e_log_handle = gs_log_handle
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CALL FUNCTION 'BAL_DSP_LOG_PARAMETERS'
EXPORTING
i_log_handle = gs_log_handle
i_langu = sy-langu
EXCEPTIONS
log_not_found = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ADD 1 TO gs_msgno.
CLEAR gs_s_msg.
CALL FUNCTION 'BAL_LOG_MSG_ADD'
EXPORTING
i_log_handle = gs_log_handle
i_s_msg = gs_s_msg
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Get a prepared profile
CALL FUNCTION 'BAL_DSP_PROFILE_POPUP_GET'
IMPORTING
e_s_display_profile = gs_s_display_profile
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Set report to allow saving of variants
gs_s_display_profile-disvariant-report = sy-repid.
gs_s_display_profile-disvariant-handle = 'LOG'.
CALL FUNCTION 'BAL_DSP_LOG_DISPLAY'
EXPORTING
i_s_display_profile = gs_s_display_profile
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
01-29-2015 3:00 PM