‎2006 Nov 30 4:38 PM
Hi progmr's,
I m unable to understand what exactly happening in BDC call transaction error handling.
As we say that we create a structure similar to structure BDCMSGCOLL and populate the messges into that stucture.and loop at that structure and see the required errors.
So frnds can anyone tell me what is use of format_message function module.
what is the use of that function module.
plz clarify my doubt .
regards,
karthik
‎2006 Nov 30 4:47 PM
Hi
What this function module does is take all the components of the error message and combine them to form the full message that you would see on the screen.
please check the following code
call function 'FORMAT_MESSAGE'
exporting
id = wa_messages-msgid
lang = sy-langu
no = wa_messages-msgnr
v1 = wa_messages-msgv1
v2 = wa_messages-msgv2
v3 = wa_messages-msgv3
v4 = wa_messages-msgv4
importing
msg = v_msg
exceptions
not_found = 1
others = 2.
The bdcmsgcoll table would have the components as msgid,msgnr,msgv1,msgv2,msgv3,msgv4.This would be used to combine into a full message
‎2006 Nov 30 4:42 PM
Hi,
FM FORMAT_MESSAGE is used to fill up the text for the message id and no along with the place holders..
Example..
If you have the message "Invalid sold-to party <b>&</b> "
If you pass the message no, message id, msgv1, msgv2, v3 v4..
The FM will return "Invalid sold-to party CUSTOMER ". If the MSGV1 value is CUSTOMER..
Thanks,
Naren
‎2006 Nov 30 4:46 PM
HI Narendran,
Thnk u for ur reply.
U mean to say that we hav to use both bdcmsgcoll structure and format_message function module to handle errors in call transaction method.
can u tell me the steps to do it and what is functionality which is followed by both of them to handle errors.
thnking u again
regards,
karthik
‎2006 Nov 30 4:50 PM
Hi Ravi,
Thnk u for ur reply.
what is place holder and actual values. i m bit confused. If u plz will be more clear than i can get the solution exactly..
regards,
karthik
‎2006 Nov 30 4:44 PM
Karthik,
If you look at the output of CALL TRANSACTION in the BDCMSGCOLL, you will have messages not in a readable format directly as the messages might have place holders and that values for the place holders will be the other fields of the BDCMSGCOLL structure.
FORMAT_MESSAGE will replace those place holders with the actual values and will give you the message in a understandable manner.
Regards,
Ravi
Note - Please mrk all the helpful ansewrs
‎2006 Nov 30 4:47 PM
Hi
What this function module does is take all the components of the error message and combine them to form the full message that you would see on the screen.
please check the following code
call function 'FORMAT_MESSAGE'
exporting
id = wa_messages-msgid
lang = sy-langu
no = wa_messages-msgnr
v1 = wa_messages-msgv1
v2 = wa_messages-msgv2
v3 = wa_messages-msgv3
v4 = wa_messages-msgv4
importing
msg = v_msg
exceptions
not_found = 1
others = 2.
The bdcmsgcoll table would have the components as msgid,msgnr,msgv1,msgv2,msgv3,msgv4.This would be used to combine into a full message
‎2006 Nov 30 4:56 PM
hi Dominic,
Its nice to see ur post , can u just clarify me so when we are using Fn Mod Format_message so here when the user defined structure of type BDCMSGCOLL is used.
i m confused there.
can u just pass on a demo code so that i can understand the exact functionality of both simultaneosly.
regards,
karthik
‎2006 Nov 30 5:10 PM
Hi,
When you use the CALL Transaction you put the error messages into the structure of type bdcmsgcoll
e.g
DATA: i_messages LIKE bdcmsgcoll OCCURS 0.
CALL TRANSACTION tcode USING i_bdcdata
MODE lws_mode
UPDATE lws_update
MESSAGES INTO i_messages.
Here the error and success messages have come into the table i_messages
Now this is not complete if you look at the table i_messages at runtime...
Now to get the complete message you use the FORMAT_MESSAGE.
LOOP AT i_messages INTO wa_messages
WHERE msgtyp EQ 'E' OR
msgtyp EQ 'A'. (This is to get only Error Messages)
call function 'FORMAT_MESSAGE'
exporting
id = wa_messages-msgid
lang = sy-langu
no = wa_messages-msgnr
v1 = wa_messages-msgv1
v2 = wa_messages-msgv2
v3 = wa_messages-msgv3
v4 = wa_messages-msgv4
importing
msg = v_msg
exceptions
not_found = 1
others = 2.
Here v_msg contains the full error message such that you would see on the screen.
wa_error-message = v_msg.
append wa_error to i_error.
Here your table i_error will contain all the error messages which have come
ENDLOOP.
Hope this helps.
‎2006 Nov 30 4:47 PM
hi Karthik,
BDCMSGCOLL is used to trap the error records once those records passed throught the validated code and if those r not satisfied then those come into this file with related message specifying the error..
instead of bdcmsgcoll you can use the format_message also trap the error records in calltransaction method.
these r necessary because as session method, call transaction don't have a log file by default so you have to create the file by your own.
mark the helpful answers
Regards,
Naveen
‎2006 Nov 30 4:51 PM
Hi,
It is not neccessary you have to use the FORMAT_MESSAGE FM..IT is just used to get the message for the message no, id...
To handle errors
-
DATA: T_MESSAGE LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
CALL TRANSACTION 'VA01' USING T_BDCDATA MESSAGES INTO T_MESSAGE.
IF SY-SUBRC <> 0.
There is an error occured in the transaction...
ENDIF.
Check the message table for any error or abort message types.
LOOP AT T_MESSAGE WHERE MSGTYP = 'E' OR MSGTYP = 'A'.
EXIT.
ENDLOOP.
IF SY-SUBRC = 0.
There is an error occured in the transaction...
ENDIF.
Thanks,
Naren
‎2006 Nov 30 5:04 PM
hi ,
So frnds then i can conclued that its not mandatory to use both bdcmsgcoll and format_message in a program to handle error.
But still i didnt get about place holder and actual value concept.
regards,
karthik
‎2006 Nov 30 5:10 PM
When you define a message in SE93, you might define something like this
Purchase Order &1 created.
At runtime, it will be displayed as Purcase Order 500001000 created.
So &1 is the placeholder which will get replaced with a value at runtime.
Please mark all the helpful answers
Regards,
Ravi
‎2006 Nov 30 5:10 PM
will the messages in the call tr. Will be stored in the database?
regards,
karthik
‎2006 Nov 30 5:21 PM
Thnk u all for contributing for my post.
i thnk u all for helping me again.
regards,
karthik