06-30-2013 6:14 PM
Hi Guys,
I am looking for a way to get back to the selection screen when an error occur during the program processing.
Could this work or is there a restriction using it?
MESSAGE s001(T00) DISPLAY LIKE 'E' .
Leave list-processing.
Thanks for your advice.
06-30-2013 7:20 PM
Hi Maria,
It will work, message would be a success one and would be shown as error one. Why do not you code it and see the behavior ?
BR.
06-30-2013 10:23 PM
Hi,
it actually works but I asked the question because I am starting a job automatically and if it does end because of an error, I just want to give an error message and the user should be able to restart the process.
I am just confused because of the word "list processing". I am not processing a list.
My goal is just to go back to the selection screen after an error message. That is why I asked if this was appropiate or may be there are also others solutions you can make.
Thanks.
06-30-2013 10:55 PM
Hi guys,
Which one of these is better in this case:
- leave list-processing?
- exit?
- leave to screen 0?
Do you have others ideas?
Thanks
07-01-2013 5:38 AM
07-01-2013 6:11 AM
Hi Maria,
Just see the SAP Standard demo program 'DEMO_MESSAGES' in SE38 transaction.
Thanks & Regards
Bala Krishna
07-01-2013 6:47 AM
Hi Maria,
Use LEAVE LIST-PROCESSING .
Sample Code -
data: jobname like tbtcjob-jobname value
'TRANSFER DATA'.
data: jobcount like tbtcjob-jobcount,
host like msxxlist-host.
data: begin of starttime.
include structure tbtcstrt.
data: end of starttime.
data: starttimeimmediate like btch0000-char1 value 'X'.
* Job open
call function 'JOB_OPEN'
exporting
delanfrep = ' '
jobgroup = ' '
jobname = jobname
sdlstrtdt = sy-datum
sdlstrttm = sy-uzeit
importing
jobcount = jobcount
exceptions
cant_create_job = 01
invalid_job_data = 02
jobname_missing = 03.
*-- I have changed the below NE to EQ to forcefully raise error and see behavior.
if sy-subrc eq 0.
"error processing
MESSAGE 'Error Cause - ' type 'S' DISPLAY LIKE 'E' .
Leave list-processing.
endif.
* Insert process into job
SUBMIT zreport and return
with p_param1 = 'value'
with p_param2 = 'value'
user sy-uname
via job jobname
number jobcount.
if sy-subrc > 0.
"error processing
endif.
* Close job
starttime-sdlstrtdt = sy-datum + 1.
starttime-sdlstrttm = '220000'.
call function 'JOB_CLOSE'
exporting
" event_id = starttime-eventid
" event_param = starttime-eventparm
" event_periodic = starttime-periodic
jobcount = jobcount
jobname = jobname
" laststrtdt = starttime-laststrtdt
" laststrttm = starttime-laststrttm
" prddays = 1
" prdhours = 0
" prdmins = 0
" prdmonths = 0
" prdweeks = 0
" sdlstrtdt = starttime-sdlstrtdt
" sdlstrttm = starttime-sdlstrttm
strtimmed = starttimeimmediate
" targetsystem = host
exceptions
cant_start_immediate = 01
invalid_startdate = 02
jobname_missing = 03
job_close_failed = 04
job_nosteps = 05
job_notex = 06
lock_failed = 07
others = 99.
if sy-subrc eq 0.
"error processing
endif.
-> In the above code once the error occurs, the control will not go to subsequent statements if you use Leave List-Processing. If you do not use it will go.
BR.
06-30-2013 7:33 PM
06-30-2013 8:50 PM
Hi,
Try this code:
MESSAGE s001(T00) DISPLAY LIKE 'E' .
submit <the_name_of_your_program>.
leave program.
Hope it was helpful.
07-01-2013 6:26 AM
You can give
MESSAGE i001(T00).
LEAVE TO SCREEN 0.
Or simply use Leave to transaction statement.
MESSAGE i001(T00).
leave to transaction 'TCODE'.
Cheers,
Susmitha.
07-01-2013 6:55 AM
Dear Marria,
You can use
LEAVE LIST-PROCESSING
or
LEAVE PROGRAM
Thanks & Regards,
buz_sap
07-01-2013 11:35 AM
Hi,
Write your error message in AT SELECTION-SCREEN event. Error message will stop at the selection screen.
Regards,
Supriya.
07-01-2013 12:34 PM
You could also use a LEAVE TO CURRENT TRANSACTION (or LEAVE TO TRANSACTION sy-tcode. for old versions).
Else you could perform the checks in PAI (AT SELECTION-SCREEN), if check are CPU/time consuming wrap the text by a check like following sample which only check range validity if user request execution :
AT SELECTION-SCREEN ON so_range.
CHECK sscrfields-ucomm EQ 'ONLI'
OR sscrfields-ucomm EQ 'PRIN'.
SELECT SINGLE field1 INTO workarea
FROM table
WHERE field1 IN so_range.
IF sy-subrc NE 0.
MESSAGE 'No data found for range'(900) TYPE 'E'.
ENDIF.
So check will not be processed when user press ENTER. Also use the check on a ON clause like ON BLOCK so that fields keep input allowed.
Regards,
Raymond