Resolving Symbolic variables

Ask/Clarify the questions on TSO, CLIST & REXX

Moderators: Veera, Moderator Group

Post Reply
mainframesara
Member
Posts: 13
Joined: Mon Oct 26, 2009 12:00 pm

Resolving Symbolic variables

Post by mainframesara » Wed Apr 07, 2010 6:34 pm

Hi,
i wrote the rexx pgm to get the Files used in shr mode in Proc PDS. But in the Proc the file is specified using symbolic variables, so the file name is coming as,

&PFX1..&MODE1..&R14..P.&UI.AC.TIMP

The symbolic variables are defined in the top of the PROC as

PFX1 = G19B,
MODE1= PI, AND ETC..,


Anybody have any idea about how to resolve these symbolic variables to get the file name. Basic idea is enough, i will code the exec part.

Thanks in advance.

User avatar
dbzTHEdinosauer
Moderator
Posts: 981
Joined: Mon Oct 02, 2006 8:31 pm

Post by dbzTHEdinosauer » Wed Apr 07, 2010 7:16 pm

I would build two stems to save the symbolics that are defined at the top of the proc
stem1. symbolic without the &
stem2. replacement value

I would parse each filename, as I indentified it, into a third stem - that I would reuse for each filename. I would parse your example as:

stem3.1 &PFX1
stem3.2 .
stem3.3 &MODE1
stem3.4 .
stem3.5 &R14
stem3.6 .
stem3.7 P
stem3.8 &UI
stem3.9 AC
stem3.10 TIMP

when you parse, insure that single '.' are dropped and double '..' are keep as '.' in its own occurance,
that way when you concat them after the subsitution,
you get a valid file name.

then

Code: Select all

do loop stem3.0
  if left(stem3.i,1) = "&" then
    do loop stem1.0   
       if stem3.i = stem1.k then
           stem3.i = stem2.k
    end
end
then concat stem3
Dick Brenholtz
JCL, SQL and code in programs have an irritating habit of doing what you say,
not what you meant.

User avatar
dbzTHEdinosauer
Moderator
Posts: 981
Joined: Mon Oct 02, 2006 8:31 pm

Post by dbzTHEdinosauer » Wed Apr 07, 2010 8:09 pm

this is a little hookie, not really a good PARSE rexxer, but this works:

Code: Select all

/*   */
/*   stemf. contains the parsed filename*/
/*   stema. contains the symbolic variables with the & */
/*   stemb. contains the replacement values*/
/*   */
filename = '&PFX1..&MODE1..&R14..P.&UI.AC.TIMP'
stemf. = ''
/*   */
/*  14 separate items may not be enough */
/*   */
parse var filename stemf.1 '.' stemf.2 '.' stemf.3 '.' stemf.4 '.' stemf.5 '.' stemf.6 '.' stemf.7 '.' stemf.8 '.' stemf.9 '.' stemf.10 '.' stemf.11 '.' stemf.12 '.' stemf.13 '.' stemf.14
/*   */
/*   now go backward and drop the items that were not used */
/*   until you find the first occurance that contains other than null string*/
/*   */
/*   between item 1 and the last, any null is really a '.' */
/*    see below in the filename build routine                */
/*   */
stemf.0 = 14
do i = 14 to 1 by -1 
  if stemf.i > '' then leave
  if stemf.i = '' then
     stemf.0 = stemf.0 - 1
end
/*   */
/*  you are going to have to write your own routine to extract the */
/*   symbolic variables and their replacement values yourself       */
/*   */
/*   if you decide to build stema. without the &, the substitution will */
/*    have to be a concatenation instead of a direct substitution      */
/*   */
stema.0 = 4
stema.1 = '&PFX1'
stema.2 = '&MODE1'
stema.3 = '&R14'
stema.4 = '&UI'

stemb.0 = 4
stemb.1 = 'ACCOUNT'
stemb.2 = 'TEST'
stemb.3 = 'REGIONA'
stemb.4 = '1'
/*   */
/*    now do the replacement*/
/*   */
do i = 1 to stemf.0
   if left(stemf.i,1) = '&' then
     do k = 1 to stema.0
        if stemf.i = stema.k then
           stemf.i = stemb.k
     end   
end
/*   */
/*  rebuild the filename */
/*    remember a null string is really a '.'*/
/*   */
filename_bld = ''
do i = 1 to stemf.0
   if stemf.i = '' then
      filename_bld = filename_bld || '.'
   else
      filename_bld = filename_bld || stemf.i
end
say filename
say filename_bld
Dick Brenholtz
JCL, SQL and code in programs have an irritating habit of doing what you say,
not what you meant.

mainframesara
Member
Posts: 13
Joined: Mon Oct 26, 2009 12:00 pm

Post by mainframesara » Thu Apr 22, 2010 9:15 am

Thanks Guys for your valuable suggestions.

arajune1810
Member
Posts: 2
Joined: Fri Jun 25, 2010 9:47 pm

Post by arajune1810 » Sat Jun 26, 2010 12:00 am

hello guys ...


its really nice and informative post....


i just liked it....


thanks for your information guys ...........

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others