Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

error handling in call transaction

Former Member
0 Kudos

hi ..

can any one tell about error handling in call transaction and

simple example program for error handling in call transaction

1 ACCEPTED SOLUTION

Former Member
0 Kudos

hi,

also an easy example

CALL TRANSACTION 'VD51' USING it_bdc MODE 'A' UPDATE 'S'

MESSAGES INTO it_messages.

IF NOT it_messages[] IS INITIAL.

PERFORM format_message.

ENDIF.

----


  • FORM FORMAT_MESSAGE *

----


  • ........ *

----


FORM format_message.

DATA: l_msg(100).

LOOP AT it_messages.

READ TABLE it_customer INDEX l_index.

CALL FUNCTION 'FORMAT_MESSAGE'

EXPORTING

id = it_messages-msgid

lang = sy-langu

no = it_messages-msgnr

v1 = it_messages-msgv1

v2 = it_messages-msgv2

v3 = it_messages-msgv3

v4 = it_messages-msgv4

IMPORTING

msg = l_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:/ l_msg.

ENDLOOP.

ENDFORM. " FORMAT_MESSAGE

4 REPLIES 4

Former Member
0 Kudos

Have a look at this:

  call transaction 'FB01' using bdcdata mode 'N' update 'S'
                          messages into messtab.

* Display the messages
  loop at messtab.
* Message for changed account assignment has already been displayed
    if messtab-msgid  = 'FICUSTOM' and
       messtab-msgtyp = 'W'        and
       messtab-msgnr  = '014'.
      continue.
    endif.
    sy-msgid = messtab-msgid.
    sy-msgty = messtab-msgtyp.
    sy-msgno = messtab-msgnr.
    sy-msgv1 = messtab-msgv1.
    sy-msgv2 = messtab-msgv2.
    sy-msgv3 = messtab-msgv3.
    sy-msgv4 = messtab-msgv4.
    message id sy-msgid type sy-msgty number sy-msgno
            with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

    if sy-msgid = 'F5' and sy-msgno = '312'.
      perform clear_screen.
    endif.
    delete messtab.
  endloop.

Rob

Former Member
0 Kudos

hi friend,

dont mind just use same question in search option ,

u come across many threads not only 1/2 .

from that u can choose as per ur rquirement.

Thanks

Former Member
0 Kudos

Hi Lokesh,

This is a sample error handling while uploading Customers..

Generally when the transaction is Unsuccessful you must get the

Message of type E or A.

In that Case you can Handle Like this:

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.

Otherwise if the Transaction FD01 is unsuccessful bcoz the Customer already exists

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.

Former Member
0 Kudos

hi,

also an easy example

CALL TRANSACTION 'VD51' USING it_bdc MODE 'A' UPDATE 'S'

MESSAGES INTO it_messages.

IF NOT it_messages[] IS INITIAL.

PERFORM format_message.

ENDIF.

----


  • FORM FORMAT_MESSAGE *

----


  • ........ *

----


FORM format_message.

DATA: l_msg(100).

LOOP AT it_messages.

READ TABLE it_customer INDEX l_index.

CALL FUNCTION 'FORMAT_MESSAGE'

EXPORTING

id = it_messages-msgid

lang = sy-langu

no = it_messages-msgnr

v1 = it_messages-msgv1

v2 = it_messages-msgv2

v3 = it_messages-msgv3

v4 = it_messages-msgv4

IMPORTING

msg = l_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:/ l_msg.

ENDLOOP.

ENDFORM. " FORMAT_MESSAGE