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

Checking field value in IF clause in JCL


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Priyanka Pyne

New User


Joined: 09 Feb 2008
Posts: 95
Location: India

PostPosted: Sat Aug 27, 2011 1:20 am
Reply with quote

Hi,

I want to execute one particular step depending on a field value. I have gone through the existing jobs in my prod lbrary and google. It seems we can validate the return code of a particular step through IF condition.

I want to execute a step if field1 not equal to spaces

Can anyone tell me if it is at all possible to check a field value in JCL. And if possible what will be the yntax for this.

I was using
Code:
// IF EMAIL1='' THEN


but it is not working
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1787
Location: Bloomington, IL

PostPosted: Sat Aug 27, 2011 1:24 am
Reply with quote

Priyanka Pyne wrote:
Hi,

I want to execute one particular step depending on a field value. I have gone through the existing jobs in my prod lbrary and google. It seems we can validate the return code of a particular step through IF condition.

I want to execute a step if field1 not equal to spaces

Can anyone tell me if it is at all possible to check a field value in JCL. And if possible what will be the yntax for this.

I was using
Code:
// IF EMAIL1='' THEN


but it is not working

As reading the fine manual would have told you, this is not even close to acceptable.

Now, what is the source of FIELD1 supposed to be? A symbolic variable? A parameter taken from a data set, or output by a program?
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Sat Aug 27, 2011 1:24 am
Reply with quote

Priyanka Pyne wrote:
Hi,

I want to execute one particular step depending on a field value. I have gone through the existing jobs in my prod lbrary and google. It seems we can validate the return code of a particular step through IF condition.

I want to execute a step if field1 not equal to spaces

Can anyone tell me if it is at all possible to check a field value in JCL. And if possible what will be the yntax for this.

I was using
Code:
// IF EMAIL1='' THEN


but it is not working


What does the JCL manual say about the IF statement

Look at the top of this page under IBM MANUALS!
Back to top
View user's profile Send private message
Priyanka Pyne

New User


Joined: 09 Feb 2008
Posts: 95
Location: India

PostPosted: Sat Aug 27, 2011 1:28 am
Reply with quote

I am paasing the value of field1 through panel. It will be a emanil id.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10888
Location: italy

PostPosted: Sat Aug 27, 2011 1:42 am
Reply with quote

please reply to the following question ( already asked anyway )

What does the JCL manual say about the IF statement ???
Back to top
View user's profile Send private message
Priyanka Pyne

New User


Joined: 09 Feb 2008
Posts: 95
Location: India

PostPosted: Sat Aug 27, 2011 1:55 am
Reply with quote

I looked into the manuals. JCL user guide and JCL language references. What I found there is, expressin can be used in the IF clause. But I am not sure if anything can be use as expression other than RC. Please correct me if I am wrong.
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1787
Location: Bloomington, IL

PostPosted: Sat Aug 27, 2011 1:57 am
Reply with quote

Priyanka Pyne wrote:
I am paasing the value of field1 through panel. It will be a emanil id.

For the sake of discussion, I assume that a Rexx exec is being used to handle the panel and tailor skeletonized JCL. Add the first two steps at the beginning of your job:
Code:
//STEP000A EXEC PGM=IEBGENER                                       
//SYSPRINT DD   SYSOUT=*                                           
//SYSUT1   DD   *,DLM=@@                                           
/* Rexx */                                                         
  trace o                                                           
  if (&FIELD1=' ') then return 666                                 
  else return 0                                                     
@@                                                                 
//SYSUT2   DD   DSN=&&TEMP(FOO),DISP=(NEW,PASS),SPACE=(TRK,(1,1,1)),
//         UNIT=TEMPDISK,DCB=(RECFM=VB,LRECL=255)                   
//SYSIN    DD   DUMMY                                               
//STEP000B EXEC PGM=IRXJCL,PARM='FOO'                               
//SYSEXEC  DD   DSN=&&TEMP,DISP=(OLD,DELETE)                       
//SYSTSPRT DD   SYSOUT=*                                           

Encapsulate the desired JCL thus:
Code:
//IF1      IF     (STEP000B.RC = 666) THEN
(stuff to be done)
//ENDIF1   ENDIF
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1787
Location: Bloomington, IL

PostPosted: Sat Aug 27, 2011 2:02 am
Reply with quote

Priyanka Pyne wrote:
I looked into the manuals. JCL user guide and JCL language references. What I found there is, expressin can be used in the IF clause. But I am not sure if anything can be use as expression other than RC. Please correct me if I am wrong.

Your reading comprehension seems flawed. z/OS V1R12.0 MVS JCL Reference clearly states:
Quote:
The following keywords are the only keywords supported by IBM and recommended for use in relational-expressions. Any other keywords, even if accepted by the system, are not intended or supported keywords.

(Emphasis added.)
Back to top
View user's profile Send private message
Priyanka Pyne

New User


Joined: 09 Feb 2008
Posts: 95
Location: India

PostPosted: Sun Aug 28, 2011 12:42 am
Reply with quote

Hi Akatsukami


Could you please let me know which file you are refereing here by DSN=&&TEMP?
Back to top
View user's profile Send private message
Priyanka Pyne

New User


Joined: 09 Feb 2008
Posts: 95
Location: India

PostPosted: Sun Aug 28, 2011 12:59 am
Reply with quote

I tried the provide code but it I am getting RC=3651. I am not sure if I am missing something. Here is what I am doing.

Code:
//STEP000A EXEC PGM=IEBGENER                                       
//SYSPRINT DD   SYSOUT=*                                           
//SYSUT1   DD   *,DLM=@@                                           
/* Rexx */                                                         
  trace o                                                         
  if (=' ') then return 666                                       
  else return 0                                                   
@@                                                                 
//SYSUT2   DD   DSN=&TEMP(FOO),DISP=(NEW,PASS),SPACE=(TRK,(1,1,1)),
//         UNIT=SYSDA,DCB=(RECFM=VB,LRECL=255)                     
//SYSIN    DD   DUMMY                                             
//****************************************************************
//STEP000B EXEC PGM=IRXJCL,PARM='FOO'                             
//SYSEXEC  DD   DSN=&TEMP,DISP=(OLD,DELETE)                       
//SYSTSPRT DD   SYSOUT=*                                           
//****************************************************************
//IF1      IF     (STEP000B.RC = 666) THEN                           
//SEND    EXEC PGM=IKJEFT1B                                         
//SYSIN    DD DUMMY                                                 
//SYSEXEC  DD DSN=TSO.SSS.REXXLIB,DISP=SHR                           
//SYSPRINT DD SYSOUT=*                                               
//SYSTSPRT DD SYSOUT=*                                               
//SYSTSIN  DD *                                                     
%XMITIP () -                                                         
        MSGDD CONTENT -                                             
        MSG72 -                                                     
        REPLYTO xxx@dddd.com -                         
        FROM xxx@dddd.com -                           
        SUBJECT 'Compare job execution status'                       
/*                                                                   
//CONTENT  DD *                                                     
 Comparison job has been completed and the output datasets are ready.
/*             
//ENDIF1   ENDIF
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19243
Location: Inside the Matrix

PostPosted: Sun Aug 28, 2011 9:33 am
Reply with quote

Hello,

Quote:
I tried the provide code but it I am getting RC=3651.
In which step. . .?

Post the diagnostic information generated by the problem step.

If you want people to help, you simply must post something to work with . . .
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Sun Aug 28, 2011 1:35 pm
Reply with quote

Priyanka Pyne wrote:
I am paasing the value of field1 through panel. It will be a emanil id.
I hope you are using a skeleton JCL.
And if yes, why not just do:
Code:
)SEL &EMAIL ¬= &Z
.
. place your step here
.
)ENDSEL

No value = no step. Nothing easier than that!
Back to top
View user's profile Send private message
expat

Global Moderator


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

PostPosted: Sun Aug 28, 2011 1:36 pm
Reply with quote

If you are passing the value through a panel then surely your logic which displays the panel and accepts values should also include the logic to either submit the job or not rather than faffing about doing something totally unrequired in a batch job.
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1787
Location: Bloomington, IL

PostPosted: Mon Aug 29, 2011 3:19 pm
Reply with quote

Priyanka Pyne wrote:
I tried the provide code but it I am getting RC=3651.

FIELD1 is set to null, not space, on return from the panel, as your output clearly shows.

On consideration,I like Marso's solution better than the one I originally devised; it's more comprehensible.
Back to top
View user's profile Send private message
Priyanka Pyne

New User


Joined: 09 Feb 2008
Posts: 95
Location: India

PostPosted: Mon Aug 29, 2011 8:36 pm
Reply with quote

Hi Marco,

I am getting this error.
Code:
ISPF107                                                                 
                                                                         
Control word error                                                         
Invalid control word parameter, EMAIL record-24                         
                                                                         
                                                                         
                                                                         
                                                                         
                                                                         
PYNPRIY,JHLOGPRC,11/08/29,11:05,1,ISR,PGM(ISRUDL) PARM(ISRUDLP) SCRNAME(D
File tailoring input line:                                               
)SEL &EMAIL1.¬= &Z                                                       
                                                                         
    Enter    HELP    command for further information regarding this error.       
    Press    ENTER    key to terminate the dialog.                               
Back to top
View user's profile Send private message
don.leahy

Active Member


Joined: 06 Jul 2010
Posts: 765
Location: Whitby, ON, Canada

PostPosted: Mon Aug 29, 2011 10:05 pm
Reply with quote

Try losing the dot after &EMAIL1
Back to top
View user's profile Send private message
Priyanka Pyne

New User


Joined: 09 Feb 2008
Posts: 95
Location: India

PostPosted: Mon Aug 29, 2011 10:50 pm
Reply with quote

Tried that..same error

Code:
ISPF107                                                                 
                                                                         
Control word error                                                         
Invalid control word parameter, EMAIL record-24                         
                                                                         
                                                                         
                                                                         
                                                                         
                                                                         
PYNPRIY,JHLOGPRC,11/08/29,13:19,2,ISR,PGM(ISRUDL) PARM(ISRUDLP) SCRNAME(D
File tailoring input line:                                               
)SEL &EMAIL1¬= &Z                                                       
                                                                         
    Enter    HELP    command for further information regarding this error.       
    Press    ENTER    key to terminate the dialog.                               
                                                                         
Back to top
View user's profile Send private message
don.leahy

Active Member


Joined: 06 Jul 2010
Posts: 765
Location: Whitby, ON, Canada

PostPosted: Mon Aug 29, 2011 11:02 pm
Reply with quote

There needs to be a SPACE between the variable name and the operator. icon_rolleyes.gif
Back to top
View user's profile Send private message
Priyanka Pyne

New User


Joined: 09 Feb 2008
Posts: 95
Location: India

PostPosted: Tue Aug 30, 2011 1:03 am
Reply with quote

Great!!!. Working now. I have one concern. My job has only this step and if the condition is getting satisfied i.e. email id is blank the job is getting JCL error. Is there anything which can be done?
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Aug 30, 2011 3:36 am
Reply with quote

We don't, yet, have access to your latest JCL. If you can post it and tell us the details of the error you are getting, maybe there is something that can be done.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2454
Location: Hampshire, UK

PostPosted: Tue Aug 30, 2011 10:13 am
Reply with quote

Add a step to your skeleton JCL that executes IEFBR14 - I suspect, but do not know as you have not told us, that the JCL error is something along the lines of 'JOB HAS NO STEPS'.

Time to put your thinking cap on and think about the error and how to resolve it.
Back to top
View user's profile Send private message
Priyanka Pyne

New User


Joined: 09 Feb 2008
Posts: 95
Location: India

PostPosted: Tue Aug 30, 2011 10:22 am
Reply with quote

Thanks a lot to everyone. This is working fine now.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19243
Location: Inside the Matrix

PostPosted: Tue Aug 30, 2011 10:29 am
Reply with quote

Hello,

Quote:
This is working fine now.
So, what was the problem and what fixed it?

If you expect people to spend so much time on your several issues, the least you could do is post what the problem actually was and what fixed it.

You may find less people willing to help if you continue to have these drag-on topics and then provide no followup. . .

d
Back to top
View user's profile Send private message
Priyanka Pyne

New User


Joined: 09 Feb 2008
Posts: 95
Location: India

PostPosted: Tue Aug 30, 2011 10:36 am
Reply with quote

I updated it here as soon as i fixed it. It was giving NO STEP FOUND ERROR. I did as suggested and that worked. I should have given more detail in my earlier post itself. I am really sorry for that.
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Tue Aug 30, 2011 1:03 pm
Reply with quote

Priyanka Pyne wrote:
Great!!!. Working now. I have one concern. My job has only this step and if the condition is getting satisfied i.e. email id is blank the job is getting JCL error. Is there anything which can be done?
icon_rolleyes.gif icon_rolleyes.gif icon_rolleyes.gif icon_exclaim.gif icon_exclaim.gif icon_exclaim.gif icon_evil.gif icon_evil.gif icon_confused.gif icon_confused.gif icon_sad.gif sterb050.gif
In that case, consider:
Code:
IF EMAIL <> '' THEN DO
   "FTOPEN ..."
   "FTINCL ..."
   "FTCLOSE"
   "SUBMIT ..."
END
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 -> JCL & VSAM Goto page 1, 2  Next

 


Similar Topics
Topic Forum Replies
No new posts Help required to reset decimal points... DFSORT/ICETOOL 10
No new posts Sorting Date Field DFSORT/ICETOOL 4
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Join 2 files according to one key field. JCL & VSAM 3
No new posts How to move the first field of each r... DFSORT/ICETOOL 5
Search our Forums:

Back to Top