IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

How to Modify the SAS return code(SYSRC) in the SAS Code?


IBM Mainframe Forums -> All Other Mainframe Topics
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
harikiran.mc

New User


Joined: 18 Jan 2007
Posts: 17
Location: CHENNAI

PostPosted: Fri May 30, 2008 11:24 am
Reply with quote

Generally SAS program in the JCL gives a Return code at the end of the step. Inside the Step I think we can Modify the Return code.
I want to modify the Return code Value in the SAS, like forcing the abend while Testing.

Ex:- Move '8' to %SYSRC.

If anyone knows this please give me some syntax.
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Fri May 30, 2008 11:37 am
Reply with quote

Hi,
I usually use this to return my own RC


Code:
 ABORT 99 ;


Gerry
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Fri May 30, 2008 11:45 am
Reply with quote

Hi,
you can use
Code:
ABORT  ABEND


if you want the job to abend


Gerry
Back to top
View user's profile Send private message
abhishekmdwivedi

New User


Joined: 22 Aug 2006
Posts: 95
Location: india

PostPosted: Fri May 30, 2008 12:32 pm
Reply with quote

hi,
You may use

Code:

DATA _NULL_;     
ABORT ABEND;


to abend your application OR

you may use

Code:

DATA _NULL_;     
ABORT 16;

or
Code:

DATA _NULL_;     
RC=16;           
RETURN;           


to return specific code to JCL, which can be used in the steps below the EXEC SAS.
Back to top
View user's profile Send private message
harikiran.mc

New User


Joined: 18 Jan 2007
Posts: 17
Location: CHENNAI

PostPosted: Fri May 30, 2008 2:42 pm
Reply with quote

Hi Friends!! Thanks a lot for your replies!!!

Hi Abhishek!!

Can we send any message when we use the below syntax:

DATA _NULL_;
ABORT ABEND;

[/img]
Back to top
View user's profile Send private message
abhishekmdwivedi

New User


Joined: 22 Aug 2006
Posts: 95
Location: india

PostPosted: Fri May 30, 2008 2:48 pm
Reply with quote

Well ABORT ABEND is an inbulit SAS function. It just abends the job abnormally.

For SAS System message :
You may use SYSMSG function.
Back to top
View user's profile Send private message
harikiran.mc

New User


Joined: 18 Jan 2007
Posts: 17
Location: CHENNAI

PostPosted: Fri May 30, 2008 2:53 pm
Reply with quote

Sounds Good!! Thanks a Lot !!
Back to top
View user's profile Send private message
harikiran.mc

New User


Joined: 18 Jan 2007
Posts: 17
Location: CHENNAI

PostPosted: Fri May 30, 2008 2:59 pm
Reply with quote

[quote]Hi !! If we Code the below statements, will it abend at that step and return to the JCL and proceeds next step ?
OR
Will it store 16 as return code and perform the next steps in SAS and @ End of SAS code program will terminate??
Code:

DATA _NULL_;     
RC=16;           
RETURN;
[/quote]
Back to top
View user's profile Send private message
abhishekmdwivedi

New User


Joined: 22 Aug 2006
Posts: 95
Location: india

PostPosted: Fri May 30, 2008 3:15 pm
Reply with quote

1) No it will not abend at that step it is used to make steps followed after the EXEC SAS to flush with COND=ONLY within JCL.

2) To abend in SAS code you have to use ABORT ABEND only at an DATA STEP and SAS will terminate immediatly with errored steps (including steps followed by the step having ABORT ABEND).
Back to top
View user's profile Send private message
Alan Voss

New User


Joined: 29 Nov 2006
Posts: 32
Location: Jacksonville, FL

PostPosted: Wed Jun 04, 2008 10:27 pm
Reply with quote

abhishekmdwivedi wrote:
1) No it will not abend at that step it is used to make steps followed after the EXEC SAS to flush with COND=ONLY within JCL.


The above statement is not true. SAS will continue running and RC from SAS will still be 0.

You must use the ABORT statement to end SAS with a user provided return code.
Back to top
View user's profile Send private message
harikiran.mc

New User


Joined: 18 Jan 2007
Posts: 17
Location: CHENNAI

PostPosted: Thu Jun 05, 2008 11:01 am
Reply with quote

Can i use the following code:??

Code:

DATA _NULL_;     
RC=16;           
RETURN;
/* THE ABOVE STEPS WILL MAKES RC TO HOLD THE RETURN CODE AS 16 /*

ABORT ABEND;
/* THIS ABORT STEP WILL ABEND AT THIS STEP AND RETURN TO JCL. SO RC OF THIS SAS STEP WILL BE 16/*

/* PLEASE CORRECT ME IF I'M WORNG/*
Back to top
View user's profile Send private message
harikiran.mc

New User


Joined: 18 Jan 2007
Posts: 17
Location: CHENNAI

PostPosted: Thu Jun 05, 2008 11:03 am
Reply with quote

OR JUST CAN I USE:???
[/code]
DATA _NULL_;
ABORT 16;

/* WILL THE ABOVE LINES OF CODE TERMINATE ABNORMLY AND STORES THE SAS STEP RC AS 16??/*
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10888
Location: italy

PostPosted: Thu Jun 05, 2008 11:06 am
Reply with quote

did anybody care to test before posting icon_rolleyes.gif
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Thu Jun 05, 2008 11:40 am
Reply with quote

Hi Enrico,
I can assure you I have tested what I stated, rarely I don't test the code that I provide.


Gerry
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8796
Location: Welsh Wales

PostPosted: Thu Jun 05, 2008 11:46 am
Reply with quote

gcicchet wrote:
Hi Enrico,
I can assure you I have tested what I stated, rarely I don't test the code that I provide.
Gerry

Surely you must be tempted at some stage to supply untested code, just to see what happens icon_biggrin.gif
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10888
Location: italy

PostPosted: Thu Jun 05, 2008 11:48 am
Reply with quote

Hi Gerry,
I did not mean to put You in the same waste basket icon_biggrin.gif
it' s a pity that good answers get lost in the general noise
and too many people reply just to ... participate
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Thu Jun 05, 2008 11:50 am
Reply with quote

Hi Expat,
I did say rarely icon_lol.gif


Gerry
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10888
Location: italy

PostPosted: Thu Jun 05, 2008 11:54 am
Reply with quote

/nastyness on

sometimes I provide the proper code, with slightly misleading comments
99% of the times nobody cares
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8796
Location: Welsh Wales

PostPosted: Thu Jun 05, 2008 1:02 pm
Reply with quote

I once recall giving an explanation and sample of the code to work from to get the solution, only to have the OP in question post back saying that it didn't work because my code had the incorrect field positions in it icon_rolleyes.gif
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8796
Location: Welsh Wales

PostPosted: Fri Jun 06, 2008 11:36 am
Reply with quote

icon_eek.gif Spooky eh ??? After my very last post on this topic .................

http://www.ibmmainframes.com/viewtopic.php?t=31280

Now let's see, what do I fancy in the 2:00 at Newmarket next week icon_biggrin.gif
Back to top
View user's profile Send private message
abhishekmdwivedi

New User


Joined: 22 Aug 2006
Posts: 95
Location: india

PostPosted: Thu Jun 12, 2008 7:15 pm
Reply with quote

My apologies for posting untested code.
And yes gcicchet you are right that SAS will return value 0 even if RC=16 with return is used within the SAS.
Thanks for correcting me.
Back to top
View user's profile Send private message
siva25

New User


Joined: 22 Jun 2007
Posts: 4
Location: bangalore

PostPosted: Thu May 21, 2009 8:28 pm
Reply with quote

Could anyone please tell me the logic?

I want to modify the Return code Value in the SAS, like forcing the JOB abend while Testing.

My Requirement:

If the output file has only 1 record, then modify the return code, the job (SAS step) should end with a non-zero return code.
If the output file has more than 1 record, the job should end with zero return code.

Thanks in advance.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> All Other Mainframe Topics

 


Similar Topics
Topic Forum Replies
No new posts purge jobs with return code 0 and ret... JCL & VSAM 4
No new posts run rexx code with jcl CLIST & REXX 15
No new posts Compile rexx code with jcl CLIST & REXX 6
No new posts Return codes-Normal & Abnormal te... JCL & VSAM 7
No new posts REXX code to expand copybook in a cob... CLIST & REXX 2
Search our Forums:

Back to Top