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
 

 

Parsing JCL SET var=value statements

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

Senior Member


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

PostPosted: Sat Dec 26, 2015 4:41 am    Post subject: Parsing JCL SET var=value statements
Reply with quote

It's not that hard,

Code:
//label SET var=value

is trivial

Code:
//label SET var=(a,(b,(c,d)))

is trivial, count the '(' and ')' parentheses, and (more or less the same for single quotes, just cater for embedded ones)

Code:
//label SET var=value,var2=value2

isn't very hard either, and

Code:
//label SET var=value,var2=value2,
// var3=value3

should be about the same, just check for the comma-space and append the stripped of '//' and leading spaces next line

Anyway, I've come up with

Code:
/* REXX */
  "isredit macro"
  "isredit (ZL) = linenum .zl"

  var. = 0

  do i = 1 to +zl
    "isredit (L) = line" i

    l = substr(l, 13)

    p = pos(' SET ', l, pos(' ', l))

    if p \= 0 then
      do
        vars = strip(substr(l, p + 5), 'L')' '

        do until left(vars, 1) = ' '
          parse value var.0 + 1 vars with $ var.$ '=' val.$ 1 var.0 .

          s = left(val.$, 1)
          p = 1

          select
            when s = '(' then
              do
                op = 1

                do p = 2 by 1 to length(val.$) until op = 0
                  select
                    when substr(val.$, p, 1) = '(' then op = op + 1
                    when substr(val.$, p, 1) = ')' then op = op - 1
                    otherwise
                  end
                end

                vars  = substr(val.$, p + 1)
                val.$ = left(val.$, p)
say left(var.$, 10) val.$
              end

            when s = '''' then
              do
                src = val.$ '*'

                drop t.
                t = 1

                do until src = '' | left(src, 1) \= "'"
                  parse value src with pre "'" text "'" src

                  if src \= '' then
                    do
                      t.t = text
                      t   = t + 1
                    end
                end

                val = ''
                do !=1 to t-1
                  val = val || "'" || t.! || "'"
                end
                vars  = substr(val.$, length(val) + 1)
                val.$ = val
say left(var.$, 10) val.$
              end

            otherwise
              do
                parse value vars with . '=' val.$ ' ' vars
say left(var.$, 10) val.$
              end
          end
          if left(vars, 1) = ',' then
            vars = substr(vars, 2)

          if right(val.$, 1) = ',' then
            do
              val.$ = strip(val.$,, ',')

              i     = i + 1
              "isredit (L) = line" i
              vars = strip(substr(l, 13), 'L')
            end


        end
      end
  end


to be used on the "SE'ed" JESJCL dataset. It seems to work for everything I've thrown at it, but if anyone can suggest any improvements, feel free to share them - the code will eventually be used to improve the readability of submitted JCL by removing the wrapping
Code:
IEFC653I SUBSTITUTION JCL -

messages.
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 Symbolic Parameters in SYSIN DD state... madishpa DFSORT/ICETOOL 3 Mon Jun 27, 2016 6:23 pm
No new posts Extracting Information from DD Statem... Charles Wolters All Other Mainframe Topics 7 Wed Apr 13, 2016 10:21 pm
No new posts Parsing and Listing a Subset of Recor... Charles Wolters IBM Tools 3 Fri Feb 05, 2016 10:39 pm
No new posts DFSORT control statements in any order ? ronald masters DFSORT/ICETOOL 2 Tue Dec 15, 2015 11:22 pm
No new posts Any example of XML GENERATE nested st... marianambot COBOL Programming 6 Tue Sep 22, 2015 7:48 pm


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