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

Handling errors in BDC/ Call transaction

Former Member
0 Likes
704

Hi,

I have an excel sheet to upload using BDC.. I am validating the contents of the excel sheet before calling the BDC session and populating the errors. Now after the call transaction statement the BDCMSGCOll is getting populated... I am also collecting all these errors in the error tab...

In the excel sheet the 3 & 4 row are having transaction errors for eg. "This entry already exits"... or Specify correct date... But in my output the 4th record is getting populated twice... I want the 3rd & the 4th record with correct reasons in the error tab. Please suggest

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
670

You can do something like this :

gt_messtab is the error table returned by CALL TRANSACTION.

LOOP AT gt_messtab INTO ls_messtab.

SELECT SINGLE text INTO ws_text FROM t100

WHERE sprsl = ls_messtab-msgspra

AND arbgb = ls_messtab-msgid

AND msgnr = ls_messtab-msgnr.

IF sy-subrc = 0.

lv_mstring = ws_text.

IF lv_mstring CS '&1'.

REPLACE '&1' WITH ls_messtab-msgv1 INTO lv_mstring.

REPLACE '&2' WITH ls_messtab-msgv2 INTO lv_mstring.

REPLACE '&3' WITH ls_messtab-msgv3 INTO lv_mstring.

REPLACE '&4' WITH ls_messtab-msgv4 INTO lv_mstring.

ELSE.

REPLACE '&' WITH ls_messtab-msgv1 INTO lv_mstring.

REPLACE '&' WITH ls_messtab-msgv2 INTO lv_mstring.

REPLACE '&' WITH ls_messtab-msgv3 INTO lv_mstring.

REPLACE '&' WITH ls_messtab-msgv4 INTO lv_mstring.

ENDIF.

CONDENSE lv_mstring.

ENDIF.

IF ls_messtab-msgtyp = 'E'.

lv_subrc = 1.

gv_error = ls_messtab.

ENDIF.

ENDLOOP.

Hi,

I have an excel sheet to upload using BDC.. I am validating the contents of the excel sheet before calling the BDC session and populating the errors. Now after the call transaction statement the BDCMSGCOll is getting populated... I am also collecting all these errors in the error tab...

In the excel sheet the 3 & 4 row are having transaction errors for eg. "This entry already exits"... or Specify correct date... But in my output the 4th record is getting populated twice... I want the 3rd & the 4th record with correct reasons in the error tab. Please suggest

4 REPLIES 4
Read only

Former Member
0 Likes
670

Hello,

After collecting the errors in BDCMSGCOLL.

Try to check this records with the updated records in the database table and delete the unwanted ones.

Chekc and let me know.

Regards

Read only

Former Member
0 Likes
671

You can do something like this :

gt_messtab is the error table returned by CALL TRANSACTION.

LOOP AT gt_messtab INTO ls_messtab.

SELECT SINGLE text INTO ws_text FROM t100

WHERE sprsl = ls_messtab-msgspra

AND arbgb = ls_messtab-msgid

AND msgnr = ls_messtab-msgnr.

IF sy-subrc = 0.

lv_mstring = ws_text.

IF lv_mstring CS '&1'.

REPLACE '&1' WITH ls_messtab-msgv1 INTO lv_mstring.

REPLACE '&2' WITH ls_messtab-msgv2 INTO lv_mstring.

REPLACE '&3' WITH ls_messtab-msgv3 INTO lv_mstring.

REPLACE '&4' WITH ls_messtab-msgv4 INTO lv_mstring.

ELSE.

REPLACE '&' WITH ls_messtab-msgv1 INTO lv_mstring.

REPLACE '&' WITH ls_messtab-msgv2 INTO lv_mstring.

REPLACE '&' WITH ls_messtab-msgv3 INTO lv_mstring.

REPLACE '&' WITH ls_messtab-msgv4 INTO lv_mstring.

ENDIF.

CONDENSE lv_mstring.

ENDIF.

IF ls_messtab-msgtyp = 'E'.

lv_subrc = 1.

gv_error = ls_messtab.

ENDIF.

ENDLOOP.

Read only

0 Likes
670

Hi Ravi,

I am writing

LOOP AT MESSTAB WHERE MSGTYP = 'E'.

CALL FUNCTION 'MESSAGE_TEXT_BUILD'

EXPORTING

MSGID = MESSTAB-MSGID

MSGNR = MESSTAB-MSGNR

MSGV1 = MESSTAB-MSGV1

MSGV2 = MESSTAB-MSGV2

MSGV3 = MESSTAB-MSGV3

MSGV4 = MESSTAB-MSGV4

IMPORTING

MESSAGE_TEXT_OUTPUT = W_TEXTOUT.

ENDLOOP.

  • Build error table ready for output

If sy-subrc = 0.

MOVE : v_ctr to t_error-ctr,

T_INPUT-KURST TO T_ERROR-KURST,

T_INPUT-GDATU TO T_ERROR-GDATU,

T_INPUT-FCURR TO T_ERROR-FCURR,

T_INPUT-TCURR TO T_ERROR-TCURR,

T_INPUT-INUKURS TO T_ERROR-INUKURS,

T_INPUT-DUKURS TO T_ERROR-DUKURS,

W_TEXTOUT TO T_ERROR-MSG.

APPEND T_ERROR.

CLEAR: T_ERROR.

endif.

  • Perform to close the BDC session.

PERFORM CLOSE_GROUP.

Read only

0 Likes
670

It will be better if you can select from T100 table as you get the exact text.

You can have a look at the code i send to you.