Application Development 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: 

In case of error message go back to start screen

Former Member
0 Kudos

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.

12 REPLIES 12

Former Member
0 Kudos

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.

0 Kudos

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.

0 Kudos

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

0 Kudos

Hi,

  

   LEAVE LIST-PROCESSING is better.

Regards,

Mordhwaj

0 Kudos

Hi Maria,

Just see the SAP Standard demo program 'DEMO_MESSAGES' in SE38 transaction.

Thanks & Regards

Bala Krishna

0 Kudos

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.

iftah_peretz
Active Contributor
0 Kudos

Hi,

Try this code:

MESSAGE s001(T00) DISPLAY LIKE 'E' .

submit <the_name_of_your_program>.

leave program.

Hope it was helpful.


former_member184569
Active Contributor
0 Kudos

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.

0 Kudos

Dear Marria,

You can use

LEAVE LIST-PROCESSING

or

LEAVE PROGRAM

Thanks & Regards,

buz_sap


Former Member
0 Kudos

Hi,

Write your error message in AT SELECTION-SCREEN event. Error message will stop at the selection screen.

Regards,

Supriya.

raymond_giuseppi
Active Contributor
0 Kudos

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