Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

BDC error handling

Former Member
0 Likes
2,390

Hi EXPERTS,

I have a requirement in BDC.I have read five files from application server and upload it

using call transaction method.while uploading if there is any error i have record the error

description along with the file name and record that generated error and send a mail

to a particular id.I don't know how to create error log details with the file name and record that generated error.

Please Help.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,265

Hi noufal,

For your requirement i'll explain you with a small example.

Say i'm having 2 files with names f1 and f2.

The contents of the files must have the file name too in each record.

f1

-------------------------------

field 1  filed 2 field 3 field 4

-------------------------------

f1           a      b      c

f1           b      c      a

f1           d      a      b

f2

-------------------------------

field1  filed2 field3 field 4

-------------------------------

f2           a      b      c

f2           c      c      c

f2           d      d      d

you must have the contents of both files in one internal table

once after you will loop the table and write the call transaction.

after the call transaction statement check for the sy-subrc value and write the code as below.

if sy-subrc <> 0.

then there might be problem with recent call transaction statement.

move the corresponding record to dummy inernal table and also record the error message from the message table. for the file name, see the current record in the loop the first field is having the file name.

endif.

14 REPLIES 14
Read only

Former Member
0 Likes
2,265

If you are using BDC to perform your transactions, you get the messages occured during transaction in messtab. Please refer to call transaction SAP help for more details.

Using CALL TRANSACTION USING for Data Transfer (SAP Library - Background Processing)

Read only

Former Member
0 Likes
2,265

Hi noufal.

How say chinmay you can have details of log in table  messtab.

But if you need create register of log and save it in system. Is necessary use the utility of transaction slg1.

Check this url:
http://help.sap.com/saphelp_nw70/helpdata/en/2a/fa0216493111d182b70000e829fbfe/frameset.htm

Read only

Former Member
0 Likes
2,265

Hi guys,

Thanks for your reply..I got forgot to mention that im using FCHR T-code to upload date using BDC.If a particular check number got any error then we cannot upload data.So i want find out which check number got error...

Read only

0 Likes
2,265

after getting your messges in bdcmsgcoll structure . you can get which record is got error .so pass that record and message to display by write or ALV grid.

(call transaction FCHR using BDCDATA mode 'A' update 'S' messages into messtab.

so in messtab you will have your error's.

if message type is E that message is error message.)

this will help you to find out which line has got error.

hope this helps,

Vinoth

Read only

0 Likes
2,265

Hi vinoth,

  i tried that..i didnt get the record no (check number)

Read only

0 Likes
2,265

the check no is generating ffrom FCHR means it will be in status message message type 'S'.

Read only

0 Likes
2,265

hi vinoth...

   when the record is saved successfully the transaction fchr generates a report automatically.In that report it displays the status message with the document number.That message is not capturing in BDCMSGCOLL internal table...........

Regards,

Noufal p

Read only

Former Member
0 Likes
2,266

Hi noufal,

For your requirement i'll explain you with a small example.

Say i'm having 2 files with names f1 and f2.

The contents of the files must have the file name too in each record.

f1

-------------------------------

field 1  filed 2 field 3 field 4

-------------------------------

f1           a      b      c

f1           b      c      a

f1           d      a      b

f2

-------------------------------

field1  filed2 field3 field 4

-------------------------------

f2           a      b      c

f2           c      c      c

f2           d      d      d

you must have the contents of both files in one internal table

once after you will loop the table and write the call transaction.

after the call transaction statement check for the sy-subrc value and write the code as below.

if sy-subrc <> 0.

then there might be problem with recent call transaction statement.

move the corresponding record to dummy inernal table and also record the error message from the message table. for the file name, see the current record in the loop the first field is having the file name.

endif.

Read only

0 Likes
2,265

Hi sudheer,

Thanks for you reply..im getting file name...But How to get the error record

Read only

0 Likes
2,265

hi noufal,

    see the logic below...

loop at itemtab.

CALL TRANSACTION 'TFCA' USING BDCDATA

MODE 'A'

UPDATE 'S'.

MESSAGES INTO MESSTAB.

IF SY-SUBRC <> 0.

<Error_handling>.

read table messtab into wa_messtab index 1.

append wa_messtab to dummy_messtab.

ENDIF.

endloop.

here you will collect all error messages into dummy internal table.

move records into a flatfile by calling method

CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD.

.

Read only

0 Likes
2,265

in the above logic along with the error message if you want the record too then take another dummy table which will holds the un processed records of item tab.

say dummy_itemtab.

loop at itemtab into wa_itemtab.

CALL TRANSACTION 'TFCA' USING BDCDATA

MODE 'A'

UPDATE 'S'.

MESSAGES INTO MESSTAB.

IF SY-SUBRC <> 0.

<Error_handling>.

read table messtab into wa_messtab index 1.

append wa_messtab to dummy_messtab.               "for error messages

append wa_itemtab to dummy_itemtab.                   "for error record

ENDIF.

endloop.

off-course the dummy_messtab contains the error messages which cant understand, for that call the FM FORMAT_MESSAGE

Message was edited by: S M SUDHEER KUMAR CHUNDURU

Read only

0 Likes
2,265

hi SUDHEER,

your solution was really helpful.Now im gettting another issue.

  when the record is saved successfully the transaction fchr generates a report automatically.In that report it displays the status message with the document number.That message is not capturing in BDCMSGCOLL internal table...........

Regards,

Noufal p


Read only

0 Likes
2,265

Hi noufal,

     I didn't understood whether you want to capture success/failure messages of call transaction statement or else you want to capture the messages of a report which was internally called by your transaction.

In-fact the BDCMSGCOLL will have only the messages regarding the transaction but not the internal reports. I think it will pick the message only after completion of your transaction. In the case if you want the report message to be captured you need to do some implicit enhancements at report level.

Simply EXPORT the message into some memory id and in your report fetch those messages from that memory id using IMPORT statement.

Hope you will understand....

Regards,

Sudheer Kumar.

Read only

reachdebopriya
Active Participant
0 Likes
2,265

Hi

CALL TRANSACTION 'TFCA' USING BDCDATA

MODE 'A'

UPDATE 'S'.

MESSAGES INTO MESSTAB.

IF SY-SUBRC <> 0.

*-- <Error_handling>.

Loop at messtab into w_messtab.

Call Function Module 'FORMAT_MESSAGE' to format the message.

pass id, lang, no, v1,v2,v3,v4 of w_messtab.

it will fetch the message and append in final_messtab.

ENDLOOP.

Now you format the error log from internal table final_messtab and forward it as mail.

Regards,

Debopriya Ghosh