Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Problem with stem variable

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

Active User


Joined: 31 Jan 2008
Posts: 148
Location: Chennai, India

PostPosted: Mon Dec 22, 2008 9:59 pm    Post subject: Problem with stem variable
Reply with quote

Hi all,

Through REXX I try to read a dataset , substring a particular value and
storing into an array.

Here with giving Source Code:

Code:

/*REXX*/                                                         
"EXECIO * DISKR MYINDD1 (FINIS STEM NEWVAR."                   
SAY NEWVAR.0                                                   
DO I = 1 TO NEWVAR.0                                                                 
   NEWDATA = NEWVAR.I                                             
   IF SUBSTR(NEWDATA,59,3) = YES THEN                             
     DO                                                         
       ARR.I = SUBSTR(NEWDATA,10,5)                                 
       SAY ARR.I                                                   
    END                                                         
 END                                                             
 SAY ARR.0


SAY ARR.0 is not giving total no of values, its just printing ARR.0

Please let me know where I am wrong.
Back to top
View user's profile Send private message

superk

Moderator Team Head


Joined: 26 Apr 2004
Posts: 4650
Location: Raleigh, NC, USA

PostPosted: Mon Dec 22, 2008 10:07 pm    Post subject: Reply to: Problem with stem variable
Reply with quote

Maybe I'm missing something, but where have you moved a value into ARR.0?

This is what I would do:

Code:

/*REXX*/                                                         
"EXECIO * DISKR MYINDD1 (FINIS STEM NEWVAR."                   
SAY NEWVAR.0       
CNTR = 0           
ARR. = ""                                 
DO I = 1 TO NEWVAR.0                                               
   IF SUBSTR(NEWVAR.I,59,3) = YES THEN                             
     DO         
       CNTR = CNTR + 1
       ARR.CNTR = SUBSTR(NEWVAR.I,10,5)                                 
       SAY ARR.CNTR       
    END                                                         
 END                                                             
SAY CNTR
Back to top
View user's profile Send private message
PeD

Active User


Joined: 26 Nov 2005
Posts: 456
Location: Belgium

PostPosted: Tue Dec 23, 2008 12:03 am    Post subject:
Reply with quote

If I read correctly the second code of Kevin ( based on the Poster's code ), you can have in case of at least one record(59,3) without YES, you can have a count of items in ARR.I superior to ARR.0

Because I index is used simultaneously for input as well for output.

Pierre
Back to top
View user's profile Send private message
superk

Moderator Team Head


Joined: 26 Apr 2004
Posts: 4650
Location: Raleigh, NC, USA

PostPosted: Tue Dec 23, 2008 12:25 am    Post subject: Reply to: Problem with stem variable
Reply with quote

Yeah, it would be a poor way to code it. I prefer my first example. The other issue I see is that, unless the value YES is present on every record, the stem ARR. will have gaps between values.

I removed that second post. It would be poor coding style.
Back to top
View user's profile Send private message
Pedro

Senior Member


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

PostPosted: Tue Dec 23, 2008 11:14 am    Post subject: Reply to: Problem with stem variable
Reply with quote

Quote:
Maybe I'm missing something, but where have you moved a value into ARR.0?


The convention is that the zero-eth element of the array has the count of elements. But it is not automatic. YOU have to keep track of the count and store it in the .0 element.
Back to top
View user's profile Send private message
murugan_mf

Active User


Joined: 31 Jan 2008
Posts: 148
Location: Chennai, India

PostPosted: Tue Dec 23, 2008 5:30 pm    Post subject:
Reply with quote

When I try to display ARR.1 it is not giving the value for ARR.1 , instead it is printing as ARR.1
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: Tue Dec 23, 2008 5:34 pm    Post subject:
Reply with quote

Then perhaps the variable has not been populated by the conditions set in the code.
Back to top
View user's profile Send private message
PeD

Active User


Joined: 26 Nov 2005
Posts: 456
Location: Belgium

PostPosted: Tue Dec 23, 2008 5:39 pm    Post subject:
Reply with quote

That means that any record satisfied to condition YES and as the stem is not defined and initialised, you have that value ARR.1.

So define the array before

ARR. = ' '
ARR.0 = 0

Also if you "Trace I", you can follow easily your piece of code.

Cheers
Pierre
Back to top
View user's profile Send private message
murugan_mf

Active User


Joined: 31 Jan 2008
Posts: 148
Location: Chennai, India

PostPosted: Tue Dec 23, 2008 7:22 pm    Post subject:
Reply with quote

Problem solved..
Thanks for all your suggestions
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: Tue Dec 23, 2008 7:23 pm    Post subject:
Reply with quote

What was the solution ?
Back to top
View user's profile Send private message
murugan_mf

Active User


Joined: 31 Jan 2008
Posts: 148
Location: Chennai, India

PostPosted: Tue Dec 23, 2008 7:28 pm    Post subject:
Reply with quote

Here some of the variables are having are values 'YES' .
SO when I try to display a value ARR.1 it is displaying as ARR.1 as it is
not having any value

So modified like this..

Code:
CNTR=0                             
DO I=0 TO NEWVAR.0                 
                                   
  NEWDATA=NEWVAR.I                 
                                   
  IF SUBSTR(NEWDATA,58,3)=YES THEN
    DO;                           
    CNTR = CNTR + 1               
    ARR.CNTR=SUBSTR(NEWDATA,10,8) 
    END                           
END                               
                                   
ARR.0 = CNTR 
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 LMINIT problem - not finding DDNAME Danielle.Filteau CLIST & REXX 7 Tue Sep 19, 2017 9:57 pm
No new posts Moving values to a variable of copybo... Vignesh Sid COBOL Programming 6 Wed Sep 06, 2017 1:04 pm
No new posts Updating the Trailer count in variabl... satheshbabur DFSORT/ICETOOL 6 Wed Aug 30, 2017 9:49 pm
No new posts Move from Comp3 variable to Edited Va... sreekusr COBOL Programming 8 Thu Aug 10, 2017 4:20 pm
No new posts Problem commiting to DB2 from IMS MPP Ole Soerensen IMS DB/DC 2 Wed Jul 26, 2017 5:19 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us