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

Problem in BDC : Call Transaction with error handling - Urgent

Hello Experts,

I'm using a call transaction method with error handling to upload customer master data.

CALL TRANSACTION 'FD01' USING bdcdata MODE 'N' UPDATE 'S'

MESSAGES INTO messtab.

The requirement is that whenever there is any error, an email is to be triggered to the user since the program will be running in background.

But when I'm calling the transaction in mode N, and even if the transaction is <b>not successful</b>, it gives <b>success message</b> in messtab. The actual database is not updated.

On the other hand, when I call the transaction in mode A or E, it gives the error message, but the program doesn't proceed unless I correct the input field in error.

What can be the problem? How can I handle error in N mode.

Please help....will reward full points if helpful.

Thanks in advance.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Posted on Sep 18, 2007 at 09:50 AM

    Hi Radhika...

    Generally when the transaction is Unsuccessful you must get the

    Message of type E or A.

    <b>In that Case you can Handle Like this:</b>

    Using BDCMSGCOLL Structure we have to declare an itab.

    DATA : IT_MSG LIKE TABLE OF BDCMSGCOLL .

    Then We can catch the messages using:

    CALL TRANSACTION 'MK01'

    USING IT_BDCDATA

    MODE 'N'

    MESSAGES INTO IT_MSG.

    IF sy-subrc ne 0.

    LOOP AT IT_MSG INTO WA_MSG

    WHERE MSGTYP = 'E' OR MSGTYP = 'A'..

    ENDLOOP.

    <b>Otherwise if the Transaction FD01 is unsuccessful bcoz the Customer already exists</b>

    Then it will give the Message type S.

    Before calling the Transaction FD01 you have to check whether customer already exists in SAP using SELECT single STATEMENT.

    Only if Customer does not exist then Call the Transaction.

    REWARD IF HELPFUL.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 18, 2007 at 10:19 AM

    Hi

    see this program once

    give ur file name here

    &----


    *& Report ZNNR_BDC

    *&

    &----


    *&

    *&

    &----


    REPORT ZNNR_BDC .

    DATA : BEGIN OF ITAB OCCURS 0,

    EMPID LIKE ZNNR-EMPID,

    EMPNAME LIKE ZNNR-EMPNAME,

    EMPADR LIKE ZNNR-EMPADR,

    END OF ITAB.

    DATA : BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.

    CALL FUNCTION 'GUI_UPLOAD'

    EXPORTING

    FILENAME = 'C:\NARESH\NARESH.TXT'

    • FILETYPE = 'ASC'

    HAS_FIELD_SEPARATOR = 'X'

    • HEADER_LENGTH = 0

    • READ_BY_LINE = 'X'

    • DAT_MODE = ' '

    • CODEPAGE = ' '

    • IGNORE_CERR = ABAP_TRUE

    • REPLACEMENT = '#'

    • CHECK_BOM = ' '

    • VIRUS_SCAN_PROFILE =

    • NO_AUTH_CHECK = ' '

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

    CALL FUNCTION 'BDC_OPEN_GROUP'

    EXPORTING

    CLIENT = SY-MANDT

    • DEST = FILLER8

    GROUP = 'NARESH'

    • HOLDDATE = FILLER8

    KEEP = 'X'

    USER = SY-UNAME

    • RECORD = FILLER1

    • PROG = SY-CPROG

    • IMPORTING

    • QID =

    EXCEPTIONS

    CLIENT_INVALID = 1

    DESTINATION_INVALID = 2

    GROUP_INVALID = 3

    GROUP_IS_LOCKED = 4

    HOLDDATE_INVALID = 5

    INTERNAL_ERROR = 6

    QUEUE_ERROR = 7

    RUNNING = 8

    SYSTEM_LOCK_ERROR = 9

    USER_INVALID = 10

    OTHERS = 11

    .

    IF SY-SUBRC <> 0.

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

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

    ENDIF.

    LOOP AT ITAB.

    REFRESH BDCDATA.

    PERFORM BDC_DYNPRO USING 'ZNNR_MODULE' '0100'.

    PERFORM BDC_FIELD USING 'BDC_CURSOR'

    'ZNNR-EMPADR'.

    PERFORM BDC_FIELD USING 'BDC_OKCODE'

    '=CRT'.

    PERFORM BDC_FIELD USING 'ZNNR-EMPID'

    ITAB-EMPID.

    PERFORM BDC_FIELD USING 'ZNNR-EMPNAME'

    ITAB-EMPNAME.

    PERFORM BDC_FIELD USING 'ZNNR-EMPADR'

    ITAB-EMPADR.

    • PERFORM BDC_TRANSACTION USING 'ZNNC'.

    CALL FUNCTION 'BDC_INSERT'

    EXPORTING

    TCODE = 'ZNNC'

    • POST_LOCAL = NOVBLOCAL

    • PRINTING = NOPRINT

    • SIMUBATCH = ' '

    • CTUPARAMS = ' '

    TABLES

    DYNPROTAB = BDCDATA

    EXCEPTIONS

    INTERNAL_ERROR = 1

    NOT_OPEN = 2

    QUEUE_ERROR = 3

    TCODE_INVALID = 4

    PRINTING_INVALID = 5

    POSTING_INVALID = 6

    OTHERS = 7

    .

    IF SY-SUBRC <> 0.

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

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

    ENDIF.

    ENDLOOP.

    CALL FUNCTION 'BDC_CLOSE_GROUP'

    EXCEPTIONS

    NOT_OPEN = 1

    QUEUE_ERROR = 2

    OTHERS = 3

    .

    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 :/ 'SESSION CREATED SUCCESSFULLY'.

    FORM BDC_DYNPRO USING PROGRAM DYNPRO.

    CLEAR BDCDATA.

    BDCDATA-PROGRAM = PROGRAM.

    BDCDATA-DYNPRO = DYNPRO.

    BDCDATA-DYNBEGIN = 'X'.

    APPEND BDCDATA.

    ENDFORM.

    FORM BDC_FIELD USING FNAM FVAL.

    • IF FVAL <> NODATA.

    CLEAR BDCDATA.

    BDCDATA-FNAM = FNAM.

    BDCDATA-FVAL = FVAL.

    APPEND BDCDATA.

    • ENDIF.

    ENDFORM.

    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.