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
 

 

How to dynamically assign different variable to store data ?

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

Active User


Joined: 09 Jun 2014
Posts: 106
Location: windsor

PostPosted: Wed Sep 10, 2014 6:32 pm    Post subject: How to dynamically assign different variable to store data ?
Reply with quote

Hi,

I got the following input , I have the rexx to store the first colum data according to the same second colum . But my question is that each time the number of these data is changed , is anyway to dynamically assgin the different variable to store first colum data by same second colum instead of write lots of select (Variable name1....n )each time ?

Thank you so much !

Input :
Code:
INP01A 01
OUT01A 01
OUT01B 01
OUT01C 01
OUT01D 01
OUT01E 01
INP02A 02
OUT02A 02
INP03A 03
OUT03A 03
OUT03B 03
OUT03C 03
INP06A 06
OUT06A 06
INP07A 07
OUT07A 07
INP08A 08
OUT08A 08


My code :

Code:
DO CU=1 TO Q                             
   DROP STEPNAME                         
   PARSE VALUE STEP.CU WITH STEPNAME TYPE                   
     SELECT                               
         WHEN TYPE='01' then           
              NAME1 = STEPNAME             
         WHEN TYPE='02' then           
              NAME2 = STEPNAME   
         WHEN TYPE='03' then           
              NAME3 = STEPNAME   
         WHEN TYPE='04' then           
              NAME4 = STEPNAME      ----- and so on .
         END                             
         OTHERWISE                       
     END                                 
   END                                   
                               
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7241

PostPosted: Wed Sep 10, 2014 6:46 pm    Post subject: Reply to: How to dynamically assign different variable to st
Reply with quote

You've already managed one stem variable, why not another?
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1219
Location: Israel

PostPosted: Wed Sep 10, 2014 7:32 pm    Post subject:
Reply with quote

Use the INTERPRET instruction:
Code:
INTERPRET "NAME"TYPE" = STEPNAME"

This will assign values to NAME01, NAME02 and so on.
You'll have to take care of the zero if you don't want it.
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1219
Location: Israel

PostPosted: Wed Sep 10, 2014 7:38 pm    Post subject:
Reply with quote

In addition:
  • You don't need to DROP STEPNAME.
  • I would add a period (.) after TYPE in the PARSE line.
  • To do nothing (in the OTHERWISE), use NOP.
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1219
Location: Israel

PostPosted: Wed Sep 10, 2014 7:44 pm    Post subject: Re: Reply to: How to dynamically assign different variable t
Reply with quote

Bill Woodger wrote:
You've already managed one stem variable, why not another?
Panels can't handle stem vars. Maybe that's the reason ?
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7241

PostPosted: Wed Sep 10, 2014 7:58 pm    Post subject: Reply to: How to dynamically assign different variable to st
Reply with quote

Maybe, but I was thinking since they'd not complained about this:

Code:
PARSE VALUE STEP.CU WITH STEPNAME TYPE


then there shouldn't be a problem.

/understatement on
Knowing a bit more about what the aim of the thing is would help, as always
/understatement off
Back to top
View user's profile Send private message
jackzhang75

Active User


Joined: 09 Jun 2014
Posts: 106
Location: windsor

PostPosted: Wed Sep 10, 2014 9:45 pm    Post subject:
Reply with quote

Hi Marso,

Really apprecaite your answer. I changed the code according to your suggestion

Code:
 DO CU=1 TO Q                             
 DROP STEPNAME                             
    PARSE VALUE STEP.CU WITH STEPNAME TYPE
    INTERPRET "NAME"TYPE".CU = STEPNAME"   
 END     


It does the job and another thing is i need these data to be stored in the array variable ,so i made "NAME"TYPE".CU. But when i print out the variable Name01 , it looks like following.
1. How to correct this ? i don't want NAME01.*, i only want it has actual data.
2. How to get total number of input in Name** variable ?

Thank you for your help!

Code:
INP01A
OUT01A
OUT01B
OUT01C   
OUT01D   
OUT01E   
NAME01.7
NAME01.8
NAME01.9
NAME01.10
NAME01.11--- and so on
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7241

PostPosted: Wed Sep 10, 2014 11:01 pm    Post subject: Reply to: How to dynamically assign different variable to st
Reply with quote

Presumably you have something which was used to stuff the data into STEP. so why don't you use that instead of the ravishingly descriptive Q?
Back to top
View user's profile Send private message
Pedro

Senior Member


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

PostPosted: Thu Sep 11, 2014 9:16 pm    Post subject: Reply to: How to dynamically assign different variable to st
Reply with quote

Quote:
But when i print out the variable Name01...

Show us the code for printing.
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1219
Location: Israel

PostPosted: Mon Sep 15, 2014 2:14 pm    Post subject:
Reply with quote

Do I really have to quote myself ?
Marso wrote:
In addition:
  • You don't need to DROP STEPNAME.
  • I would add a period (.) after TYPE in the PARSE line.
  • To do nothing (in the OTHERWISE), use NOP.

Now that makes less sense:
jackzhang75 wrote:
i need these data to be stored in the array variable ,so i made "NAME"TYPE".CU.
If you can use stems. why not use NAME.TYPE.CU
When I have a case like this, I also keep a list of the allocated values:
Code:
If WordPos(TYPE,TYPElist) = 0 Then
   TYPElist = TYPElist TYPE
Code:
Do Z = 1 To Words(TYPElist)
   curTYPE = Word(TYPElist,Z)
   Say '<'NAME.curTYPE.CU'>'
End

And one more tip: when displaying a variable, place it around special signs:
Code:
Say "NAME.TYPE.CU=<"NAME.TYPE.CU'>'
Like this you'll see exactly the contents of the variable
(hint inside the tip: in stems, trailing spaces count...)
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
This topic is locked: you cannot edit posts or make replies. Unwrap the data based on delimiter X'25' bhavana yalavarthi DFSORT/ICETOOL 30 Fri Dec 09, 2016 10:25 am
No new posts Is the 'prompt' data for the DSLIST p... Willy Jensen TSO/ISPF 2 Tue Dec 06, 2016 4:38 am
This topic is locked: you cannot edit posts or make replies. How to move a long alphanumeric data ... lind sh COBOL Programming 8 Mon Dec 05, 2016 7:51 pm
No new posts ODPP(Optim Data privacy Provider) Iss... Rama kishore IBM Tools 1 Mon Nov 07, 2016 5:46 pm
No new posts Can sending 5 MB data between cobol p... Kevin Vaz CICS 12 Tue Oct 18, 2016 4:50 pm


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