2014 Feb 05 7:12 AM
Dear Experts,
I create Function Module for a DBC.
From My program I have called it.
CALL FUNCTION 'ZFM_FB05_BDC_CLEARING'
EXPORTING
i_bldat = sy-datum "s_date
i_budat = p_budat
i_waers = 'BDT'
i_newbs = '40'
i_newko = v_hkont
i_text = p_text
i_bukrs = '1000' "s_bukrs
i_prctr = v_prctr
TABLES
lt_bdcdata = it_belnr
lt_bdcdata2 = it_gl_amt.
Now I want to get the success or unsuccess message.
How it possible.
Regards,
Mahfuz
2014 Feb 05 7:53 AM
Hi Rahman,
check this sample code. It may be help you.
DATA: I_BDC TYPE STANDARD TABLE OF BDCDATA ,
W_BDC TYPE BDCDATA,
I_MSG TYPE STANDARD TABLE OF BDCMSGCOLL,
W_MSG TYPE BDCMSGCOLL.
IF I_BDC IS NOT INITIAL.
*&-----Call Transaction F-32
CALL TRANSACTION C_TCODE USING I_BDC
OPTIONS FROM V_OPTION MESSAGES INTO I_MSG.
ENDIF.
****************************************************
DATA : LV_MSG TYPE STRING.
LOOP AT I_MSG INTO W_MSG.
CLEAR LV_MSG.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
ID = W_MSG-MSGID
LANG = 'EN'
NO = W_MSG-MSGNR
V1 = W_MSG-MSGV1
V2 = W_MSG-MSGV2
V3 = W_MSG-MSGV3
V4 = W_MSG-MSGV4
IMPORTING
MSG = LV_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.
CLEAR RETURN.
RETURN-TYPE = W_MSG-MSGTYP.
RETURN-ID = W_MSG-MSGID.
RETURN-NUMBER = W_MSG-MSGNR.
CONDENSE W_MSG-MSGV1 NO-GAPS.
CONDENSE W_MSG-MSGV2 NO-GAPS.
CONDENSE W_MSG-MSGV3 NO-GAPS.
CONDENSE W_MSG-MSGV4 NO-GAPS.
RETURN-MESSAGE_V1 = W_MSG-MSGV1.
RETURN-MESSAGE_V2 = W_MSG-MSGV2.
RETURN-MESSAGE_V3 = W_MSG-MSGV3.
RETURN-MESSAGE_V4 = W_MSG-MSGV4.
RETURN-MESSAGE = LV_MSG.
APPEND RETURN.
ENDLOOP.
CLEAR: I_BDC.
Any issue write up.
Thanks,
Ranjit Kumar.
2014 Feb 05 7:15 AM
Hi Mohammad,
To know whether FM successfully executed or not, SY-SUBRC value will helpful. But whether particular transaction has run successful or not, that should be handled in your function module source code and that depends on your logic.
Regards,
Vijay
2014 Feb 05 7:21 AM
Thanks.
Yes it is for particular Transaction. T-code FB05.
CALL TRANSACTION 'FB05' USING bdcdata
MODE 'A'
UPDATE 'S'
MESSAGES INTO messtab.
Regards,
Mahfuz
2014 Feb 05 7:25 AM
Hi,
In messtab, you will get all the messages.
Pass this message class, message number and message type into T100 table and display appropriate messages.
Arivazhagan S
2014 Feb 05 7:27 AM
Hi
Loop the MESSTAB and call function module FORMAT_MESSAGE in loop, pass required parameters and get the message.
Regards,
Vijay
2014 Feb 05 7:29 AM
Create one more parameter in the FM , as Log as export parameter. Inside the FM source code, if u r calling a BDC , if the transaction is sucess, in sy-sunrc u will get 0. , if it is zero pass sucess mesaage in the log . u can retrieve the same in the FM in Import parameter.
Hope it useful.
Thanks,
Vijay SR
2014 Feb 05 7:41 AM
Check the messtab contents to decide whether BDC was successful or not
2014 Feb 05 7:53 AM
Hi Rahman,
check this sample code. It may be help you.
DATA: I_BDC TYPE STANDARD TABLE OF BDCDATA ,
W_BDC TYPE BDCDATA,
I_MSG TYPE STANDARD TABLE OF BDCMSGCOLL,
W_MSG TYPE BDCMSGCOLL.
IF I_BDC IS NOT INITIAL.
*&-----Call Transaction F-32
CALL TRANSACTION C_TCODE USING I_BDC
OPTIONS FROM V_OPTION MESSAGES INTO I_MSG.
ENDIF.
****************************************************
DATA : LV_MSG TYPE STRING.
LOOP AT I_MSG INTO W_MSG.
CLEAR LV_MSG.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
ID = W_MSG-MSGID
LANG = 'EN'
NO = W_MSG-MSGNR
V1 = W_MSG-MSGV1
V2 = W_MSG-MSGV2
V3 = W_MSG-MSGV3
V4 = W_MSG-MSGV4
IMPORTING
MSG = LV_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.
CLEAR RETURN.
RETURN-TYPE = W_MSG-MSGTYP.
RETURN-ID = W_MSG-MSGID.
RETURN-NUMBER = W_MSG-MSGNR.
CONDENSE W_MSG-MSGV1 NO-GAPS.
CONDENSE W_MSG-MSGV2 NO-GAPS.
CONDENSE W_MSG-MSGV3 NO-GAPS.
CONDENSE W_MSG-MSGV4 NO-GAPS.
RETURN-MESSAGE_V1 = W_MSG-MSGV1.
RETURN-MESSAGE_V2 = W_MSG-MSGV2.
RETURN-MESSAGE_V3 = W_MSG-MSGV3.
RETURN-MESSAGE_V4 = W_MSG-MSGV4.
RETURN-MESSAGE = LV_MSG.
APPEND RETURN.
ENDLOOP.
CLEAR: I_BDC.
Any issue write up.
Thanks,
Ranjit Kumar.
2014 Feb 05 8:47 AM
Hi Rahman ,
Simply have a tables parameter of type MESSTAB and pass the messtab from your FM to report (or wherever you are calling the FM) , just like you are passing BDC data to FM .
Loop at MESSTAB and check for msgtype .
USe function module 'FORMAT_MESSAGE' as shown :
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
ID = ls_MSG-MSGID
LANG = 'EN'
NO = LS_MSG-MSGNR
V1 = ls_MSG-MSGV1
V2 = ls_MSG-MSGV2
V3 = ls_MSG-MSGV3
V4 = ls_MSG-MSGV4
IMPORTING
MSG = LV_MSG
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
ENDIF.
Display the variable LV_MSG .
Any doubt ??
Regards .
Praveen
2014 Feb 05 8:57 AM
Hi,
IN side the fm trap your bdc messages in internal table suppose ITAB and return table ITAB.
after the execution of Fm read table ITAB on behalf of E or S msgtype.
Regards
Neeraj