Skip to Content
author's profile photo Former Member
Former Member

bdcmsgcoll

how to handle errors using bdcmsgcoll.procedure

Add a comment
10|10000 characters needed characters exceeded

Related questions

6 Answers

  • Posted on Dec 03, 2007 at 04:01 AM

    Hi Shankar,

    Structure of <b>BDCMSGCOLL.</b>

    TCODE -> BDC Transaction code

    DYNAME -> Batch input module name

    DYNUMB -> Batch input screen number

    MSGTYP ->Batch input message type

    MSGSPRA -> Language ID of a message

    MSGID -> Batch input message ID

    MSGNR -> Batch input message number

    MSGV1 -> Variable part of a message

    MSGV2 -> Variable part of a message

    MSGV3 -> Variable part of a message

    MSGV4 -> Variable part of a message

    FLDNAME -> Field name

    Ex :

    DATA : <b>BDCMSGCOLL</b> TYPE TABLE OF BDCMSGCOLL WITH HEADER LINE,

    BDCDATA TYPE TABLE OF BDCDATA WITH HEADER LINE.

    CALL TRANSACTION 'MM01' USING BDCDATA MODE N UPDATE S MESSAGES INTO <b>BDCMSGCOLL.</b>

    IF SY-SUBRC <> 0.

    PERFORM ERR.

    CLEAR I_MSG.

    REFRESH I_MSG.

    ENDIF.

    &----


    *& Form ERR

    &----


    • text

    ----


    • --> p1 text

    • <-- p2 text

    ----


    form ERR .

    DATA V_MSG(255) TYPE C.

    READ TABLE I_MSG WITH KEY MSGTYP = 'E'.

    IF SY-SUBRC = 0.

    CALL FUNCTION 'FORMAT_MESSAGE'

    EXPORTING

    ID = I_MSG-MSGID

    LANG = 'E'

    NO = I_MSG-MSGNR

    V1 = I_MSG-MSGV1

    V2 = I_MSG-MSGV2

    V3 = I_MSG-MSGV3

    V4 = I_MSG-MSGV4

    IMPORTING

    MSG = V_MSG

    • EXCEPTIONS

    • 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.

    WRITE V_MSG. " Error Message Displayed Here.

    CLEAR V_MSG.

    ENDIF.

    endform. " ERR

    hope this will help you.

    <b>reward if useful</b>

    regards,

    sunil kairam.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 03, 2007 at 04:04 AM

    Hi,

    If you are using CALL TRANSACTION then we generally have those errors in BDCMSGCOLL structure

    Check this thread for sample code...

    errors-in-bdc

    Regards,

    Maha

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 03, 2007 at 10:21 AM

    Hi Shankar,

    <b>THIS IS CALL TRANSACTION METHOD.

    TCODE 'MK01' WITH DISPLAY ERROR MESSAGE .</b>

    no standard page heading line-size 255.

    data: begin of itab occurs 0,

    lifnr like lfa1-lifnr,

    ekorg like lfm1-ekorg,

    ktokk like lfa1-ktokk,

    name1 like lfa1-name1,

    sortl like lfa1-sortl,

    end of itab.

    data: bdcdata like bdcdata occurs 0 with header line,

    i_msg like bdcmsgcoll occurs 0 with header line.

    *include bdcrecx1.

    CALL FUNCTION 'GUI_UPLOAD'

    EXPORTING

    filename = 'C:/ITAB.TXT'

    • FILETYPE = 'ASC'

    HAS_FIELD_SEPARATOR = 'X'

    • HEADER_LENGTH = 0

    • READ_BY_LINE = 'X'

    • DAT_MODE = ' '

    • CODEPAGE = ' '

    • IGNORE_CERR = ABAP_TRUE

    • REPLACEMENT = '#'

    • IMPORTING

    • FILELENGTH =

    • HEADER =

    tables

    data_tab = ITAB

    • EXCEPTIONS

    • FILE_OPEN_ERROR = 1

    • FILE_READ_ERROR = 2

    • NO_BATCH = 3

    • GUI_REFUSE_FILETRANSFER = 4

    • INVALID_TYPE = 5

    • NO_AUTHORITY = 6

    • UNKNOWN_ERROR = 7

    • BAD_DATA_FORMAT = 8

    • HEADER_NOT_ALLOWED = 9

    • SEPARATOR_NOT_ALLOWED = 10

    • HEADER_TOO_LONG = 11

    • UNKNOWN_DP_ERROR = 12

    • ACCESS_DENIED = 13

    • DP_OUT_OF_MEMORY = 14

    • DISK_FULL = 15

    • DP_TIMEOUT = 16

    • OTHERS = 17

    .

    IF sy-subrc <> 0.

    • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

    start-of-selection.

    *perform open_group.

    LOOP AT ITAB.

    perform bdc_dynpro using 'SAPMF02K' '0107'.

    perform bdc_field using 'BDC_CURSOR'

    'RF02K-KTOKK'.

    perform bdc_field using 'BDC_OKCODE'

    '/00'.

    perform bdc_field using 'RF02K-LIFNR'

    • 'Di001'.

    ITAB-LIFNR.

    perform bdc_field using 'RF02K-EKORG'

    • '1000'.

    ITAB-EKORG.

    perform bdc_field using 'RF02K-KTOKK'

    • '0001'.

    ITAB-KTOKK.

    perform bdc_dynpro using 'SAPMF02K' '0110'.

    perform bdc_field using 'BDC_CURSOR'

    'LFA1-LAND1'.

    perform bdc_field using 'BDC_OKCODE'

    '/00'.

    perform bdc_field using 'LFA1-NAME1'

    • 'nehru'.

    ITAB-NAME1.

    perform bdc_field using 'LFA1-SORTL'

    • 'NE'.

    ITAB-SORTL.

    perform bdc_field using 'LFA1-LAND1'

    'in'.

    perform bdc_dynpro using 'SAPMF02K' '0120'.

    perform bdc_field using 'BDC_CURSOR'

    'LFA1-KUNNR'.

    perform bdc_field using 'BDC_OKCODE'

    '/00'.

    perform bdc_dynpro using 'SAPMF02K' '0310'.

    perform bdc_field using 'BDC_CURSOR'

    'LFM1-WAERS'.

    perform bdc_field using 'BDC_OKCODE'

    '/00'.

    perform bdc_field using 'LFM1-WAERS'

    'inr'.

    perform bdc_dynpro using 'SAPMF02K' '0320'.

    perform bdc_field using 'BDC_CURSOR'

    'RF02K-LIFNR'.

    perform bdc_field using 'BDC_OKCODE'

    '=ENTR'.

    perform bdc_dynpro using 'SAPLSPO1' '0300'.

    perform bdc_field using 'BDC_OKCODE'

    '=YES'.

    *perform bdc_transaction using 'MK01'.

    *perform close_group.

    CALL TRANSACTION 'MK01' USING BDCDATA

    UPDATE 'A'

    MODE 'A'

    MESSAGES INTO I_MSG.

    IF SY-SUBRC <> 0 .

    PERFORM ERROR.

    ENDIF.

    CLEAR BDCDATA.

    REFRESH BDCDATA.

    ENDLOOP.

    ----


    • Start new screen *

    ----


    FORM BDC_DYNPRO USING PROGRAM DYNPRO.

    CLEAR BDCDATA.

    BDCDATA-PROGRAM = PROGRAM.

    BDCDATA-DYNPRO = DYNPRO.

    BDCDATA-DYNBEGIN = 'X'.

    APPEND BDCDATA.

    ENDFORM.

    ----


    • Insert field *

    ----


    FORM BDC_FIELD USING FNAM FVAL.

    • IF FVAL <> NODATA.

    CLEAR BDCDATA.

    BDCDATA-FNAM = FNAM.

    BDCDATA-FVAL = FVAL.

    APPEND BDCDATA.

    • ENDIF.

    ENDFORM.

    <b>form ERR .

    DATA V_MSG(255) TYPE C.

    READ TABLE I_MSG WITH KEY MSGTYP = 'E'.

    IF SY-SUBRC = 0.

    CALL FUNCTION 'FORMAT_MESSAGE'

    EXPORTING

    ID = I_MSG-MSGID

    LANG = 'E'

    NO = I_MSG-MSGNR

    V1 = I_MSG-MSGV1

    V2 = I_MSG-MSGV2

    V3 = I_MSG-MSGV3

    V4 = I_MSG-MSGV4

    IMPORTING

    MSG = V_MSG

    • EXCEPTIONS

    • 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.

    WRITE V_MSG. " Error Message Displayed Here.

    CLEAR V_MSG.

    ENDIF.

    endform. " ERR</b>

    The above Blocked Part for Handling Message Using <b>BDCMSGCOLL</b> Structure.

    Regards,

    Vijay

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 04, 2007 at 05:22 AM

    <b>Hi shankar,

    If you still have doubts in BDCMSGCOLL just revert back if you got your answer then close the thread by assing points for useful answers.

    <b>dont forget to reward points for helpful answers</b>

    regards,

    sunil kairam.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 04, 2007 at 06:06 AM

    Steps for the error handling in CALL TRANSACTION:

    LOOP AT IT_DATA.

    Populate IT_BDCTAB table

    CALL TRANSACTION <> USING IT_BDCDATA

    MODE<A/N/E>

    UPDATE<A/S>

    MESSAGES INTO IT_BDCMSGCOLL.

    if sy-subrc <> 0.

    Call function FORMAT_MESSAGE.

    or

    Call Funciton BAPI_MESSAGE_GETDETAIL

    or

    Querry the message Text from teh table T100 for the Messages Collected into IT_BDCMSGCOLL.

    The Text in T100-TEXT would be maintained with place holders (&1,&2,&3,&4)

    Replace the place holders with Variable Texts from IT_BDCMSGCOLL(MSGV1,MSGV2,MSGV3,MSGV4).

    Either APPEND the error message to another internal table IT_ERROR and display it finally or display the record and message immediately.

    ENDLOOP.

    Rewards if useful.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 04, 2007 at 08:26 AM

    Hi

    To store error messages ( CALL TRANSACTION )

    data: begin of Tab_Mess occurs 0.

    include structure bdcmsgcoll.

    data : end of Tab_Mess,

    CALL TRANSACTION ‘FK02’ USING BDC_TAB MODE ‘N’ UPDATE ‘S’

    MESSAGES INTO TAB_MESS.

    IF SY-SUBRC NE 0.

    WRITE: / Tab_MESS-TCODE, Tab_MESS-DYNUMB, Tab_MESS-MSGTYP ,

    Tab_MESS-MSGID.

    ENDIF.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.