Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Checking field value in IF clause in JCL
Goto page 1, 2  Next
 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
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    Post subject: Checking field value in IF clause in JCL
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: 1738
Location: Bloomington, IL

PostPosted: Sat Aug 27, 2011 1:24 am    Post subject: Re: Checking field value in IF clause in JCL
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    Post subject: Re: Checking field value in IF clause in JCL
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    Post subject:
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10201
Location: italy

PostPosted: Sat Aug 27, 2011 1:42 am    Post subject: Reply to: Checking field value in IF clause in JCL
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    Post subject:
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: 1738
Location: Bloomington, IL

PostPosted: Sat Aug 27, 2011 1:57 am    Post subject:
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: 1738
Location: Bloomington, IL

PostPosted: Sat Aug 27, 2011 2:02 am    Post subject:
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    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Sun Aug 28, 2011 9:33 am    Post subject:
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: 1218
Location: Israel

PostPosted: Sun Aug 28, 2011 1:35 pm    Post subject:
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: 8593
Location: Back in jolly old England

PostPosted: Sun Aug 28, 2011 1:36 pm    Post subject:
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: 1738
Location: Bloomington, IL

PostPosted: Mon Aug 29, 2011 3:19 pm    Post subject:
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    Post subject:
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: 641
Location: Whitby, ON, Canada

PostPosted: Mon Aug 29, 2011 10:05 pm    Post subject:
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    Post subject:
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: 641
Location: Whitby, ON, Canada

PostPosted: Mon Aug 29, 2011 11:02 pm    Post subject:
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    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Tue Aug 30, 2011 3:36 am    Post subject: Reply to: Checking field value in IF clause in JCL
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
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm
No new posts Amount field is getting corrupted whe... thesumitk SYNCSORT 5 Tue Oct 18, 2016 8:20 pm
This topic is locked: you cannot edit posts or make replies. Checking wether a string starts from ... sundaram.naveen CLIST & REXX 9 Thu Oct 06, 2016 11:56 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us