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
 

 

Select Variable=string Rexx does not work

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
View previous topic :: :: View next topic  
Author Message
Csongor

New User


Joined: 23 Apr 2015
Posts: 16
Location: Hungary

PostPosted: Thu May 07, 2015 9:33 pm    Post subject: Select Variable=string Rexx does not work
Reply with quote

Hello!

I am new to Rexx, I would like to ask for some help. I want to have a simple code to find the pds where a job is located, the first 3 characters of the job indicates in wich pds the job is. But with the select it does not give me the right ansver. Later on I will work with over 60 pds.
My code:
/*REXX */
JOB='JCC6L0ET'
HLQ=DELSTR(JOB,3,5)
PDS.1='XJ26T.AS.CNTL'
PDS.2='XJ26J.AS.CNTL'
PDS.3='XJ26C.AS.CNTL'
SELECT
WHEN HLQ='JCT' THEN SAY PDS.1'('JOB')'
WHEN HLQ='JCJ' THEN SAY PDS.2'('JOB')'
WHEN HLQ='JCC' THEN SAY PDS.3'('JOB')'
END

and the result is:
XJ26T.AS.CNTL(JCC6L0ET)
it schould be XJ26C.AS.CNTL(JCC6L0ET)
Can you tell me where the problem is in my code? Or is there a better solution?
Back to top
View user's profile Send private message

Csongor

New User


Joined: 23 Apr 2015
Posts: 16
Location: Hungary

PostPosted: Thu May 07, 2015 9:57 pm    Post subject: solution
Reply with quote

I found it myself, the delete string should start on the 4-th character.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7225

PostPosted: Thu May 07, 2015 10:20 pm    Post subject: Reply to: Select Variable=string Rexx does not work
Reply with quote

Next time remember that the functions provided by interpreters, compilers and other things work. It is the way you use them that doesn't, when that happens.
Back to top
View user's profile Send private message
Pedro

Senior Member


Joined: 01 Sep 2006
Posts: 2019
Location: Silicon Valley

PostPosted: Fri May 08, 2015 12:09 am    Post subject: Reply to: Select Variable=string Rexx does not work
Reply with quote

A trace statement would help debug the problem.
Back to top
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 645
Location: Pennsylvania

PostPosted: Fri May 08, 2015 12:38 am    Post subject:
Reply with quote

If it were me, I would replace this line:
HLQ=DELSTR(JOB,3,5)

with
HLQ=LEFT(JOB,3)

It is a little easier to understand what you are trying to achieve.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1713
Location: UK

PostPosted: Fri May 08, 2015 5:46 am    Post subject:
Reply with quote

And I would use Substr(job,1,3). Whichever floats your boat, as they say.
Back to top
View user's profile Send private message
guilhermeagb

New User


Joined: 18 Mar 2015
Posts: 2

PostPosted: Wed Aug 05, 2015 5:52 pm    Post subject:
Reply with quote

You are missing at the specified position . It must start from the 4th place with length: 5.
You can debug your program by inserting a line: 'trace ?r' before operations.


(Wrong) HLQ=DELSTR(JOB,3,5) => JC C6L0E T

HLQ=DELSTR(JOB,3,5) => JCC 6L0ET
Back to top
View user's profile Send private message
Garry Carroll

Active Member


Joined: 08 May 2006
Posts: 988
Location: Dublin, Ireland / Edinburgh, Scotland

PostPosted: Wed Aug 05, 2015 6:10 pm    Post subject:
Reply with quote

3 months on - and surely you mean

HLQ = DELSTR(JOB,4,5) => JCC 6L0ET ?

Garry
Back to top
View user's profile Send private message
guilhermeagb

New User


Joined: 18 Mar 2015
Posts: 2

PostPosted: Wed Aug 05, 2015 6:26 pm    Post subject:
Reply with quote

guilhermeagb wrote:
You are missing at the specified position . It must start from the 4th place with length: 5.
You can debug your program by inserting a line: 'trace ?r' before operations.


(Wrong) HLQ=DELSTR(JOB,3,5) => JC C6L0E T

HLQ=DELSTR(JOB,4,5) => JCC 6L0ET
Back to top
View user's profile Send private message
Pedro

Senior Member


Joined: 01 Sep 2006
Posts: 2019
Location: Silicon Valley

PostPosted: Thu Aug 06, 2015 6:19 am    Post subject: Reply to: Select Variable=string Rexx does not work
Reply with quote

Quote:
Whichever floats your boat, as they say.


If you have an application that is performance sensitive, you probably should not write in rexx. But some will do anyway.

There is a slight advantage in using LEFT rather than DELSTR or SUBSTR.
Code:
/* rexx */                     
JOb='JCC6L0ET'                 
srv_start = sysvar('syssrv')   
Do a= 1 to 5000               
  HLQ=DELSTR(JOB,4,5)         
End                           
srv_end = sysvar('syssrv')     
say 'Diff  = 'srv_end-srv_start
                               
srv_start = sysvar('syssrv')   
Do a= 1 to 5000               
  HLQ=LEFT(JOB,3)             
End                           
srv_end = sysvar('syssrv')     
say 'Diff  = 'srv_end-srv_start
                               
srv_start = sysvar('syssrv')   
Do a= 1 to 5000               
  HLQ=substr(JOB,1,3)         
End                           
srv_end = sysvar('syssrv')     
say 'Diff  = 'srv_end-srv_start

(I was curious)
Though the values were different each time I ran it, at times LEFT was 20% faster than SUBSTR, with DELSTR, somewhere in the middle.
Back to top
View user's profile Send private message
prino

Active Member


Joined: 07 Feb 2009
Posts: 982
Location: Oostende, Belgium

PostPosted: Thu Aug 06, 2015 8:37 am    Post subject: Re: Reply to: Select Variable=string Rexx does not work
Reply with quote

Pedro wrote:
Quote:
Whichever floats your boat, as they say.
If you have an application that is performance sensitive, you probably should not write in rexx. But some will do anyway.

There is a slight advantage in using LEFT rather than DELSTR or SUBSTR.

.
.
.

(I was curious)
Though the values were different each time I ran it, at times LEFT was 20% faster than SUBSTR, with DELSTR, somewhere in the middle

Have you tried timing "parse"? It's supposed to be even faster. No time to do it now myself, about to hitchhike from Belgium to Lithuania...
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: Thu Aug 06, 2015 5:16 pm    Post subject:
Reply with quote

I am curious too, so I copied Pedro's code and added a "parse var job HLQ +3 rest" statement. Results:
Code:
Diff  = 2971 DELSTR
Diff  = 2497 LEFT   
Diff  = 2949 SUBSTR
Diff  = 2313 PARSE 
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 -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts What is the command to check MODE of ... rohanthengal CLIST & REXX 6 Fri Nov 18, 2016 1:48 pm
No new posts Two Selects in a single select query Rohit Umarjikar DB2 1 Fri Nov 04, 2016 8:46 pm
This topic is locked: you cannot edit posts or make replies. Rexx to create GDG by scanning JJ result krish.deepu CLIST & REXX 5 Tue Oct 25, 2016 5:32 pm
No new posts Replace repeated JCL with looping REXX prino CLIST & REXX 3 Thu Oct 13, 2016 5:30 am
This topic is locked: you cannot edit posts or make replies. Need to code a Rexx PGM sundaram.naveen CLIST & REXX 18 Thu Oct 06, 2016 6:45 pm


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