cancel
Showing results for 
Search instead for 
Did you mean: 

How to set a batch Job to cancelled when External Program Fails

Former Member
0 Kudos

Hi Guru's  How do I set and external program in SM36 to cause my Job status to reflect as Cancelled when the Job log picks up and error.  The Job log correctly flags all the errors but the Job Overview screen still reflects as finished.  Does anyone know how I can set the status to cancelled?  e.g. My script executes and is supposed to FTP a file from Unix to Wintel, but if there is no connectivity to the receiver the job log is updated, but the Job overall status reflects Finished.  See below logs.  JOB LOG  Date       Time     Message text                                                                                      Message class Message no. Message typ  2013-06-10 08:23:25 Job started                                                                                            00           516          S 2013-06-10 08:23:26 Step 001 started                                                                                       BT           611          S 2013-06-10 08:23:26 External program: /utl/app/sh/z_transferfile.sh                                                             BT           612          S 2013-06-10 08:23:26 Related parameter:                                                                                     BT           613          S 2013-06-10 08:24:38 Ext. prog.: ssh: connect to host hostname.domain.com port 22: Connection timed out#      BT           606          S 2013-06-10 08:24:38 Ext. prog.: lost connection                                                                            BT           606          S 2013-06-10 08:24:38 Job finished                                                                                           BT           607          S  JOB OVERVIEW Status          Start date Start time  Finished        2013-06-10 08:23:25  Any suggestions will be appreciated and awarded.  Thanks Maahir

Accepted Solutions (1)

Accepted Solutions (1)

former_member206552
Active Contributor
0 Kudos

Hi Maahir,

Prerequisites for Running External Programs

http://help.sap.com/saphelp_nw70/helpdata/en/c4/3a7fbb505211d189550000e829fbbd/content.htm

Analyzing Problems with External Commands and Programs

http://help.sap.com/saphelp_nw70/helpdata/en/c4/3a80c4505211d189550000e829fbbd/content.htm

Hope these helps

Best Regards

Marius

Answers (2)

Answers (2)

0 Kudos

Have you tried calling this script from sm49? In this way the command should be executed in the SAP environment where the kernel communicates directly with the operating system.


Basically the kernel is not a DOS/UNIX interpreter so you may not be able to do exactly the same things from sm49 that you can do directly at OS level. However, sometimes there are ways to work around these issues. There is no shell in this case and while it is possible to run the very basic

unix commands, others have to be contained in a short script at OS level.

willi_eimler
Contributor
0 Kudos

Dear Maahir,

do your script raise errorlevel? Error<> 0 causes a job to abort.

Best regards

Willi Eimler