2007 Sep 12 5:40 AM
Hi Gurus,
I have scenario here where in I have written a BDC program for transaction FV50L to park an FI document and then later made it is a function module.In this function module one of the TABLES parameter is BAPIRET2 to return error messages to the calling program..
Actually this FM is RFC enabled so that it can be called from non sap system...
Now i am not sure how to transfer the error messages from the BDC program to this BAPIRET2 table...
Can any of u gurus provide me detail insight into this how it can be done....code samples will be helpful as i am still in a learning phase of ABAP...
Points will be awarded.
Cheers: Jim
2007 Sep 12 5:53 AM
you need to use BDCMSGCOLL which holds all the messages during a bdc.
But this works only with the 'call transaction syntax'.
2007 Sep 12 5:46 AM
hi Jimmy..
You can do this in case of Call transaction method only..
Sample code:
Using BDCMSGCOLL Structure we have to declare an itab.
DATA : IT_MSG LIKE TABLE OF BDCMSGCOLL .
DATA : V_MSG TYPE STRING .
Then We can catch the messages using:
CALL TRANSACTION 'MK01'
USING IT_BDCDATA
MODE 'N'
MESSAGES INTO IT_MSG. "stores the messages
IF sy-subrc ne 0.
LOOP AT IT_MSG INTO WA_MSG .
**WHERE MSGTYP = 'E' OR MSGTYP = 'A'. "if you want only error messages
CALL FUNCTION 'FORMAT_MESSAGE' "To get the Message text into V_MSG.
IT_BAPIRET2-MSGTYP = IT_MSG-MSGTYP.
IT_BAPIRET2-MSGID = IT_MSG-MSGTYP.
IT_BAPIRET2-MESSAGE = V_MSG.
APPEND IT_BAPIRET2.
CLEAR IT_BAPIRET2.
ENDLOOP.
REWARD IF HELPFUL.
2007 Sep 12 5:49 AM
Hi,
Simply loop over the error message table i_bdcmsgcoll & populate the table bapiret2.
Following are the fields of BDCMSGCOLL
TCODE
DYNAME
DYNUMB
MSGTYP
MSGSPRA
MSGID
MSGNR
MSGV1
MSGV2
MSGV3
MSGV4
ENV
FLDNAME
Following are the fields of BAPIRET2.
TYPE
ID
NUMBER
MESSAGE
LOG_NO
LOG_MSG_NO
MESSAGE_V1
MESSAGE_V2
MESSAGE_V3
MESSAGE_V4
PARAMETER
ROW
FIELD
SYSTEM
Fill the common fields
loop at i_bdcmsgcoll.
move i_bdcmsgcoll-msgtype to bapiret2-type.
move i_bdcmsgcoll-MSGV1 to bapiret2-MESSAGE_V1.
and so on..
append bapiret2.
endloop.
2007 Sep 12 5:53 AM
you need to use BDCMSGCOLL which holds all the messages during a bdc.
But this works only with the 'call transaction syntax'.
2007 Sep 12 6:12 AM
Thanks for the response guys....
i will try this and then let you know...
thanks for ur help....
cheers:
jim
2007 Sep 12 6:26 PM
Hi gurus,
I tried doing this but it is not working...
How will be the mapping between BAPIRET2 and BDCMSGCOLL...I mean when the NDC program is succesfull it will generate a document number for the parked document....i will have to return this document number also in the FM...how can i do that....which field of BDCMSGCOLL will have this doc number...
Please suggest...I have to resolve it by end of the day...
Cheers:
Jim