Retreive Error Message from BDC

While doing call transaction, if an error occurs in updation, we declare bdcmsgcoll and store our messages in it, but how to retreive error message from it

Using function module 'FORMAT_MESSAGE' you can capture the messages.

Here is a sample of the program code for that:

  LOOP AT it_messtab.
  CALL FUNCTION 'FORMAT_MESSAGE'
    EXPORTING
      id     = it_messtab-msgid
      lang   = it_messtab-msgspra
      no     = it_messtab-msgnr
      v1     = it_messtab-msgv1
      v2     = it_messtab-msgv2
    IMPORTING
    msg    =  g_msg
  EXCEPTIONS
      OTHERS = 0.
  IF it_messtab-msgtyp = 'S'.
    it_sucess-sucess_rec = g_msg.
    it_sucess-lifnr = it_header-lifnr." Based on your field
    it_sucess-tabix = v_lines.
    APPEND it_sucess.
  ELSEIF it_messtab-msgtyp = 'E'.
    it_error-error_rec = g_msg.
    it_error-lifnr = it_header-lifnr.
    it_error-tabix = v_lines.
    APPEND it_error.
  ELSE.
    it_info-info_rec = g_msg.
    it_info-lifnr    = it_header-lifnr.
    it_info-tabix    = v_lines.
    APPEND it_info.
  ENDIF.
ENDLOOP.

ABAP Tips by :  Poornima Latha

Fast Links:
Get help for your ABAP problems
Do you have a ABAP Question?

SAP Books
SAP Certification, Functional, Basis Administration and ABAP Programming Reference Books

ABAP Tips
ABAP Forum for Discussion and Samples Program Codes for Abapers

Main Index
SAP Basis, ABAP Programming and Other IMG Stuff

All the site contents are Copyright © www.erpgreat.com and the content authors. All rights reserved.
All product names are trademarks of their respective companies.  The site www.erpgreat.com is in no way affiliated with SAP AG.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
 The content on this site may not be reproduced or redistributed without the express written permission of
www.erpgreat.com or the content authors.