Application Development and Automation 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: 
Read only

hi

Former Member
0 Likes
495

hi all,

pls help me how to handle error handling in session and call transaction method?

hi all,

pls help me how to handle error handling in session and call transaction method?

3 REPLIES 3
Read only

naimesh_patel
Active Contributor
0 Likes
476

For session you can use the Session Log.

For the call transaction you can use the MESSAGES INTO MESS_TAB.

CALL TRANSACTION 'MM01' USING BDCDATA MESSAGES INTO MESS_TAB.

READ TABLE MESS_tAB WITH MSGID = 'XX'  " << MESSAGE ID FOR SUCCFUL GENERATED MESSAGE
MSGNR = '123'.  " << NUMBER
IF SY-SUBRC = 0.
* DOCUMENT WAS CREATED SUCCESSFULLY
ELSE.
* ERROR 
ENDIF.

Regards,

Naimesh Patel

Read only

Former Member
0 Likes
476

Hi,

please check out this eg. code.

****/ data declaration
DATA : IT_T100 LIKE T100 OCCURS 0 WITH HEADER LINE.
DATA : BEGIN OF IMSG  OCCURS 0.
        INCLUDE STRUCTURE  BDCMSGCOLL.
DATA : END OF IMSG .

DATA : PTF_FILENAME TYPE STRING,
       U_MODE(1),
       L_MSTRING TYPE STRING.

****/ calling transaction with messages.
    CALL TRANSACTION  'MD61' USING  BDCTAB
                              MODE  U_MODE
                            UPDATE  C_UPDATE
                          MESSAGES  INTO IMSG.
    PERFORM ALL_MESSAGES .

*****/ form of above perform...
*&---------------------------------------------------------------------*
*&      Form  ALL_MESSAGES
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM ALL_MESSAGES .
  LOOP AT IMSG.
    SELECT SINGLE * FROM T100 INTO IT_T100
                             WHERE SPRSL = IMSG-MSGSPRA
                               AND ARBGB = IMSG-MSGID
                               AND MSGNR = IMSG-MSGNR.
    IF SY-SUBRC IS INITIAL.
      L_MSTRING = IT_T100-TEXT.
      IF L_MSTRING CS '&1'.
        REPLACE '&1' WITH IMSG-MSGV1 INTO L_MSTRING.
        REPLACE '&2' WITH IMSG-MSGV2 INTO L_MSTRING.
        REPLACE '&3' WITH IMSG-MSGV3 INTO L_MSTRING.
        REPLACE '&4' WITH IMSG-MSGV4 INTO L_MSTRING.
      ELSE.
        REPLACE '&' WITH IMSG-MSGV1 INTO L_MSTRING.
        REPLACE '&' WITH IMSG-MSGV2 INTO L_MSTRING.
        REPLACE '&' WITH IMSG-MSGV3 INTO L_MSTRING.
        REPLACE '&' WITH IMSG-MSGV4 INTO L_MSTRING.
      ENDIF.
      CONDENSE L_MSTRING.
      WRITE : /5 IMSG-MSGTYP,  L_MSTRING .
    ELSE.
      WRITE : /5 IMSG.
    ENDIF.
  ENDLOOP.
ENDFORM.                    " ALL_MESSAGES

This code will help you to handle the messages/errors...

rewards Points.

Cheers

SAGUN DESAI...

Read only

Former Member
0 Likes
476

Hi Lakshmi,

In session method the process log is automatically created in sm35, when we process the session. Analyse the log see the transaction what are all have errors. correct those and process the session again.

In call transaction method we have to explicitly handle the errors. for error handling declare an internal table it_messages like bdcmsgcoll.use the extension messages in to it_messages in the call transaction. The call transaction statement will return sy-subrc. If sy-subrc <> 0, then that transaction is errored transaction. After the call transaction check the sy-subrc. If sy-subrc <> 0. call function format_message. This function is called to store the message given by system and to display it along with the record. Append it to the internal table. display the record and message.