02-01-2012 8:55 AM
Hello gurus,
I have a very simple problem, which i cannot solve it! i hope you ll help me.
All i want is to call a programm (report) or a transaction in a loop statement, and when an error occurs, i want to log it somewhere and go to the next line. How is this possible in ABAP?
Thanks in advance!
02-01-2012 9:46 AM
You could try BDC calls using CALL TRANSACTION.
Sample:
CALL TRANSACTION (tcode) USING (bdc_table)
MODE 'N'
UPDATE 'S'
MESSAGES INTO i_lmesstab.
i_lmesstab contains the messages (error/status/etc) encountered during the BDC call.
i_lmesstab should be of TYPE STANDARD TABLE OF bdcmsgcoll.
Hope this helped.
02-01-2012 9:37 AM
I think if you run the program in background, message will be logged in job log...please try.
02-01-2012 10:24 AM
It ll be loged but it will not skip it..
so only with call transaction you can do this ?
and what if a programm is not assigned with a transaction code ?
02-01-2012 4:00 PM
Well, it still won't skip the error. I think the only solution is to modify the called program to skip errors and continue when called by your program.
Rob
02-02-2012 1:26 AM
Hi!
Errors are in place so that the transaction will not continue. What's the use in continuing if you have errors in data? (",)
With CALL TRANSACTION, you get to log all messages encountered by the call transaction statement.
You could also use SUBMIT (program) ... AND RETURN statement but I think this will only give you the last error message that terminated the call through SY-SUBRC check.
Also, if you are using LOOP statement to process a lot of transaction like
LOOP AT itab INTO wa.
...
CALL TRANSACTION...
IF sy-subrc IS INITIAL.
"Transaction ended most probably successfully.
ENDIF.
"Check the iMessageTab for the messages encountered
ENDLOOP.
The next line of the internal table itab gets processed anyway regardless if the previous call was successful or not.
Edited by: Michael.Sumaya on Feb 2, 2012 9:32 AM
02-01-2012 9:46 AM
You could try BDC calls using CALL TRANSACTION.
Sample:
CALL TRANSACTION (tcode) USING (bdc_table)
MODE 'N'
UPDATE 'S'
MESSAGES INTO i_lmesstab.
i_lmesstab contains the messages (error/status/etc) encountered during the BDC call.
i_lmesstab should be of TYPE STANDARD TABLE OF bdcmsgcoll.
Hope this helped.