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

Hii Gurus

plz help me

need the code details how to handle errors in call transaction

means after transfering data to BDCMSGCOLL

how to show those through format_message .

Thanx to all in advance

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Have a look at the code snippet. This handles the error management scenario exclusively.

 

REFRESH MESSTAB. 
    CALL TRANSACTION TRANS_TAB-TCODE USING BDC_TAB 
                                           OPTIONS FROM CTU_PARAMS 
                                           MESSAGES INTO MESSTAB. 

DESCRIBE TABLE MESSTAB LINES SY-TFILL. 
    IF SY-TFILL <= 0. 
      CLEAR ITEMTAB. 
      WRITE L_COUNT TO ITEMTAB-TA_NUM LEFT-JUSTIFIED. 
      ITEMTAB-MSGTEXT = 'Keine'(009). 
      APPEND ITEMTAB. 
    ELSE. 
      LOOP AT MESSTAB. 
        SELECT SINGLE * FROM T100 WHERE SPRSL = MESSTAB-MSGSPRA 
                                  AND   ARBGB = MESSTAB-MSGID 
                                  AND   MSGNR = MESSTAB-MSGNR. 
        IF SY-SUBRC = 0. 
          L_MSTRING = T100-TEXT. 
          IF L_MSTRING CS '&1'. 
            REPLACE '&1' WITH MESSTAB-MSGV1 INTO L_MSTRING. 
            REPLACE '&2' WITH MESSTAB-MSGV2 INTO L_MSTRING. 
            REPLACE '&3' WITH MESSTAB-MSGV3 INTO L_MSTRING. 
            REPLACE '&4' WITH MESSTAB-MSGV4 INTO L_MSTRING. 
          ELSE. 
            REPLACE '&' WITH MESSTAB-MSGV1 INTO L_MSTRING. 
            REPLACE '&' WITH MESSTAB-MSGV2 INTO L_MSTRING. 
            REPLACE '&' WITH MESSTAB-MSGV3 INTO L_MSTRING. 
            REPLACE '&' WITH MESSTAB-MSGV4 INTO L_MSTRING. 
          ENDIF. 
          CONDENSE L_MSTRING. 

          CLEAR ITEMTAB. 
          WRITE L_COUNT TO ITEMTAB-TA_NUM LEFT-JUSTIFIED. 
          MOVE-CORRESPONDING MESSTAB TO ITEMTAB. 
          ITEMTAB-MSGTEXT = L_MSTRING. 
          APPEND ITEMTAB. 
        ENDIF. 
      ENDLOOP. 
    ENDIF. 

Have a look at the Message Handling Part. This deals with the way the messages will be handled.

You can get a more detailed information in the package : SBDC.

Hope this helps.

Thanks,

Samantak.

6 REPLIES 6

Former Member
0 Kudos

Hi bhabanibiswal

here is sample one

DATA: gi_bdcdata TYPE TABLE OF bdcdata WITH HEADER LINE,

gi_msgtab TYPE TABLE OF bdcmsgcoll WITH HEADER LINE.

CALL TRANSACTION 'xxxx' USING gi_bdcdata

MODE 'N''

UPDATE 'S'

MESSAGES INTO gi_msgtab.

Then loop at gi_msgtab and pass the value to Fm format_message

i think above info helps you

Thanks

Ramesh

0 Kudos

Hello,

For message formatting u can also use SE91 and n can make a class over there and put ur msg id thn u can create msgs there and u can use in ur format_message function directly ..

thanks & regards

Girish Goyal

Former Member
0 Kudos

Hi,

Have a look at the code snippet. This handles the error management scenario exclusively.

 

REFRESH MESSTAB. 
    CALL TRANSACTION TRANS_TAB-TCODE USING BDC_TAB 
                                           OPTIONS FROM CTU_PARAMS 
                                           MESSAGES INTO MESSTAB. 

DESCRIBE TABLE MESSTAB LINES SY-TFILL. 
    IF SY-TFILL <= 0. 
      CLEAR ITEMTAB. 
      WRITE L_COUNT TO ITEMTAB-TA_NUM LEFT-JUSTIFIED. 
      ITEMTAB-MSGTEXT = 'Keine'(009). 
      APPEND ITEMTAB. 
    ELSE. 
      LOOP AT MESSTAB. 
        SELECT SINGLE * FROM T100 WHERE SPRSL = MESSTAB-MSGSPRA 
                                  AND   ARBGB = MESSTAB-MSGID 
                                  AND   MSGNR = MESSTAB-MSGNR. 
        IF SY-SUBRC = 0. 
          L_MSTRING = T100-TEXT. 
          IF L_MSTRING CS '&1'. 
            REPLACE '&1' WITH MESSTAB-MSGV1 INTO L_MSTRING. 
            REPLACE '&2' WITH MESSTAB-MSGV2 INTO L_MSTRING. 
            REPLACE '&3' WITH MESSTAB-MSGV3 INTO L_MSTRING. 
            REPLACE '&4' WITH MESSTAB-MSGV4 INTO L_MSTRING. 
          ELSE. 
            REPLACE '&' WITH MESSTAB-MSGV1 INTO L_MSTRING. 
            REPLACE '&' WITH MESSTAB-MSGV2 INTO L_MSTRING. 
            REPLACE '&' WITH MESSTAB-MSGV3 INTO L_MSTRING. 
            REPLACE '&' WITH MESSTAB-MSGV4 INTO L_MSTRING. 
          ENDIF. 
          CONDENSE L_MSTRING. 

          CLEAR ITEMTAB. 
          WRITE L_COUNT TO ITEMTAB-TA_NUM LEFT-JUSTIFIED. 
          MOVE-CORRESPONDING MESSTAB TO ITEMTAB. 
          ITEMTAB-MSGTEXT = L_MSTRING. 
          APPEND ITEMTAB. 
        ENDIF. 
      ENDLOOP. 
    ENDIF. 

Have a look at the Message Handling Part. This deals with the way the messages will be handled.

You can get a more detailed information in the package : SBDC.

Hope this helps.

Thanks,

Samantak.

0 Kudos

Hello,

Use the below code to format the BDCMSGCOLL messages.

Loop at messtab.

CALL FUNCTION 'MESSAGE_PREPARE'

EXPORTING

LANGUAGE = messtab-MSGSPRA

MSG_ID = messtab-MSGID

MSG_NO = messtab-MSGNR

MSG_VAR1 = messtab-MSGV1

MSG_VAR2 = messtab-MSGV1

MSG_VAR3 = messtab-MSGV1

MSG_VAR4 = messtab-MSGV1

IMPORTING

MSG_TEXT = mess_text

EXCEPTIONS

FUNCTION_NOT_COMPLETED = 1

MESSAGE_NOT_FOUND = 2

OTHERS = 3

APPEND the text and other details into an internal table and display it.

ENDLOOP.

Happy Coding

Former Member
0 Kudos

Thanx to all who replied to my thread..

But my requirment is to transfer all the errors to BDCMSGCOLL

and using FORMAT_MESAGE or BAPI_message_gedetail will have to display.

Kindly help

0 Kudos

Hi,

Have a look at the following code snippet for a detailed usage of FORMAT_MESSAGE Function Module..



 LOOP AT MSG_LST.
    CONCATENATE MSG_LST-MSGTY MSG_LST-MSGNO '(' MSG_LST-MSGID ')'
                INTO MSG_TEXT.
    WRITE: / MSG_TEXT      COLOR COL_NORMAL NO-GAP.

    CALL FUNCTION 'FORMAT_MESSAGE'
         EXPORTING
              ID        = MSG_LST-MSGID
              LANG      = SY-LANGU
              NO        = MSG_LST-MSGNO
              V1        = MSG_LST-MSGV1
              V2        = MSG_LST-MSGV2
              V3        = MSG_LST-MSGV3
              V4        = MSG_LST-MSGV4
         IMPORTING
              MSG       = MSG_TEXT
         EXCEPTIONS
              NOT_FOUND = 01.
    WRITE: AT 12(68) MSG_TEXT COLOR COL_NORMAL.
    G_MSG_LST = MSG_LST. HIDE G_MSG_LST.
  ENDLOOP.

Hope this will help.

Thanks,

Samantak.