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

Select Variable=string Rexx does not work


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
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
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
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

Moderator Emeritus


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

PostPosted: Thu May 07, 2015 10:20 pm
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

Global Moderator


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

PostPosted: Fri May 08, 2015 12:09 am
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: 792
Location: Pennsylvania

PostPosted: Fri May 08, 2015 12:38 am
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: 2455
Location: Hampshire, UK

PostPosted: Fri May 08, 2015 5:46 am
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
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

Senior Member


Joined: 08 May 2006
Posts: 1193
Location: Dublin, Ireland

PostPosted: Wed Aug 05, 2015 6:10 pm
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
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

Global Moderator


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

PostPosted: Thu Aug 06, 2015 6:19 am
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

Senior Member


Joined: 07 Feb 2009
Posts: 1306
Location: Vilnius, Lithuania

PostPosted: Thu Aug 06, 2015 8:37 am
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: 765
Location: Whitby, ON, Canada

PostPosted: Thu Aug 06, 2015 5:16 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Compile Several JCL JOB Through one r... CLIST & REXX 4
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts Running REXX through JOB CLIST & REXX 13
No new posts Error to read log with rexx CLIST & REXX 11
Search our Forums:

Back to Top