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

Need to code a Rexx PGM


IBM Mainframe Forums -> CLIST & REXX
Post new topic   This topic is locked: you cannot edit posts or make replies.
View previous topic :: View next topic  
Author Message
sundaram.naveen
Warnings : 1

New User


Joined: 06 Oct 2016
Posts: 19
Location: India

PostPosted: Thu Oct 06, 2016 6:45 pm
Reply with quote

Hi guys,

My requirement is I need to code a REXX which takes in a PS file as input. Basically this PS file will be similar to the report that we get when we use SuperCE utility to compare two members.
So the input PS file looks somewhat similar to this
Code:

   NEW:ABC.EPY(PGM1)                                              OLD:ABC.POU(PGM1)
I - 0001  MOVE  5            TO WS-VAR1
I - 0010  MOVE  8        TO WS-VAR2
D - 0010  MOVE  5            TO WS-VAR2
I - 0020  MOVE 'ALPHA'       TO WS-NAME



So as you can see in the above input the line 'move 8 to ws-var2'
the TO clause is not aligned properly. The other TO clause that we see are the properly aligned ones.
Let's assume the properly aligned TO clause starts in column 40. Now I need to check whether the given string has a 'TO' clause and if it has whether it starts @ column 40. If not, a report has to be generated in a new ps file mentioning the program name (PGM1) and the entire line of code in which the 'TO' clause is not aligned .

Need your expertise on this.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Thu Oct 06, 2016 6:46 pm
Reply with quote

as already asked, post a sample of the expected output -
not a description!
Back to top
View user's profile Send private message
sundaram.naveen
Warnings : 1

New User


Joined: 06 Oct 2016
Posts: 19
Location: India

PostPosted: Thu Oct 06, 2016 6:50 pm
Reply with quote

Sample Output
Code:

                                       MIS-ALLIGNED CODES

PROGRAM:PGM1
*******************************************
0010  MOVE  8        TO WS-VAR2
*******************************************
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Thu Oct 06, 2016 6:55 pm
Reply with quote

are there other clauses that might be unaligned ?
Back to top
View user's profile Send private message
sundaram.naveen
Warnings : 1

New User


Joined: 06 Oct 2016
Posts: 19
Location: India

PostPosted: Thu Oct 06, 2016 7:17 pm
Reply with quote

The PIC Clause in WS-Section should also begin from 40 and the VALUE clause should begin from 52. These are the requirements for now
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Thu Oct 06, 2016 7:19 pm
Reply with quote

getting info from You is like pulling a tooth,
do You realize that You are giving people who try to help You a very hard time ?
Back to top
View user's profile Send private message
sundaram.naveen
Warnings : 1

New User


Joined: 06 Oct 2016
Posts: 19
Location: India

PostPosted: Thu Oct 06, 2016 7:38 pm
Reply with quote

Quote:

getting info from You is like pulling a tooth,
do You realize that You are giving people who try to help You a very hard time ?


Sorry for that .
Back to top
View user's profile Send private message
steve-myers

Active Member


Joined: 30 Nov 2013
Posts: 917
Location: The Universe

PostPosted: Thu Oct 06, 2016 8:36 pm
Reply with quote

Generally, I don't post in CLIST/Rexx as I seldom write Rexx, and my CLIST skills are only slightly better than your alleged Rexx skills.

However, we - as a group - will not do your work for you, which seems to be your expectation. Our goal is to provide assistance for relatively simple questions and problems. We are not unpaid consultants, we are not unpaid trainers and you should not expect us to spend hours doing research. Over in PL/I / Assembler I occaisionally write simple tutorials, but that is not the primary idea behind this site
Back to top
View user's profile Send private message
sundaram.naveen
Warnings : 1

New User


Joined: 06 Oct 2016
Posts: 19
Location: India

PostPosted: Thu Oct 06, 2016 9:22 pm
Reply with quote

Quote:

Generally, I don't post in CLIST/Rexx as I seldom write Rexx, and my CLIST skills are only slightly better than your alleged Rexx skills.

However, we - as a group - will not do your work for you, which seems to be your expectation. Our goal is to provide assistance for relatively simple questions and problems. We are not unpaid consultants, we are not unpaid trainers and you should not expect us to spend hours doing research. Over in PL/I / Assembler I occaisionally write simple tutorials, but that is not the primary idea behind this site


Hi Steve, I understand that. I am not expecting my task to be done by the rexx geniuses here, rather what I am expecting is a heads up on how to approach my task. Apologies if my post appeared like that to you.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3048
Location: NYC,USA

PostPosted: Thu Oct 06, 2016 9:41 pm
Reply with quote

Why REXX?
You can do this with Cobol , All that you just need to do is read each record into some fixed length , say 500 bytes. and do a simple ref. modification WS-REC(40:2) = 'TO' then continue else write.

Quote:
getting info from You is like pulling a tooth
icon_biggrin.gif
Back to top
View user's profile Send private message
sundaram.naveen
Warnings : 1

New User


Joined: 06 Oct 2016
Posts: 19
Location: India

PostPosted: Thu Oct 06, 2016 10:09 pm
Reply with quote

Well Rexx seems to be a better option in terms of execution, and I was asked to do this in REXX
So......
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Thu Oct 06, 2016 10:39 pm
Reply with quote

Quote:
rather what I am expecting is a heads up on how to approach my task.


where is that You are facing problems - the logic or the coding ???

after You have devised the logic, the coding will not make too much difference
Back to top
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 792
Location: Pennsylvania

PostPosted: Thu Oct 06, 2016 10:55 pm
Reply with quote

Quote:
Why REXX?


Rexx is by far easier to code in the Cobol.

To get the OP on the right track...

Allocate input file
Use EXECIO to read input file into Stem variable INREC. (for example)
Set up a loop varying variable I until of data (INREC.0)
Use the following logic to 'rebuild' each INREC.I when needed

Code:
TOPOS = POS('TO ',INREC.I)
SELECT
  WHEN TOPOS = 0  THEN NOP
  WHEN TOPOS < 40 THEN DO
    PART1 = LEFT(INREC.I,TOPOS-1)
    PART2 = SUBSTR(INREC.I,TOPOS)
    INREC.I = PART1||PART2
  END
  WHEN TOPOS > 40 THEN DO
    PART1 = LEFT(INREC.I,39)
    PART2 = SUBSTR(INREC.I,TOPOS)
    INREC.I = PART1||PART2
  END
  OTHERWISE NOP /* TOPOS = 40 */
END


Allocate output file
Use EXECIO to write output file from Stem variable INREC.

This is just one approach, untested at that.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Thu Oct 06, 2016 11:12 pm
Reply with quote

dave,
You answered the other topic misleading requirement,
in this case no reformatting needed,
just write in the report the offending line

here is a snippet for the actual requirement

it assumes that a stem has been already filled with the data
and it contains only valid records


Code:

data.1  = "   NEW:ABC.EPY(PGM1)     OLD:ABC.POU(PGM1)"
data.2  = "I - 0001  MOVE  5            TO WS-VAR1"
data.3  = "I - 0010  MOVE  8        TO WS-VAR2"
data.4  = "D - 0010  MOVE  5            TO WS-VAR2"
data.5  = "I - 0020  MOVE 'ALPHA'       TO WS-NAME"

data.6  = "   NEW:ABC.EPY(PGM2)     OLD:ABC.POU(PGM2)"
data.7  = "I - 0001  MOVE  5  TO WS-VAR1"
data.8  = "I - 0010  MOVE  8        TO WS-VAR2"
data.9  = "D - 0010  MOVE  5     TO WS-VAR2"

data.0  = 9

keyw.1  = "TO"  ;   keyp.1  = 29 ;
keyw.2  = "PIC" ;   keyp.2  = 29 ;
keyw.3  = "VALUE" ; keyp.3  = 51 ;
keyw.0 = 3


prog = ""
do d = 1 to data.0
    data = data.d
    if  pos("NEW:", data) > 0 then do
        if  prog \= "" then do
            say "end   of data for prog =" prog
            say ""
            /* write some trailer for the old program */
        end
        parse var data . "(" prog ")" .
        say "start of data for prog =" prog
        /* write some header for the new program */
        iterate
    end

    do  k = 1 to keyw.0
        keyp = pos(" "keyw.k" ", data )
        -- say keyw.k keyp
        if  keyp  > 0 & ,
            keyp \= keyp.k then do
            say "error " ">>"data"<< at "keyp
            /* write the detail record for the error */
            iterate d
        end
    end


end
/* process the dangling trailer */
if  prog \= "" then do
    say "end   of data for prog =" prog
    say ""
    /* write some trailer for the old program */
end



TESTED AND WORKING

anyway the topic is going to be locked very shortly
I / we wasted already too much time on it

I confirm the suggestion for the TS to migrate to the beginners forum
and I will undertake the appropriate actions
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3048
Location: NYC,USA

PostPosted: Thu Oct 06, 2016 11:17 pm
Reply with quote

Quote:
Well Rexx seems to be a better option in terms of execution, and I was asked to do this in REXX
So......
Say, you don't know REXX and need to learn but also you can tell to by COBOL in 1 hour or so.
Quote:
Rexx is by far easier to code in the Cobol
Choice is personal, because TS first needs to learn REXX and then code so my point is, this can be done through COBOL ( assume TS knows that at least)
Back to top
View user's profile Send private message
RahulG31

Active User


Joined: 20 Dec 2014
Posts: 446
Location: USA

PostPosted: Thu Oct 06, 2016 11:21 pm
Reply with quote

I think after generating the report the next step would be to make all the 'TO' start at column 40. If you think about why column 40 then you'll realize that the maximum length of a working storage variable name is 30 characters. So, if you start 'TO' at 40, then your variable name will end at column 72 and this is max you can go.

Have you, Or the person who assigned you this task, thought about a variable name with length 30 characters having a subscript?

That would mean that you'll have to write this variable name in a different line. There could be a situation where you have only 'TO' in a single line. It would look bad to me and that would defeat the purpose of having 'TO' in column 40 to make the code look good.

I assume that you would have to align the 'IF' 'ELSE' and other stuff as well with some minimum margin between nested 'IF's. This would again create trouble if you have too many nested 'IF's.

I believe, this is probably a futile effort and not well thought of. You would probably be wasting a lot of time (your and your client's).

If I had so much time, I would rather concentrate on cross technology trainings for me Or for my team.

.
Back to top
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 792
Location: Pennsylvania

PostPosted: Thu Oct 06, 2016 11:22 pm
Reply with quote

The choice is personal of course.

I know both and would choose Rexx most of the time. For this requirement without a doubt.

Please lock this and put all of us out of several miseries.
Back to top
View user's profile Send private message
prino

Senior Member


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

PostPosted: Fri Oct 07, 2016 12:18 am
Reply with quote

daveporcelan wrote:
Please lock this and put all of us out of several miseries.

+42
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 Oct 07, 2016 1:49 am
Reply with quote

Not bad going:

. joined today
. received a warning
. started 2 topics
. both locked
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   This topic is locked: you cannot edit posts or make replies. View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Running REXX through JOB CLIST & REXX 13
No new posts Error to read log with rexx CLIST & REXX 11
No new posts isfline didnt work in rexx at z/OS ve... CLIST & REXX 7
No new posts run rexx code with jcl CLIST & REXX 15
No new posts Execute secondary panel of sdsf with ... CLIST & REXX 1
Search our Forums:

Back to Top