‎2006 Jan 18 7:00 AM
Hi All,
Can any1 giv me a sample code of how to use the BDCMSGCOLL Internal Table and to capture the errors into it.
Thanks & Regds.
Ramesh.
‎2006 Jan 18 7:04 AM
loop at it_msg where msgtyp = 'E'.
"use format_message FM.
endloop.
‎2006 Jan 18 7:04 AM
loop at it_msg where msgtyp = 'E'.
"use format_message FM.
endloop.
‎2006 Jan 18 7:09 AM
DATA BEGIN OF message OCCURS 10.
INCLUDE STRUCTURE BDCMSGCOLL.
DATA END OF message.
CALL TRANSACTION 'MM01' USING BDCDATA MODE 'N'
MESSAGES INTO MESSage.
loop at it_msg where msgtyp = 'E'.
"use format_message FM.
endloop.
‎2006 Jan 18 7:05 AM
Hi,
Look at the sample code........
*******************
DATA: BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE,
IT_BDCMSGCOLL LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE,
l_errtxt(80) type c.
call transaction 'ZDMR01' using bdcdata
mode w_mode
update 'S'
messages into it_bdcmsgcoll.
if sy-subrc eq 0.
succ_it-pernr = pitab-pernr.
write icon_green_light to succ_it-light.
succ_it-type = text-h05.
succ_it-msg = text-h04.
append succ_it.
else.
succ_it-pernr = pitab-pernr.
write icon_red_light to succ_it-light.
succ_it-type = text-h05.
loop at it_bdcmsgcoll .
message id it_bdcmsgcoll-msgid type it_bdcmsgcoll-msgtyp
number it_bdcmsgcoll-msgnr
into l_errtxt with it_bdcmsgcoll-msgv1 it_bdcmsgcoll-msgv2
it_bdcmsgcoll-msgv3 it_bdcmsgcoll-msgv4.
succ_it-msg = l_errtxt.
succ_it-msgtyp = it_bdcmsgcoll-msgtyp.
append succ_it.
endloop.
endif.
endif.
Here in the call trans all the msh will be into internal table.
And later we r processing it and capturing the error log.
Thanks.
If this helps you reward with points.
‎2006 Jan 18 7:06 AM
Hi,
so pls. analyze the error message with...
DATA: itab LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE.
CALL TRANSACTION tcode USING bdcdata MODE mod MESSAGES INTO itab.
*get text to bdc-message
if sy-subrc <> 0.
...
LOOP AT itab WHERE msgtyp = 'E'.
*fill errtab
CLEAR errtab.
MOVE p_kunnr TO errtab-kunnr.
MOVE p_bukrs TO errtab-bukrs.
MOVE p_kde TO errtab-kde.
MOVE p_bkz TO errtab-bkz.
*
MOVE itab-msgnr TO errtab-msgnr.
MOVE itab-msgid TO errtab-msgid.
MOVE itab-fldname TO errtab-fieldn.
*fill protocol
CLEAR prot.
MOVE-CORRESPONDING itab TO prot.
MOVE-CORRESPONDING errtab TO prot.
MOVE itab-fldname TO prot-feld.
SELECT SINGLE text FROM t100 INTO prot-text
WHERE sprsl = sy-langu
AND arbgb = prot-msgid
AND msgnr = prot-msgnr.
CALL FUNCTION 'TB_MESSAGE_BUILD_TEXT'
EXPORTING
langu = sy-langu
msgid = itab-msgid
msgno = prot-msgnr
msgv1 = prot-msgv1
msgv2 = prot-msgv2
msgv3 = prot-msgv3
msgv4 = prot-msgv4
IMPORTING
text = prot-text.
APPEND prot.
ENDLOOP.
...
endif.Andreas
‎2006 Jan 18 7:15 AM
Hi,
Here is the sample code.Kindly reward points by clikcing the star on the left of reply,if it helps.
DATA : T_BDCDATA TYPE BDCDATA OCCURS 0 WITH HEADER LINE,
T_MESSTAB TYPE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF T_ERROR OCCURS 0,
PERNR TYPE P0000-PERNR,"prog. specific
SPACE(2) TYPE C,
W_TYPE(4) TYPE C,
AMOUNT(15) TYPE C,,"prog. specific
ERROR(73) TYPE C,
END OF T_ERROR.
REFRESH T_MESSTAB.CLEAR T_MESSTAB.
REFRESH T_BDCDATA.CLEAR T_BDCDATA.
...do coding here to perform BDC.
CALL TRANSACTION TCODE USING T_BDCDATA MODE 'N'
UPDATE 'L'
MESSAGES INTO T_MESSTAB.
IF SY-SUBRC <> 0.
PERFORM SUB_MSGTAB.
ENDIF.
FORM SUB_MSGTAB .
DATA: W_TEXTOUT LIKE T100-TEXT.
LOOP AT T_MESSTAB.
CLEAR T_ERROR.
IF T_MESSTAB-MSGTYP = 'E'.
CALL FUNCTION 'MESSAGE_TEXT_BUILD'
EXPORTING
MSGID = T_MESSTAB-MSGID
MSGNR = T_MESSTAB-MSGNR
MSGV1 = T_MESSTAB-MSGV1
MSGV2 = T_MESSTAB-MSGV2
MSGV3 = T_MESSTAB-MSGV3
MSGV4 = T_MESSTAB-MSGV4
IMPORTING
MESSAGE_TEXT_OUTPUT = W_TEXTOUT.
IF SY-SUBRC = 0.
"prog. specific
MOVE : T_MAIN-PERNR TO T_ERROR-PERNR,
T_MAIN-AMOUNT TO T_ERROR-AMOUNT,
T_MAIN-W_TYPE TO T_ERROR-W_TYPE,
W_TEXTOUT TO T_ERROR-ERROR.
APPEND T_ERROR.
CLEAR T_ERROR.
DELETE T_MAIN.
DELETE T_MESSTAB.
G_ERRCOUNT = G_ERRCOUNT + 1.
EXIT.
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM. " SUB_MSGTAB