‎2006 Jun 01 3:19 PM
Hi Friends,
What is the most effective way of capturing error messages when i run a BDC program using call transaction. if i use bdcmsgcoll strcuture, capture all the errors when i run the program. please let me know.
regards,
Sharan
‎2006 Jun 02 3:47 PM
Hello Sharan,
Once you get the error messages in <b>BDCMSGCOLL</b> after the Call Transaction is complete use the Function module
<b>BAPI_MESSAGE_GETDETAIL</b> to get the detailed error messages. Refer to the table <b>T100</b> and <b>BDCMSGCOLL</b> for exporting parameters.
Regards,
Arun Sambargi.
‎2006 Jun 01 3:22 PM
Hi,
u can go ahead with using BDCMSGCOLL for messages in call transaction.
regards,
Nagaraj
‎2006 Jun 01 3:22 PM
if you are using the CALL TRANSACTION you can use the BDCMSGCOLL structure.
and you can use FORMAT_MESSAGE function module to get the messagges
write the messages
‎2006 Jun 01 3:22 PM
hi
use format_mesasge
u can capture errors by the type also by
loop at it_mesage where msgtyp = 'E' or 'A' or 'I' or 'S'
..
..
..
endloop.
‎2006 Jun 01 3:23 PM
Hi ,
Use bdcmsgcoll to record all messages in
call transaction.
Regards
Amole
‎2006 Jun 01 3:23 PM
YOu have to use the messages into it_messages addition for the call transaction statement.
call transaction <TCODE> using bdcdata options from x_options messages into i_return.
loop at i_return.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
ID = i_return-id
LANG = sy-langu
NO = i_return-number
V1 = i_return-MESSAGE_V1
V2 = i_return-MESSAGE_V2
V3 = i_return-MESSAGE_V3
V4 = i_return-MESSAGE_V4
IMPORTING
MSG = l_message
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2
.
check sy-subrc = 0.
write: / l_message.
endloop.
REgards,
ravi
‎2006 Jun 01 3:25 PM
hi sharan,
CALL TRANSACTION <tcode> USING it_bdcdata MODE 'A' into it_messages.
WRITE:/ sy-subrc.
perform format_messages.
CLEAR it_bdcdata.
REFRESH it_bdcdata.
ENDLOOP.
ENDFORM. " POPULATE_DATA
--> p1 text
<-- p2 text
----
FORM format_messages .
DATA: l_msg(100).
LOOP AT it_messages.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
id = it_messages-msgid
lang = sy-langu
no = it_messages-msgnr
v1 = it_messages-msgv1
v2 = it_messages-msgv2
v3 = it_messages-msgv3
v4 = it_messages-msgv4
IMPORTING
msg = l_msg
EXCEPTIONS
not_found = 1
OTHERS = 2.
WRITE:/ l_msg.
ENDLOOP.
ENDFORM. " FORMAT_MESSAGES
‎2006 Jun 01 3:26 PM
Hi,
use an internal table(itab) like BDCMSGCOLL and then
Read table itab with key msgtyp = 'E'.
if sy-subrc eq 0.
call function FORMAT_MESSAGE.
pass the data to it ...
‎2006 Jun 01 3:26 PM
Hi sharan,
The BDCMSGCOLL does not have the messages text. It has only the message type, number and message parameters.
You have to read the message text. (recall that the database table T100 stores all the messages.)
There are more than one method of doing this.
Following is the psuedocode for one of the methods.
LOOP for the internal table IT1 which has data value from flat file.
call transcation using....
if SY-SUBRC <> 0.
Read the dictionary table T100 FOR ALL ENTRIES in BDCMSGCOLL.
(also use the condition T100-SPRAS = SY-LANGU (the log on language. This is because you need only the message texts in English if the user is logged in English language)
IF message type is E , then, transfer the contents of this particular error record to file x. (TRANSFER......)
( Ignore all other messages. Only consider type 'E' messages. Ignore other types of messages.)
(You can also store the message text from T100 and the error record in another internal table IT2)
.....
....
ENDLOOP.
Please note that the client might ask you for a file of records which could not be uploaded.
Give him the file created in the above psuedocode. (most often you will have to do this).
Otherwise just display the error messages and the error records in the internal table IT2 in the form of a list.
Thats it.
Alternatively,
Instead of
" Read the dictionary table T100 FOR ALL ENTRIES in BDCMSGCOLL."
you can use the function module
WRITE_MESSAGES to read the messages.
Please refer to the function module for the list of parameters.
Also refer FORMAT_MESSAGES function module.
Award if helpful.
regards,
keerthi.
‎2006 Jun 01 3:30 PM
Hi,
The answer is in your question itself. To use BDCMSGCOLL is the best way to handle errors in Call Transaction method. For message text use FORMAT_MESSAGE function Module.
Sreedhar
‎2006 Jun 01 3:42 PM
Hai Sharan
Check the following Code for Error Tracking
report Z_CALLTRANS_VENDOR_01
no standard page heading line-size 255.
Generated data section with specific formatting - DO NOT CHANGE ***
data: begin of it_lfa1 occurs 0,
KTOKK like lfa1-ktokk,
NAME1 like lfa1-name1,
SORTL like lfa1-sortl,
LAND1 like lfa1-land1,
end of it_lfa1.
End generated data section ***
data : it_bdc like bdcdata occurs 0 with header line.
*DATA: IT_MESSAGES TYPE TABLE OF BDCMSGCOLL WITH HEADER LINE.
*DATA: LV_MESSAGE(255).
data : it_messages like bdcmsgcoll occurs 0 with header line.
data : V_message(255).
data : V_flag.
data : V_datum1 type sy-datum.
data : begin of it_mesg occurs 0,
message(100),
end of it_mesg.
*V_datum1 = sy-datum-1.
parameters : P_Sess like APQI-GROUPID.
start-of-selection.
perform Get_data.
*perform open_group.
loop at it_lfa1.
perform bdc_dynpro using 'SAPMF02K' '0100'.
perform bdc_field using 'BDC_CURSOR'
'RF02K-KTOKK'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'RF02K-KTOKK'
it_lfa1-KTOKK.
perform bdc_dynpro using 'SAPMF02K' '0110'.
perform bdc_field using 'BDC_CURSOR'
'LFA1-LAND1'.
perform bdc_field using 'BDC_OKCODE'
'=UPDA'.
perform bdc_field using 'LFA1-NAME1'
it_lfa1-name1.
perform bdc_field using 'LFA1-SORTL'
it_lfa1-sortl.
perform bdc_field using 'LFA1-LAND1'
it_lfa1-land1.
call transaction 'XK01' using it_bdc
mode 'N'
update 'S'
messages into it_messages.
if sy-subrc <> 0.
if V_flag <> 'X'.
perform open_group.
V_flag = 'X'.
endif.
perform bdc_transaction. "using 'XK01'.
endif.
perform format_messages.
refresh : it_bdc,it_messages.
.
endloop.
if V_flag = 'X'.
perform close_group.
endif.
&----
*& Form Get_data
&----
text
----
--> p1 text
<-- p2 text
----
FORM Get_data .
CALL FUNCTION 'UPLOAD'
EXPORTING
FILENAME = 'C:\srinu_vendor.txt'
FILETYPE = 'DAT'
TABLES
DATA_TAB = it_lfa1
EXCEPTIONS
CONVERSION_ERROR = 1
INVALID_TABLE_WIDTH = 2
INVALID_TYPE = 3
NO_BATCH = 4
UNKNOWN_ERROR = 5
GUI_REFUSE_FILETRANSFER = 6
OTHERS = 7
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " Get_data
&----
*& Form bdc_dynpro
&----
text
----
-->P_0061 text
-->P_0062 text
----
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR it_BDC.
it_BDC-PROGRAM = PROGRAM.
it_BDC-DYNPRO = DYNPRO.
it_BDC-DYNBEGIN = 'X'.
APPEND it_BDC.
ENDFORM.
----
Insert field *
----
FORM BDC_FIELD USING FNAM FVAL.
CLEAR it_BDC.
it_BDC-FNAM = FNAM.
it_BDC-FVAL = FVAL.
APPEND it_BDC.
ENDFORM.
&----
*& Form format_messages
&----
text
----
--> p1 text
<-- p2 text
----
FORM format_messages .
loop at it_messages.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
ID = it_messages-MSGID
LANG = 'EN'
NO = it_messages-MSGNR
V1 = it_messages-MSGV1
V2 = it_messages-MSGV2
V3 = it_messages-MSGV3
V4 = it_messages-MSGV4
IMPORTING
MSG = V_message
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.
write : / V_message.
clear : V_message.
endloop.
ENDFORM. " format_messages
&----
*& Form open_group
&----
text
----
--> p1 text
<-- p2 text
----
FORM open_group .
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
CLIENT = SY-MANDT
GROUP = P_Sess
HOLDDATE = V_datum1
KEEP = 'X'
USER = SY-UNAME
.
IF SY-SUBRC = 0.
write : / 'Session Creating wit Name : ',P_Sess.
ENDIF.
ENDFORM. " open_group
&----
*& Form close_group
&----
text
----
--> p1 text
<-- p2 text
----
FORM close_group .
CALL FUNCTION 'BDC_CLOSE_GROUP'.
ENDFORM. " close_group
&----
*& Form bdc_transaction
&----
text
----
-->P_0132 text
----
FORM bdc_transaction. "USING VALUE(P_0132).
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = 'XK01'
POST_LOCAL = NOVBLOCAL
PRINTING = NOPRINT
SIMUBATCH = ' '
CTUPARAMS = ' '
TABLES
DYNPROTAB = it_bdc
EXCEPTIONS
INTERNAL_ERROR = 1
NOT_OPEN = 2
QUEUE_ERROR = 3
TCODE_INVALID = 4
PRINTING_INVALID = 5
POSTING_INVALID = 6
OTHERS = 7
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " bdc_transaction
Thanks & regards
Sreenivasulu P
‎2006 Jun 01 3:59 PM
HI,
You need to prepare one internal table of type BDCMSGCALL. And pass this internal table to MESSAGE_TEXT_BUILD then it automatically converts the message into readable form.
Cheers,
Bujji
‎2006 Jun 02 3:47 PM
Hello Sharan,
Once you get the error messages in <b>BDCMSGCOLL</b> after the Call Transaction is complete use the Function module
<b>BAPI_MESSAGE_GETDETAIL</b> to get the detailed error messages. Refer to the table <b>T100</b> and <b>BDCMSGCOLL</b> for exporting parameters.
Regards,
Arun Sambargi.