CALL TRANSACTION AND ERROR HANDLING

Question:
Hi All,
How can I handle the errors in my BDC while using Call Transaction method?
I get the messages in Messtab and then can use FUNCTION 'MESSAGE_TEXT_BUILD' to write the messagesm, but I have a few questions in mind:
1. If there is any error in my transaction the message will be captured in my MessTab. but will the next transaction processed in the BDC ? or I will get the error message right after the error has occured?
2. And if the transactions which are without errors are being processed, How can I write the errors messages in the list output after all the transactions are over in my BDC ? Should I write the messages at the end using FUNCTION 'MESSAGE_TEXT_BUILD'?
Please help me understand.
I am
Jessy
Answer:
I tend to call each transaction as a seperate unit rather than building them all into a single BDC call.
I have a table which contains data that I am going to show in a report to the user. One of these fields is a 'result' text string. When the CTR returns I scan the message table for message types A or E. If I find one of these then I build the message and put the message in the text field. If I don't I then find the last 'S' type message in the table, construct the text version of that and put it in the table.
When I report the results I colour the lines accordingly, red for errors, normal for transactions that processed ok.
If you gang transactions up it is possible to sort out the various messages but you would have to know the message number that signals the start of the transaction so that you can associate the data with the appropriate message.
If you are ganging up the same transaction then all following transactions will process with an appropriate result, but obviously if you are using different transactions (for example creating a batch and then moving that batch to a storage bin) that are reliant on the previous transaction then these will fail.
I usually leave SAP to do the validation of the data, but in the case where all transactions have to run or none at all then then data has to be validated up front before any transactions are called.
Lastly, a transaction can fail with no message type E or A appearing in the message tab. This tends to be the case where a record is locked or a lookup such as a material or cost centre cannot be found. In this case sy-subrc generally has a value of 1001 after the call.
Have a look at Docs.Zip /sapfans/repos/docs.zip
in the repository. This has loads of routines for both reporting and the controlling of CTR's including functionalilty that will automatically create a batch if a CTR fails and optionally send mail to a named user.
Regards
R
_________________
Regards
R
Abap KC

SFMDR

Answer:
R!
Is the next transaction processed if a transaction has errors using call transaction method?
Answer:
Yep. AFAIK. You can see this happening in SM35 and I've never come across a CTR that contains many transactions where it stops when a transaction errors although I may be wrong.
R
_________________
Regards
R
Abap KC

SFMDR

Answer:
a slightly different perspective, perhaps....what I do is:
build an internal table (to populate fields of my BDC table).
loop at the internal table.
refresh the bdc table
refresh the message table.
build the bdc table for a single CT
call the transaction (synchronous mode)
examine the return code
if successful (0), write a success message (or write to log file, or both).
if a 'downstream' transaction is required, get any necessary information from messages table, refresh tables and build BDC for next step, call that transaction, etc....
if failed, process the error in the messages table, write a message (or write to log file, etc., save the bdc table to a BDC session for re-processing)
if a 'downstream' transaction is required, cause that part of the program to be skipped or write that data to the bdc session also, and report the situation.
continue the loop with the data for the next transaction(s)...
...and so on...
at end of program.
report results, records in, updates completed, errors passed to BDC, etc.
print the contents of the log file for future reference.
as noted, return codes are critical. Generally, CTs will, like true BDC sessions, attempt one transaction after another, if you code for one update (one CT for each data block) at a time.
_________________
D.
Answer:
I think that's generally the same as what I do Indy.
Have a good one!
R
_________________
Regards
R
Abap KC

SFMDR

Answer:
R!
Is the next transaction processed if a transaction has errors using call transaction method?
Hi Jessy,
Next transaction will still be process even current transaction failed/error.
Cheers.
Vitamin.
Answer:
R!
Is the next transaction processed if a transaction has errors using call transaction method?
Hi Jessy,
Next transaction will still be process even current transaction failed/error.
Cheers.
Vitamin.
Depends. If you are calling the Transaction in Display All/Error Mode, It stops at the error, Else If you are calling In Display Nothing Mode the error is skipped and the Next Record is Processed.
You have to capture the errors in your Message tab to check the Status.
KRK

More Articles:

User favorites down/upload program?
pls give me an reply about ws_download?
Using File Port But Not Triggering EDI Subsystem?
A Peculiar Problem ?
in bapi,how to Set the structure to a VB object?
download the data from SAP in CSV file format?